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

fix:修复url识别不准确问题

上级 6b2cdc97
无法预览此类型文件
......@@ -85,9 +85,9 @@
value:
"## edswgdfgdfgdfg\n**dfgdfgdfg**\n_ergdfgdfg_\n> ergergdfg\n```\nwefgdfsfdgdf\n```\n- efwefsdfsdf\n\n\nsdgfdfgdfgdfg\n\n\nedrfgdfgdfg\n\n\n\nergergergergerg\nergergergerg\n\n\nedrfgdfgdfg\n\n\n\nergergergergerg\nergergergerg\n\n\nedrfgdfgdfg\n\n\n\nergergergergerg\nergergergerg",
value:
"![img](https://img2.baidu.com/it/u=3681880960,455182084&fm=26&fmt=auto&gp=0.jpg)",
"[link](https://img2.baidu.com/it/u=3681880960,455182084&fm=26&fmt=auto&gp=0.jpg)",
// value: "当前问题已结题,不再开放新的回答。",
// value: "(http://www.baidu.com)\n(http://www.baidu.com)",
value: "(http://www.baidu.com)\n(http://www.baidu.com)",
disabled: false,
themeOptions: {
dark: false,
......@@ -144,12 +144,11 @@
console.log(res);
},
onUpload: function(file, type, callback) {
console.log(type);
if (type === "video") {
callback("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4");
return;
}
new Promise((res, rej) => {
setTimeout(() => {
res(file);
......
此差异已折叠。
无法预览此类型文件
{
"name": "markdown-editor",
"description": " A open source markdown editor of csdn codechina team contributed",
"version": "0.7.4",
"version": "0.7.5",
"publisher": "guoweijia",
"scripts": {
"start": "webpack serve --mode=development",
......
......@@ -398,6 +398,7 @@ export default {
},
upload(e) {
this.fileList = Array.from(e.target.files);
this.$refs.mdUploadFile.value = "";
},
submit() {
this.$emit("submit", {
......
......@@ -72,15 +72,15 @@ 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
// preload="auto"
// data-setup='{}'>
// <source src="${href}" type="video/mp4"></source>
// </video>`;
// }
// ![img](...)渲染图片
let out = '<img src="' + href + '" alt="' + text + '"';
if (title) {
......@@ -89,22 +89,33 @@ export default {
out += "/>";
return out;
},
// link(href, title, text) {
// console.log(href, title, text);
link(href, title, text) {
console.log(href, title, text);
// if (href === null) {
// return text;
// }
if (href === null) {
return text;
}
let invalidText = "";
if (href === text) {
const invalidRule = /[)】}\]]*$/;
if (href.match(invalidRule)) {
invalidText = href.match(invalidRule)[0];
href = href.replace(invalidRule, "");
text = href;
}
}
// let out = '<a href="' + href + '"';
// if (title) {
// out += ' title="' + title + '"';
// }
// out += ">" + text + "</a>";
// return out;
// },
let out = '<a href="' + href + '"';
if (title) {
out += ' title="' + title + '"';
}
out += ">" + text + "</a>";
if (invalidText) {
out += invalidText;
}
return out;
},
text(text) {
const newText = text.replace(/(\@\S+\s{0,1})/g, function(val) {
const user = _this.getUserByName(val.slice(1).trim());
return `<a type="user" download data-user="${user &&
......
......@@ -18,6 +18,14 @@
>
<span :class="['icon iconfont', `icon-${info.icon}`]"></span>
</div>
<div
v-else-if="info.name === 'video'"
@click="handleTool(info.name, info.startStr, info.endStr)"
v-tip.bottom="videoOptions"
class="tool_button"
>
<span :class="['icon iconfont', `icon-${info.icon}`]"></span>
</div>
<div
v-else
v-tip.bottom="options"
......@@ -31,10 +39,11 @@
<script>
import { checkBoswer } from "@/assets/js/utils";
import codeSelect from "./code-select";
import videoSelect from "./video-select";
import tableSelect from "./table-select";
import markdownDoc from "./markdown-doc";
export default {
components: { codeSelect, tableSelect },
components: { codeSelect, tableSelect, videoSelect },
props: {
info: {
type: Object,
......@@ -104,6 +113,23 @@ export default {
theme: this.darkMode ? "dark" : "light"
};
},
videoOptions() {
return {
// content: this.info.tip,
customComponent: videoSelect,
customClass: "videoSelectDialog",
width: 80,
customListeners: {
select: val => {
this.closeTips();
const lang = val.toLowerCase().replace(/-/, "");
this.handleTool("code", "\n```" + lang + "\n", "\n\n\n```");
}
},
zIndex: parseInt(this.zIndex) + 1,
theme: this.darkMode ? "dark" : "light"
};
},
tableOptions() {
return {
content: this.info.tip,
......
<template>
<div class="video_select_container">
<ul>
<li>上传视频</li>
<li>插入视频</li>
</ul>
</div>
</template>
<script>
export default {
data() {
return {};
}
};
</script>
<style lang="less" scoped>
.video_select_container {
position: relative;
}
ul {
max-height: 142px;
overflow-y: auto;
margin-top: 2px;
margin-bottom: 4px;
padding-top: 4px;
box-sizing: border-box;
scrollbar-color: transparent transparent;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
&::-webkit-scrollbar-thumb {
border-radius: 1em;
background-color: rgba(50, 50, 50, 0.3);
}
&::-webkit-scrollbar-track {
border-radius: 1em;
background-color: rgba(50, 50, 50, 0);
}
li {
cursor: pointer;
height: 24px;
line-height: 24px;
&:hover {
color: var(--md-editor-border-color-active);
}
}
}
</style>
......@@ -2,12 +2,7 @@ import Vue from "vue";
import App from "./App";
import Vtip from "vtip";
import "vtip/lib/index.min.css";
import {
initStyle,
setzIndex,
isNotEmpty,
getParameterName
} from "@/assets/js/utils";
import { initStyle, setzIndex, isNotEmpty } from "@/assets/js/utils";
import "@/assets/style/global.less";
Vue.use(Vtip.directive);
......@@ -111,22 +106,12 @@ function initMdEditor(obj) {
onSubmit(val);
},
upload({ val, type, callback }) {
const params = getParameterName(onUpload);
if (!params.includes("type")) {
onUpload(val, function(res) {
callback({
url: res,
file: val
});
onUpload(val, type, function(res) {
callback({
url: res,
file: val
});
} else {
onUpload(val, type, function(res) {
callback({
url: res,
file: val
});
});
}
});
},
renderLinks({ links, callback }) {
if (!renderLinks) return callback(links);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册