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

fix:修复link

上级 340cfd4b
...@@ -245,7 +245,7 @@ export default { ...@@ -245,7 +245,7 @@ export default {
const newText = formatText( const newText = formatText(
originalText, originalText,
selectionInfo, selectionInfo,
"\n![video](", "![video](",
`${url} '${name}')\n` `${url} '${name}')\n`
); );
_this.text = newText; _this.text = newText;
......
...@@ -385,12 +385,26 @@ export function getLinkTitle(linkEl, item) { ...@@ -385,12 +385,26 @@ export function getLinkTitle(linkEl, item) {
const originTitle = linkEl.innerText; const originTitle = linkEl.innerText;
const titleEl = Array.from(linkEl.getElementsByClassName("md_link_title")); const titleEl = Array.from(linkEl.getElementsByClassName("md_link_title"));
if (titleEl.length) return item.title || titleEl[0].innerText; if (titleEl.length) return item.title || titleEl[0].innerText;
return /^http/.test(originTitle) ? "" : originTitle; return /^(http|www)/.test(originTitle) ? "" : originTitle;
}
export function removeLinkHeadAndEnd(link) {
if (!link) return "";
return link.replace(/^https?:\/\//, "").replace(/\/$/, "");
} }
export function renderLinkCard(title, item) { export function renderLinkCard(title, item) {
console.log(item.title);
console.log(item.url);
return ` return `
<span class="md_link_title">${title || item.title || ""}</span> ${
removeLinkHeadAndEnd(item.title) === removeLinkHeadAndEnd(item.url)
? ""
: `
<span class="md_link_title">${title || item.title || ""}</span>
`
}
${`<span class="md_link_desc" style="${ ${`<span class="md_link_desc" style="${
item.description ? "" : "margin: 0px 0 2px" item.description ? "" : "margin: 0px 0 2px"
}">${item.description || ""}</span>`} }">${item.description || ""}</span>`}
......
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
.md_preview { .md_preview {
font-family: -apple-system, SF UI Text, Arial, PingFang SC, Hiragino Sans GB, font-family: -apple-system, SF UI Text, Arial, PingFang SC, Hiragino Sans GB,
Microsoft YaHei, WenQuanYi Micro Hei, sans-serif, SimHei, SimSun; Microsoft YaHei, WenQuanYi Micro Hei, sans-serif, SimHei, SimSun;
video {
display: block;
}
img { img {
max-width: 100%; max-width: 100%;
height: auto; height: auto;
......
...@@ -72,15 +72,13 @@ export default { ...@@ -72,15 +72,13 @@ export default {
</div> </div>
</div>`; </div>`;
} }
// if (text === "video") { if (text === "video") {
// return `<video return `<video
// class="video-js" class="video-js"
// controls controls
// preload="auto" src="${href}"
// data-setup='{}'> />`;
// <source src="${href}" type="video/mp4"></source> }
// </video>`;
// }
// ![img](...)渲染图片 // ![img](...)渲染图片
let out = '<img src="' + href + '" alt="' + text + '"'; let out = '<img src="' + href + '" alt="' + text + '"';
if (title) { if (title) {
......
...@@ -118,12 +118,20 @@ export default { ...@@ -118,12 +118,20 @@ export default {
// content: this.info.tip, // content: this.info.tip,
customComponent: videoSelect, customComponent: videoSelect,
customClass: "videoSelectDialog", customClass: "videoSelectDialog",
width: 80, width: 72,
customListeners: { customListeners: {
select: val => { addVideo: val => {
this.closeTips(); this.closeTips();
const lang = val.toLowerCase().replace(/-/, ""); switch (val) {
this.handleTool("code", "\n```" + lang + "\n", "\n\n\n```"); case "link":
this.handleTool("code", "![video](", ")\n");
break;
case "upload":
this.$emit("upload", "video");
break;
default:
break;
}
} }
}, },
zIndex: parseInt(this.zIndex) + 1, zIndex: parseInt(this.zIndex) + 1,
......
<template> <template>
<div class="video_select_container"> <div class="video_select_container">
<ul> <ul>
<li>上传视频</li> <li @click="$emit('addVideo', 'upload')">上传视频</li>
<li>插入视频</li> <li @click="$emit('addVideo', 'link')">插入视频</li>
</ul> </ul>
</div> </div>
</template> </template>
...@@ -42,6 +42,7 @@ ul { ...@@ -42,6 +42,7 @@ ul {
cursor: pointer; cursor: pointer;
height: 24px; height: 24px;
line-height: 24px; line-height: 24px;
text-align: center;
&:hover { &:hover {
color: var(--md-editor-border-color-active); color: var(--md-editor-border-color-active);
} }
......
...@@ -237,13 +237,13 @@ export default { ...@@ -237,13 +237,13 @@ export default {
startStr: "", startStr: "",
endStr: "" endStr: ""
}, },
// { {
// name: "video", name: "video",
// icon: "shipin", icon: "shipin",
// tip: "上传视频", tip: "上传视频",
// startStr: "", startStr: "",
// endStr: "" endStr: ""
// }, },
{ {
name: "task", name: "task",
icon: "renwu", icon: "renwu",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册