提交 c478b01f 编写于 作者: 璃白.'s avatar 璃白. 🌻

fix:优化选择链接展示样式表示

上级 e84da320
......@@ -453,6 +453,8 @@ export default {
},
renderLinksHtml({ vDom, links }) {
const _this = this;
console.log(links);
this.$emit("renderLinks", {
links,
callback: function(list) {
......@@ -464,6 +466,7 @@ export default {
? "https://link.csdn.net/?target=" + item.url
: item.url;
// linkEl.className = "md_link_card";
item.linkType = linkEl.getAttribute("data-type");
linkEl.setAttribute("target", "_blank");
linkEl.setAttribute("href", url);
const title = getLinkTitle(linkEl, item);
......
......@@ -369,11 +369,9 @@ export function getLinkTags(id, html) {
virtualDom.querySelectorAll("a:not([download])")
).map((item, index) => {
item.id = id + "_" + new Date().getTime() + "_" + index;
const linkType = item.getAttribute("data-type");
return {
id: item.id,
title: item.innerText,
linkType,
url: item.href
};
});
......@@ -466,3 +464,5 @@ export function getfilesize(size) {
return (size / Math.pow(num, 3)).toFixed(2) + "G"; //G
return (size / Math.pow(num, 4)).toFixed(2) + "T"; //T
}
export const linkTypeSpiltStr = "/%ra";
......@@ -437,6 +437,12 @@ export default {
)
)
return;
const cursorPoint = getPosition(this.id);
const prefixStr = this.textContent.slice(
cursorPoint - str.length - 5,
cursorPoint - str.length
);
if (prefixStr.includes("src=")) return;
this.createSelectLinkTypeDialog();
});
......
......@@ -3,7 +3,7 @@ import {
getLinkTags,
addLanguageClass,
addLinkTarget,
renderVideo,
linkTypeSpiltStr,
getfilesize
} from "@/assets/js/utils";
import marked from "marked";
......@@ -121,10 +121,10 @@ export default {
if (href === null) {
return text;
}
const linkTypeArr = href.split("::");
const linkTypeArr = href.split(linkTypeSpiltStr);
const linkType = linkTypeArr[1];
href = linkTypeArr[0];
text = text.split("::")[0];
text = text.split(linkTypeSpiltStr)[0];
let invalidText = "";
if (href === text) {
const invalidRule = /[)】}\]]*$/;
......
import { getPosition, formatText } from "@/assets/js/utils";
import { getPosition, formatText, linkTypeSpiltStr } from "@/assets/js/utils";
export default {
methods: {
handleSelectLinkType(index) {
......@@ -11,10 +11,10 @@ export default {
case 0:
break;
case 1:
typeStr = "::1";
typeStr = linkTypeSpiltStr + "1";
break;
case 2:
typeStr = "::2";
typeStr = linkTypeSpiltStr + "2";
break;
default:
break;
......@@ -71,23 +71,11 @@ export default {
left:
pEl.offsetLeft < frameWidth * (2 / 3)
? pEl.offsetLeft
: pEl.offsetLeft - 200,
: pEl.offsetLeft - 140,
top: pEl.offsetTop - textEl.scrollTop
};
textEl.parentNode.removeChild(hideEl);
// this.queryInfo.startPosition = getPosition(this.id) + 1;
// this.queryInfo.endPosition = getPosition(this.id) + 1;
// if (type === "android") {
// this.queryInfo.startPosition--;
// this.queryInfo.endPosition--;
// }
// this.$emit("queryUserList", this.queryInfo.keyWord);
this.$nextTick(() => {
// const userList = this.userList;
// if (userList === false) return;
// if (this.queryInfo.keyWord === "") {
// this.allUserList = userList;
// }
this.showSelectLinkType = true;
this.$nextTick(() => {
const list = textEl.parentNode.querySelector(".md_select_user");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册