md-editor-v3 2.0.0 → 2.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +4 -2
- package/lib/MdEditor/Editor.d.ts +4 -4
- package/lib/MdEditor/index.d.ts +11 -11
- package/lib/md-editor-v3.es.js +75 -77
- package/lib/md-editor-v3.umd.js +52 -52
- package/lib/style.css +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -398,7 +398,7 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
398
398
|
| CTRL + SHIFT + S | line-through | `~line-through~` |
|
|
399
399
|
| CTRL + SHIFT + U | unordered list | `- unordered list` |
|
|
400
400
|
| CTRL + SHIFT + C | code block | |
|
|
401
|
-
| CTRL + SHIFT + I | picture | `` |
|
|
402
402
|
| CTRL + SHIFT + Z | forward | Forward history in editor, not the function of system |
|
|
403
403
|
| CTRL + SHIFT + F | Beautify | |
|
|
404
404
|
| CTRL + ALT + C | code row | |
|
|
@@ -516,10 +516,11 @@ const text = ref('# Hello Editor');
|
|
|
516
516
|
</script>
|
|
517
517
|
```
|
|
518
518
|
|
|
519
|
-
### Upload
|
|
519
|
+
### Upload Picture
|
|
520
520
|
|
|
521
521
|
> Tips: When you paste and upload GIF, it will upload a static picture. So you should upload it by file system!
|
|
522
522
|
|
|
523
|
+
```vue
|
|
523
524
|
<template>
|
|
524
525
|
<md-editor v-model="text" @onUploadImg="onUploadImg" />
|
|
525
526
|
</template>
|
|
@@ -553,6 +554,7 @@ const onUploadImg = async (files, callback) => {
|
|
|
553
554
|
callback(res.map((item) => item.data.url));
|
|
554
555
|
};
|
|
555
556
|
</script>
|
|
557
|
+
```
|
|
556
558
|
|
|
557
559
|
### Change Styles
|
|
558
560
|
|
package/lib/MdEditor/Editor.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
119
119
|
type: PropType<string>;
|
|
120
120
|
default: string;
|
|
121
121
|
};
|
|
122
|
-
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "
|
|
122
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "onError" | "onUploadImg" | "onChange" | "onHtmlChanged" | "onGetCatalog" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
123
123
|
modelValue: {
|
|
124
124
|
type: PropType<string>;
|
|
125
125
|
default: string;
|
|
@@ -238,20 +238,20 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
238
238
|
default: string;
|
|
239
239
|
};
|
|
240
240
|
}>>, {
|
|
241
|
-
|
|
241
|
+
pageFullScreen: boolean;
|
|
242
242
|
preview: boolean;
|
|
243
243
|
htmlPreview: boolean;
|
|
244
|
+
editorId: string;
|
|
245
|
+
noPrettier: boolean;
|
|
244
246
|
tabWidth: number;
|
|
245
247
|
theme: Themes;
|
|
246
248
|
historyLength: number;
|
|
247
249
|
previewOnly: boolean;
|
|
248
250
|
showCodeRowNumber: boolean;
|
|
249
251
|
previewTheme: string;
|
|
250
|
-
noPrettier: boolean;
|
|
251
252
|
style: string | CSSProperties;
|
|
252
253
|
class: string;
|
|
253
254
|
modelValue: string;
|
|
254
|
-
pageFullScreen: boolean;
|
|
255
255
|
language: string;
|
|
256
256
|
toolbars: ToolbarNames[];
|
|
257
257
|
toolbarsExclude: ToolbarNames[];
|
package/lib/MdEditor/index.d.ts
CHANGED
|
@@ -9,20 +9,20 @@ declare const _default: {
|
|
|
9
9
|
$: import("vue").ComponentInternalInstance;
|
|
10
10
|
$data: {};
|
|
11
11
|
$props: Partial<{
|
|
12
|
-
|
|
12
|
+
pageFullScreen: boolean;
|
|
13
13
|
preview: boolean;
|
|
14
14
|
htmlPreview: boolean;
|
|
15
|
+
editorId: string;
|
|
16
|
+
noPrettier: boolean;
|
|
15
17
|
tabWidth: number;
|
|
16
18
|
theme: import("./type").Themes;
|
|
17
19
|
historyLength: number;
|
|
18
20
|
previewOnly: boolean;
|
|
19
21
|
showCodeRowNumber: boolean;
|
|
20
22
|
previewTheme: string;
|
|
21
|
-
noPrettier: boolean;
|
|
22
23
|
style: string | import("vue").CSSProperties;
|
|
23
24
|
class: string;
|
|
24
25
|
modelValue: string;
|
|
25
|
-
pageFullScreen: boolean;
|
|
26
26
|
language: string;
|
|
27
27
|
toolbars: import("./type").ToolbarNames[];
|
|
28
28
|
toolbarsExclude: import("./type").ToolbarNames[];
|
|
@@ -151,7 +151,7 @@ declare const _default: {
|
|
|
151
151
|
type: import("vue").PropType<string>;
|
|
152
152
|
default: string;
|
|
153
153
|
};
|
|
154
|
-
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "
|
|
154
|
+
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "pageFullScreen" | "preview" | "htmlPreview" | "editorId" | "noPrettier" | "tabWidth" | "theme" | "historyLength" | "previewOnly" | "showCodeRowNumber" | "previewTheme" | "style" | "class" | "modelValue" | "language" | "toolbars" | "toolbarsExclude" | "markedHeadingId" | "tableShape" | "noMermaid" | "sanitize" | "placeholder" | "noKatex" | "codeTheme">;
|
|
155
155
|
$attrs: {
|
|
156
156
|
[x: string]: unknown;
|
|
157
157
|
};
|
|
@@ -284,20 +284,20 @@ declare const _default: {
|
|
|
284
284
|
default: string;
|
|
285
285
|
};
|
|
286
286
|
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, {
|
|
287
|
-
|
|
287
|
+
pageFullScreen: boolean;
|
|
288
288
|
preview: boolean;
|
|
289
289
|
htmlPreview: boolean;
|
|
290
|
+
editorId: string;
|
|
291
|
+
noPrettier: boolean;
|
|
290
292
|
tabWidth: number;
|
|
291
293
|
theme: import("./type").Themes;
|
|
292
294
|
historyLength: number;
|
|
293
295
|
previewOnly: boolean;
|
|
294
296
|
showCodeRowNumber: boolean;
|
|
295
297
|
previewTheme: string;
|
|
296
|
-
noPrettier: boolean;
|
|
297
298
|
style: string | import("vue").CSSProperties;
|
|
298
299
|
class: string;
|
|
299
300
|
modelValue: string;
|
|
300
|
-
pageFullScreen: boolean;
|
|
301
301
|
language: string;
|
|
302
302
|
toolbars: import("./type").ToolbarNames[];
|
|
303
303
|
toolbarsExclude: import("./type").ToolbarNames[];
|
|
@@ -568,21 +568,21 @@ declare const _default: {
|
|
|
568
568
|
type: import("vue").PropType<string>;
|
|
569
569
|
default: string;
|
|
570
570
|
};
|
|
571
|
-
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "
|
|
572
|
-
|
|
571
|
+
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onSave" | "onError" | "onUploadImg" | "onChange" | "onHtmlChanged" | "onGetCatalog" | "update:modelValue", {
|
|
572
|
+
pageFullScreen: boolean;
|
|
573
573
|
preview: boolean;
|
|
574
574
|
htmlPreview: boolean;
|
|
575
|
+
editorId: string;
|
|
576
|
+
noPrettier: boolean;
|
|
575
577
|
tabWidth: number;
|
|
576
578
|
theme: import("./type").Themes;
|
|
577
579
|
historyLength: number;
|
|
578
580
|
previewOnly: boolean;
|
|
579
581
|
showCodeRowNumber: boolean;
|
|
580
582
|
previewTheme: string;
|
|
581
|
-
noPrettier: boolean;
|
|
582
583
|
style: string | import("vue").CSSProperties;
|
|
583
584
|
class: string;
|
|
584
585
|
modelValue: string;
|
|
585
|
-
pageFullScreen: boolean;
|
|
586
586
|
language: string;
|
|
587
587
|
toolbars: import("./type").ToolbarNames[];
|
|
588
588
|
toolbarsExclude: import("./type").ToolbarNames[];
|
package/lib/md-editor-v3.es.js
CHANGED
|
@@ -17,7 +17,7 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
import { onMounted, onBeforeUnmount, provide, computed,
|
|
20
|
+
import { onMounted, onBeforeUnmount, provide, computed, reactive, watch, ref, defineComponent, createVNode, cloneVNode, nextTick, inject, Fragment, toRef, isVNode } from "vue";
|
|
21
21
|
const prefix = "md";
|
|
22
22
|
const iconfontUrl = "https://at.alicdn.com/t/font_2605852_pqekijay2ij.js";
|
|
23
23
|
const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
|
|
@@ -498,10 +498,10 @@ const updateHandler = debounce((id, attr, value) => {
|
|
|
498
498
|
}
|
|
499
499
|
}, 10);
|
|
500
500
|
const useKeyBoard = (props2, context) => {
|
|
501
|
-
const { editorId } = props2;
|
|
501
|
+
const { editorId, noPrettier } = props2;
|
|
502
502
|
const initFunc = (name) => {
|
|
503
503
|
var _a, _b;
|
|
504
|
-
return ((_a = props2.toolbars) == null ? void 0 : _a.includes(name)) && !((_b = props2.toolbarsExclude) == null ? void 0 : _b.includes(name));
|
|
504
|
+
return ((_a = props2.toolbars) == null ? void 0 : _a.includes(name)) && !((_b = props2.toolbarsExclude) == null ? void 0 : _b.includes(name)) && !noPrettier;
|
|
505
505
|
};
|
|
506
506
|
const keyDownHandler = (event) => {
|
|
507
507
|
if (event.target !== document.querySelector(`#${props2.editorId}-textarea`)) {
|
|
@@ -824,6 +824,72 @@ const useExpansion = (props2, extension) => {
|
|
|
824
824
|
}
|
|
825
825
|
});
|
|
826
826
|
};
|
|
827
|
+
const useConfig = (props2, context) => {
|
|
828
|
+
const { editorId } = props2;
|
|
829
|
+
const setting = reactive({
|
|
830
|
+
pageFullScreen: props2.pageFullScreen,
|
|
831
|
+
fullscreen: false,
|
|
832
|
+
preview: props2.preview,
|
|
833
|
+
htmlPreview: props2.preview ? false : props2.htmlPreview
|
|
834
|
+
});
|
|
835
|
+
const updateSetting = (v, k) => {
|
|
836
|
+
setting[k] = v;
|
|
837
|
+
if (k === "preview" && setting.preview) {
|
|
838
|
+
setting.htmlPreview = false;
|
|
839
|
+
} else if (k === "htmlPreview" && setting.htmlPreview) {
|
|
840
|
+
setting.preview = false;
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
let bodyOverflowHistory = "";
|
|
844
|
+
const adjustBody = () => {
|
|
845
|
+
if (setting.pageFullScreen || setting.fullscreen) {
|
|
846
|
+
document.body.style.overflow = "hidden";
|
|
847
|
+
} else {
|
|
848
|
+
document.body.style.overflow = bodyOverflowHistory;
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
watch(() => [setting.pageFullScreen, setting.fullscreen], adjustBody);
|
|
852
|
+
onMounted(() => {
|
|
853
|
+
if (!props2.previewOnly) {
|
|
854
|
+
bus.on(editorId, {
|
|
855
|
+
name: "uploadImage",
|
|
856
|
+
callback(files, cb) {
|
|
857
|
+
const insertHanlder = (urls) => {
|
|
858
|
+
bus.emit(editorId, "replace", "image", {
|
|
859
|
+
desc: "",
|
|
860
|
+
urls
|
|
861
|
+
});
|
|
862
|
+
cb && cb();
|
|
863
|
+
};
|
|
864
|
+
if (props2.onUploadImg) {
|
|
865
|
+
props2.onUploadImg(files, insertHanlder);
|
|
866
|
+
} else {
|
|
867
|
+
context.emit("onUploadImg", files, insertHanlder);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
bodyOverflowHistory = document.body.style.overflow;
|
|
873
|
+
adjustBody();
|
|
874
|
+
});
|
|
875
|
+
return [setting, updateSetting];
|
|
876
|
+
};
|
|
877
|
+
const useCatalog = (props2) => {
|
|
878
|
+
const { editorId } = props2;
|
|
879
|
+
const catalogVisible = ref(false);
|
|
880
|
+
onMounted(() => {
|
|
881
|
+
bus.on(editorId, {
|
|
882
|
+
name: "catalogShow",
|
|
883
|
+
callback: () => {
|
|
884
|
+
catalogVisible.value = !catalogVisible.value;
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
});
|
|
888
|
+
const catalogShow = computed(() => {
|
|
889
|
+
return !props2.toolbarsExclude.includes("catalog") && props2.toolbars.includes("catalog");
|
|
890
|
+
});
|
|
891
|
+
return [catalogVisible, catalogShow];
|
|
892
|
+
};
|
|
827
893
|
var index$1 = "";
|
|
828
894
|
var Divider = defineComponent({
|
|
829
895
|
setup() {
|
|
@@ -5344,7 +5410,7 @@ const useMarked = (props2, mermaidData) => {
|
|
|
5344
5410
|
}
|
|
5345
5411
|
return markedCode.call(renderer, code, language, isEscaped);
|
|
5346
5412
|
};
|
|
5347
|
-
renderer.image = (href, title, desc) => {
|
|
5413
|
+
renderer.image = (href, title = "", desc = "") => {
|
|
5348
5414
|
return `<span class="figure"><img src="${href}" title="${title}" alt="${desc}"><span class="figcaption">${desc}</span></span>`;
|
|
5349
5415
|
};
|
|
5350
5416
|
renderer.listitem = (text, task) => {
|
|
@@ -5729,7 +5795,7 @@ var Content = defineComponent({
|
|
|
5729
5795
|
userZoom(html);
|
|
5730
5796
|
return () => {
|
|
5731
5797
|
return createVNode(Fragment, null, [createVNode("div", {
|
|
5732
|
-
"class":
|
|
5798
|
+
"class": `${prefix}-content`
|
|
5733
5799
|
}, [!previewOnly && createVNode("div", {
|
|
5734
5800
|
"class": `${prefix}-input-wrapper`
|
|
5735
5801
|
}, [createVNode("textarea", {
|
|
@@ -6029,7 +6095,7 @@ const props = {
|
|
|
6029
6095
|
const Editor = defineComponent({
|
|
6030
6096
|
name: "MdEditorV3",
|
|
6031
6097
|
props,
|
|
6032
|
-
emits: ["onChange", "onSave", "onUploadImg", "onHtmlChanged", "onGetCatalog", "onError"],
|
|
6098
|
+
emits: ["onChange", "onSave", "onUploadImg", "onHtmlChanged", "onGetCatalog", "onError", "update:modelValue"],
|
|
6033
6099
|
setup(props2, context) {
|
|
6034
6100
|
const {
|
|
6035
6101
|
editorId
|
|
@@ -6038,79 +6104,11 @@ const Editor = defineComponent({
|
|
|
6038
6104
|
useKeyBoard(props2, context);
|
|
6039
6105
|
useProvide(props2, extension);
|
|
6040
6106
|
useExpansion(props2, extension);
|
|
6041
|
-
const
|
|
6042
|
-
|
|
6043
|
-
});
|
|
6044
|
-
const setting = reactive({
|
|
6045
|
-
pageFullScreen: props2.pageFullScreen,
|
|
6046
|
-
fullscreen: false,
|
|
6047
|
-
preview: props2.preview,
|
|
6048
|
-
htmlPreview: props2.preview ? false : props2.htmlPreview
|
|
6049
|
-
});
|
|
6050
|
-
const updateSetting = (v, k) => {
|
|
6051
|
-
setting[k] = v;
|
|
6052
|
-
if (k === "preview" && setting.preview) {
|
|
6053
|
-
setting.htmlPreview = false;
|
|
6054
|
-
} else if (k === "htmlPreview" && setting.htmlPreview) {
|
|
6055
|
-
setting.preview = false;
|
|
6056
|
-
}
|
|
6057
|
-
};
|
|
6058
|
-
let bodyOverflowHistory = "";
|
|
6059
|
-
const adjustBody = () => {
|
|
6060
|
-
if (setting.pageFullScreen || setting.fullscreen) {
|
|
6061
|
-
document.body.style.overflow = "hidden";
|
|
6062
|
-
} else {
|
|
6063
|
-
document.body.style.overflow = bodyOverflowHistory;
|
|
6064
|
-
}
|
|
6065
|
-
};
|
|
6066
|
-
watch(() => [setting.pageFullScreen, setting.fullscreen], adjustBody);
|
|
6067
|
-
onMounted(() => {
|
|
6068
|
-
if (!props2.previewOnly) {
|
|
6069
|
-
bus.on(editorId, {
|
|
6070
|
-
name: "uploadImage",
|
|
6071
|
-
callback(files, cb) {
|
|
6072
|
-
const insertHanlder = (urls) => {
|
|
6073
|
-
bus.emit(editorId, "replace", "image", {
|
|
6074
|
-
desc: "",
|
|
6075
|
-
urls
|
|
6076
|
-
});
|
|
6077
|
-
cb && cb();
|
|
6078
|
-
};
|
|
6079
|
-
if (props2.onUploadImg) {
|
|
6080
|
-
props2.onUploadImg(files, insertHanlder);
|
|
6081
|
-
} else {
|
|
6082
|
-
context.emit("onUploadImg", files, insertHanlder);
|
|
6083
|
-
}
|
|
6084
|
-
}
|
|
6085
|
-
});
|
|
6086
|
-
}
|
|
6087
|
-
bodyOverflowHistory = document.body.style.overflow;
|
|
6088
|
-
adjustBody();
|
|
6089
|
-
bus.on(editorId, {
|
|
6090
|
-
name: "catalogShow",
|
|
6091
|
-
callback: () => {
|
|
6092
|
-
state.catalogVisible = !state.catalogVisible;
|
|
6093
|
-
}
|
|
6094
|
-
});
|
|
6095
|
-
});
|
|
6107
|
+
const [setting, updateSetting] = useConfig(props2, context);
|
|
6108
|
+
const [catalogVisible, catalogShow] = useCatalog(props2);
|
|
6096
6109
|
onBeforeUnmount(() => {
|
|
6097
6110
|
bus.clear(editorId);
|
|
6098
6111
|
});
|
|
6099
|
-
const catalogShow = computed(() => {
|
|
6100
|
-
return !props2.toolbarsExclude.includes("catalog") && props2.toolbars.includes("catalog");
|
|
6101
|
-
});
|
|
6102
|
-
onMounted(() => {
|
|
6103
|
-
bus.on(editorId, {
|
|
6104
|
-
name: "errorCatcher",
|
|
6105
|
-
callback: (err) => {
|
|
6106
|
-
if (props2.onError instanceof Function) {
|
|
6107
|
-
props2.onError(err);
|
|
6108
|
-
} else {
|
|
6109
|
-
context.emit("onError", err);
|
|
6110
|
-
}
|
|
6111
|
-
}
|
|
6112
|
-
});
|
|
6113
|
-
});
|
|
6114
6112
|
return () => {
|
|
6115
6113
|
var _a;
|
|
6116
6114
|
const defToolbars = getSlot({
|
|
@@ -6163,7 +6161,7 @@ const Editor = defineComponent({
|
|
|
6163
6161
|
}, null), catalogShow.value && createVNode(MdCatalog, {
|
|
6164
6162
|
"theme": props2.theme,
|
|
6165
6163
|
"style": {
|
|
6166
|
-
display:
|
|
6164
|
+
display: catalogVisible.value ? "block" : "none"
|
|
6167
6165
|
},
|
|
6168
6166
|
"class": `${prefix}-catalog-editor`,
|
|
6169
6167
|
"editorId": editorId,
|