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

添加es module引用方式

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