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

添加es module引用方式

上级 4923eaac
...@@ -4,9 +4,10 @@ import Vtip from "vtip"; ...@@ -4,9 +4,10 @@ import Vtip from "vtip";
import "vtip/lib/index.min.css"; import "vtip/lib/index.min.css";
import { initStyle, setzIndex, isNotEmpty } from "@/assets/js/utils"; import { initStyle, setzIndex, isNotEmpty } from "@/assets/js/utils";
import "@/assets/style/global.less"; import "@/assets/style/global.less";
import "@/assets/style/code/lightfair.less";
Vue.use(Vtip.directive); Vue.use(Vtip.directive);
function initMdEditor(obj) { const initMdEditor = function (obj) {
const _this = this; const _this = this;
this.value = { this.value = {
text: "", text: "",
...@@ -110,7 +111,7 @@ function initMdEditor(obj) { ...@@ -110,7 +111,7 @@ function initMdEditor(obj) {
onSubmit(val); onSubmit(val);
}, },
upload({ val, type, callback }) { upload({ val, type, callback }) {
onUpload(val, type, function(res) { onUpload(val, type, function (res) {
callback({ callback({
url: res, url: res,
file: val file: val
...@@ -119,13 +120,13 @@ function initMdEditor(obj) { ...@@ -119,13 +120,13 @@ function initMdEditor(obj) {
}, },
renderLinks({ links, callback }) { renderLinks({ links, callback }) {
if (!renderLinks) return callback(links); if (!renderLinks) return callback(links);
renderLinks(links, function(res) { renderLinks(links, function (res) {
callback(res); callback(res);
}); });
}, },
queryUserList({ keyWord, callback }) { queryUserList({ keyWord, callback }) {
if (!queryUserList) return callback(false); // 返回false则不触发@弹窗 if (!queryUserList) return callback(false); // 返回false则不触发@弹窗
queryUserList(keyWord, function(res) { queryUserList(keyWord, function (res) {
const list = res; const list = res;
if (!keyWord) return callback(list); if (!keyWord) return callback(list);
callback( callback(
...@@ -144,18 +145,18 @@ function initMdEditor(obj) { ...@@ -144,18 +145,18 @@ function initMdEditor(obj) {
}) })
}).$mount(el); }).$mount(el);
this.getVideoList = function(callback) { this.getVideoList = function (callback) {
return this.vEl.$children[0].getVideoList(callback); return this.vEl.$children[0].getVideoList(callback);
}; };
this.getValue = function(callback) { this.getValue = function (callback) {
if (callback) { if (callback) {
callback(this.value); callback(this.value);
} }
return this.value; return this.value;
}; };
this.setValue = function(val) { this.setValue = function (val) {
props.value = (val || "") + ""; props.value = (val || "") + "";
this.vEl.$forceUpdate(); this.vEl.$forceUpdate();
if (!props.setPreview) return; if (!props.setPreview) return;
...@@ -167,27 +168,27 @@ function initMdEditor(obj) { ...@@ -167,27 +168,27 @@ function initMdEditor(obj) {
}); });
}; };
this.focus = function() { this.focus = function () {
props.focus = true; props.focus = true;
this.vEl.$forceUpdate(); this.vEl.$forceUpdate();
}; };
this.blur = function() { this.blur = function () {
props.focus = false; props.focus = false;
this.vEl.$forceUpdate(); this.vEl.$forceUpdate();
}; };
this.disable = function() { this.disable = function () {
props.disabled = true; props.disabled = true;
this.vEl.$forceUpdate(); this.vEl.$forceUpdate();
}; };
this.enable = function() { this.enable = function () {
props.disabled = false; props.disabled = false;
this.vEl.$forceUpdate(); this.vEl.$forceUpdate();
}; };
this.registerTools = function(option) { this.registerTools = function (option) {
props.registerTools = []; props.registerTools = [];
if (Array.isArray(option)) { if (Array.isArray(option)) {
props.registerTools.push(...option); props.registerTools.push(...option);
...@@ -197,7 +198,7 @@ function initMdEditor(obj) { ...@@ -197,7 +198,7 @@ function initMdEditor(obj) {
this.vEl.$forceUpdate(); this.vEl.$forceUpdate();
}; };
this.toggleTab = function(setPreview) { this.toggleTab = function (setPreview) {
if (setPreview !== "edit" && setPreview !== "preview") { if (setPreview !== "edit" && setPreview !== "preview") {
props.setPreview = !props.setPreview; props.setPreview = !props.setPreview;
} else { } else {
...@@ -207,7 +208,7 @@ function initMdEditor(obj) { ...@@ -207,7 +208,7 @@ function initMdEditor(obj) {
this.vEl.$forceUpdate(); this.vEl.$forceUpdate();
}; };
this.toggleFullScreen = function(setFullScreen) { this.toggleFullScreen = function (setFullScreen) {
if (setFullScreen === undefined) { if (setFullScreen === undefined) {
props.setFullScreen = !props.setFullScreen; props.setFullScreen = !props.setFullScreen;
} else { } else {
...@@ -215,6 +216,8 @@ function initMdEditor(obj) { ...@@ -215,6 +216,8 @@ function initMdEditor(obj) {
} }
this.vEl.$forceUpdate(); this.vEl.$forceUpdate();
}; };
} };
window.MdEditor = initMdEditor; window.MdEditor = initMdEditor;
export default initMdEditor;
...@@ -2,14 +2,20 @@ const path = require("path"); ...@@ -2,14 +2,20 @@ const path = require("path");
const VueLoaderPlugin = require("vue-loader/lib/plugin"); const VueLoaderPlugin = require("vue-loader/lib/plugin");
module.exports = { module.exports = {
entry: path.resolve(__dirname, "./src/main.js"), entry: path.resolve(__dirname, "./src/main.js"),
experiments: {
outputModule: true
},
output: { output: {
filename: "markdown-editor.js", filename: "markdown-editor.js",
path: path.resolve(__dirname, "public") path: path.resolve(__dirname, "public"),
library: {
type: "module"
}
}, },
devServer: { devServer: {
contentBase: path.resolve(__dirname, "public"), contentBase: path.resolve(__dirname, "public"),
host: "0.0.0.0", host: "0.0.0.0",
port: '80', port: "80",
// port: 443, // port: 443,
// https: true, // https: true,
open: true open: true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册