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

fix:修复link

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