md-editor-v3 2.8.1 → 2.9.0-beta.1
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/README.md +3 -1
- package/lib/MdEditor/Editor.d.ts +13 -1
- package/lib/MdEditor/config.d.ts +1 -1
- package/lib/MdEditor/index.d.ts +25 -1
- package/lib/md-editor-v3.es.js +138 -69
- package/lib/md-editor-v3.umd.js +37 -37
- package/lib/style.css +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -103,7 +103,7 @@ mark and emoji extensions
|
|
|
103
103
|
| sanitize | `(html: string) => string` | (html) => html | Sanitize the html, prevent XSS |
|
|
104
104
|
| footers | `Array<'markdownTotal' \| '=' \| 'scrollSwitch' \| number>` | ['markdownTotal', '=', 'scrollSwitch'] | Show contents of footer, they are divided by `'='`. Set it to `[]` to hidden footer |
|
|
105
105
|
| scrollAuto | `boolean` | true | Scroll default setting |
|
|
106
|
-
| noIconfont | `boolean` | false | Not append iconfont script, [download](https://at.alicdn.com/t/c/
|
|
106
|
+
| noIconfont | `boolean` | false | Not append iconfont script, [download](https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js) and import it by yourself |
|
|
107
107
|
| formatCopiedText | `(text: string) => string` | (text: string) => text | Format copied code |
|
|
108
108
|
| noUploadImg | `boolean` | false | Not show the entrance to upload pictures |
|
|
109
109
|
| codeStyleReverse | `boolean` | true | Code style will be reversed to dark while code block of the theme has a dark background |
|
|
@@ -447,6 +447,8 @@ const handler = () => {
|
|
|
447
447
|
| onHtmlChanged | `html: string` | Compile markdown successful event, you can use it to get the html code |
|
|
448
448
|
| onGetCatalog | `list: Array<HeadList>` | Get catalog of article |
|
|
449
449
|
| onError | `err: { name: string; message: string }` | Catch run-time error, `Cropper`, `fullscreen` and `prettier` are used when they are not loaded |
|
|
450
|
+
| onBlur | `event: FocusEvent` | blur the `textarea` element |
|
|
451
|
+
| onFocus | `event: FocusEvent` | focus the `textarea` element |
|
|
450
452
|
|
|
451
453
|
## 💴 Config Editor
|
|
452
454
|
|
package/lib/MdEditor/Editor.d.ts
CHANGED
|
@@ -160,7 +160,13 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
160
160
|
autoDetectCode: {
|
|
161
161
|
type: import("vue").PropType<boolean>;
|
|
162
162
|
};
|
|
163
|
-
|
|
163
|
+
onBlur: {
|
|
164
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
165
|
+
};
|
|
166
|
+
onFocus: {
|
|
167
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
168
|
+
};
|
|
169
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onChange" | "onSave" | "onUploadImg" | "onHtmlChanged" | "onGetCatalog" | "onError" | "onBlur" | "onFocus" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
164
170
|
modelValue: {
|
|
165
171
|
type: import("vue").PropType<string>;
|
|
166
172
|
default: string;
|
|
@@ -322,6 +328,12 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
322
328
|
autoDetectCode: {
|
|
323
329
|
type: import("vue").PropType<boolean>;
|
|
324
330
|
};
|
|
331
|
+
onBlur: {
|
|
332
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
333
|
+
};
|
|
334
|
+
onFocus: {
|
|
335
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
336
|
+
};
|
|
325
337
|
}>>, {
|
|
326
338
|
pageFullscreen: boolean;
|
|
327
339
|
preview: boolean;
|
package/lib/MdEditor/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CodeCss, Config, ConfigOption, Footers, StaticTextDefault } from './type';
|
|
2
2
|
export declare const prefix = "md-editor";
|
|
3
3
|
export declare const defaultEditorId = "md-editor-v3";
|
|
4
|
-
export declare const iconfontUrl = "https://at.alicdn.com/t/c/
|
|
4
|
+
export declare const iconfontUrl = "https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js";
|
|
5
5
|
export declare const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
|
|
6
6
|
export declare const highlightUrl: string;
|
|
7
7
|
export declare const prettierUrl: {
|
package/lib/MdEditor/index.d.ts
CHANGED
|
@@ -200,6 +200,12 @@ declare const _default: {
|
|
|
200
200
|
autoDetectCode: {
|
|
201
201
|
type: import("vue").PropType<boolean>;
|
|
202
202
|
};
|
|
203
|
+
onBlur: {
|
|
204
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
205
|
+
};
|
|
206
|
+
onFocus: {
|
|
207
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
208
|
+
};
|
|
203
209
|
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "pageFullscreen" | "preview" | "htmlPreview" | "modelValue" | "theme" | "class" | "historyLength" | "previewOnly" | "language" | "toolbars" | "toolbarsExclude" | "noPrettier" | "editorId" | "tabWidth" | "showCodeRowNumber" | "previewTheme" | "style" | "markedHeadingId" | "tableShape" | "noMermaid" | "sanitize" | "placeholder" | "noKatex" | "codeTheme" | "footers" | "scrollAuto" | "formatCopiedText" | "codeStyleReverse" | "codeStyleReverseList">;
|
|
204
210
|
$attrs: {
|
|
205
211
|
[x: string]: unknown;
|
|
@@ -376,6 +382,12 @@ declare const _default: {
|
|
|
376
382
|
autoDetectCode: {
|
|
377
383
|
type: import("vue").PropType<boolean>;
|
|
378
384
|
};
|
|
385
|
+
onBlur: {
|
|
386
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
387
|
+
};
|
|
388
|
+
onFocus: {
|
|
389
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
390
|
+
};
|
|
379
391
|
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, {
|
|
380
392
|
pageFullscreen: boolean;
|
|
381
393
|
preview: boolean;
|
|
@@ -588,6 +600,12 @@ declare const _default: {
|
|
|
588
600
|
autoDetectCode: {
|
|
589
601
|
type: import("vue").PropType<boolean>;
|
|
590
602
|
};
|
|
603
|
+
onBlur: {
|
|
604
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
605
|
+
};
|
|
606
|
+
onFocus: {
|
|
607
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
608
|
+
};
|
|
591
609
|
}>> & import("vue").ShallowUnwrapRef<() => JSX.Element> & {} & {} & import("vue").ComponentCustomProperties;
|
|
592
610
|
__isFragment?: undefined;
|
|
593
611
|
__isTeleport?: undefined;
|
|
@@ -754,7 +772,13 @@ declare const _default: {
|
|
|
754
772
|
autoDetectCode: {
|
|
755
773
|
type: import("vue").PropType<boolean>;
|
|
756
774
|
};
|
|
757
|
-
|
|
775
|
+
onBlur: {
|
|
776
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
777
|
+
};
|
|
778
|
+
onFocus: {
|
|
779
|
+
type: import("vue").PropType<(event: FocusEvent) => void>;
|
|
780
|
+
};
|
|
781
|
+
}>>, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "onChange" | "onSave" | "onUploadImg" | "onHtmlChanged" | "onGetCatalog" | "onError" | "onBlur" | "onFocus" | "update:modelValue", {
|
|
758
782
|
pageFullscreen: boolean;
|
|
759
783
|
preview: boolean;
|
|
760
784
|
htmlPreview: boolean;
|
package/lib/md-editor-v3.es.js
CHANGED
|
@@ -20,7 +20,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
20
20
|
import { reactive, watch, onMounted, onBeforeUnmount, provide, computed, ref, defineComponent, createVNode, cloneVNode, nextTick, inject, Fragment, toRef, mergeProps, isVNode } from "vue";
|
|
21
21
|
const prefix = "md-editor";
|
|
22
22
|
const defaultEditorId = "md-editor-v3";
|
|
23
|
-
const iconfontUrl = "https://at.alicdn.com/t/c/
|
|
23
|
+
const iconfontUrl = "https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js";
|
|
24
24
|
const cdnBase = "https://cdnjs.cloudflare.com/ajax/libs";
|
|
25
25
|
const highlightUrl = `${cdnBase}/highlight.js/11.7.0/highlight.min.js`;
|
|
26
26
|
const prettierUrl = {
|
|
@@ -870,10 +870,10 @@ const useExpansion = (props) => {
|
|
|
870
870
|
const cropperScript = document.createElement("script");
|
|
871
871
|
cropperScript.src = ((_d2 = editorExtensions == null ? void 0 : editorExtensions.cropper) == null ? void 0 : _d2.js) || cropperUrl.js;
|
|
872
872
|
cropperScript.id = `${prefix}-cropper`;
|
|
873
|
+
if (!noIconfont) {
|
|
874
|
+
appendHandler(iconfontScript);
|
|
875
|
+
}
|
|
873
876
|
if (!previewOnly) {
|
|
874
|
-
if (!noIconfont) {
|
|
875
|
-
appendHandler(iconfontScript);
|
|
876
|
-
}
|
|
877
877
|
if (!noCropperScript) {
|
|
878
878
|
appendHandler(cropperLink);
|
|
879
879
|
appendHandler(cropperScript);
|
|
@@ -5459,10 +5459,10 @@ var kaTexExtensions = {
|
|
|
5459
5459
|
level: "block",
|
|
5460
5460
|
start: (text) => {
|
|
5461
5461
|
var _a;
|
|
5462
|
-
return (_a = text.match(/\n
|
|
5462
|
+
return (_a = text.match(/\n\$\$/)) == null ? void 0 : _a.index;
|
|
5463
5463
|
},
|
|
5464
5464
|
tokenizer(text) {
|
|
5465
|
-
if (
|
|
5465
|
+
if (/^\$\$/.test(text) && text.split("$$").length > 2) {
|
|
5466
5466
|
const match = splitKatexValue(text, "$$");
|
|
5467
5467
|
return {
|
|
5468
5468
|
type: "KaTexBlockExtension",
|
|
@@ -5697,7 +5697,38 @@ const useHistory = (props, textAreaRef, completeStatus) => {
|
|
|
5697
5697
|
});
|
|
5698
5698
|
});
|
|
5699
5699
|
};
|
|
5700
|
-
const
|
|
5700
|
+
const useKatex = (props, marked2) => {
|
|
5701
|
+
var _a;
|
|
5702
|
+
const katexConf = (_a = configOption.editorExtensions) == null ? void 0 : _a.katex;
|
|
5703
|
+
const katexIns = katexConf == null ? void 0 : katexConf.instance;
|
|
5704
|
+
const katexInited = ref(false);
|
|
5705
|
+
if (!props.noKatex) {
|
|
5706
|
+
marked2.use({
|
|
5707
|
+
extensions: [
|
|
5708
|
+
kaTexExtensions.inline(prefix, katexIns),
|
|
5709
|
+
kaTexExtensions.block(prefix, katexIns)
|
|
5710
|
+
]
|
|
5711
|
+
});
|
|
5712
|
+
}
|
|
5713
|
+
onMounted(() => {
|
|
5714
|
+
if (!props.noKatex && !katexIns) {
|
|
5715
|
+
const katexScript = document.createElement("script");
|
|
5716
|
+
katexScript.src = (katexConf == null ? void 0 : katexConf.js) || katexUrl.js;
|
|
5717
|
+
katexScript.onload = () => {
|
|
5718
|
+
katexInited.value = true;
|
|
5719
|
+
};
|
|
5720
|
+
katexScript.id = `${prefix}-katex`;
|
|
5721
|
+
const katexLink = document.createElement("link");
|
|
5722
|
+
katexLink.rel = "stylesheet";
|
|
5723
|
+
katexLink.href = (katexConf == null ? void 0 : katexConf.css) || katexUrl.css;
|
|
5724
|
+
katexLink.id = `${prefix}-katexCss`;
|
|
5725
|
+
appendHandler(katexScript, "katex");
|
|
5726
|
+
appendHandler(katexLink);
|
|
5727
|
+
}
|
|
5728
|
+
});
|
|
5729
|
+
return katexInited;
|
|
5730
|
+
};
|
|
5731
|
+
const useMarked = (props) => {
|
|
5701
5732
|
var _a, _b, _c;
|
|
5702
5733
|
const {
|
|
5703
5734
|
markedRenderer,
|
|
@@ -5715,12 +5746,20 @@ const useMarked = (props, mermaidData) => {
|
|
|
5715
5746
|
const katexIns = (_c = editorExtensions == null ? void 0 : editorExtensions.katex) == null ? void 0 : _c.instance;
|
|
5716
5747
|
const katexConf = editorExtensions == null ? void 0 : editorExtensions.katex;
|
|
5717
5748
|
const highlightInited = ref(false);
|
|
5718
|
-
const katexInited = ref(false);
|
|
5719
5749
|
const heads = ref([]);
|
|
5720
5750
|
let renderer = new marked.Renderer();
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
}
|
|
5751
|
+
renderer.image = (href, title, desc) => {
|
|
5752
|
+
return `<span class="figure"><img src="${href}" title="${title || ""}" alt="${desc || ""}" zoom><span class="figcaption">${desc || ""}</span></span>`;
|
|
5753
|
+
};
|
|
5754
|
+
renderer.listitem = (text, task) => {
|
|
5755
|
+
if (task) {
|
|
5756
|
+
return `<li class="li-task">${text}</li>`;
|
|
5757
|
+
}
|
|
5758
|
+
return `<li>${text}</li>`;
|
|
5759
|
+
};
|
|
5760
|
+
if (markedRenderer instanceof Function) {
|
|
5761
|
+
renderer = markedRenderer(renderer);
|
|
5762
|
+
}
|
|
5724
5763
|
const markedCode = renderer.code;
|
|
5725
5764
|
renderer.code = (code, language, isEscaped) => {
|
|
5726
5765
|
if (!props.noMermaid && language === "mermaid") {
|
|
@@ -5739,23 +5778,10 @@ const useMarked = (props, mermaidData) => {
|
|
|
5739
5778
|
return `<p class="${prefix}-mermaid-error">Error: ${(error == null ? void 0 : error.message) || ""}</p>`;
|
|
5740
5779
|
}
|
|
5741
5780
|
}
|
|
5742
|
-
return markedCode.call(renderer, code, language, isEscaped);
|
|
5743
|
-
};
|
|
5744
|
-
renderer.image = (href, title, desc) => {
|
|
5745
|
-
return `<span class="figure"><img src="${href}" title="${title || ""}" alt="${desc || ""}" zoom><span class="figcaption">${desc || ""}</span></span>`;
|
|
5746
|
-
};
|
|
5747
|
-
renderer.listitem = (text, task) => {
|
|
5748
|
-
if (task) {
|
|
5749
|
-
return `<li class="li-task">${text}</li>`;
|
|
5750
|
-
}
|
|
5751
|
-
return `<li>${text}</li>`;
|
|
5781
|
+
return markedCode.call(renderer, code, language, isEscaped).replace(/^<pre><code\sclass="language-([^>]*)">/, '<pre><code class="language-$1" language="$1">');
|
|
5752
5782
|
};
|
|
5753
|
-
const markedheading = renderer.heading;
|
|
5754
|
-
if (markedRenderer instanceof Function) {
|
|
5755
|
-
renderer = markedRenderer(renderer);
|
|
5756
|
-
}
|
|
5757
5783
|
const newHeading = renderer.heading;
|
|
5758
|
-
const isNewHeading =
|
|
5784
|
+
const isNewHeading = newHeading !== new marked.Renderer().heading;
|
|
5759
5785
|
renderer.heading = (text, level, raw, slugger) => {
|
|
5760
5786
|
heads.value.push({ text: raw, level });
|
|
5761
5787
|
const id = props.markedHeadingId(raw, level, heads.value.length);
|
|
@@ -5768,17 +5794,34 @@ const useMarked = (props, mermaidData) => {
|
|
|
5768
5794
|
return `<h${level} id="${id}"><a href="#${id}">${raw}</a></h${level}>`;
|
|
5769
5795
|
}
|
|
5770
5796
|
};
|
|
5797
|
+
if (highlightIns) {
|
|
5798
|
+
marked.setOptions({
|
|
5799
|
+
highlight: (code, language) => {
|
|
5800
|
+
let codeHtml;
|
|
5801
|
+
const hljsLang = highlightIns.getLanguage(language);
|
|
5802
|
+
if (language && hljsLang) {
|
|
5803
|
+
codeHtml = highlightIns.highlight(code, {
|
|
5804
|
+
language,
|
|
5805
|
+
ignoreIllegals: true
|
|
5806
|
+
}).value;
|
|
5807
|
+
} else {
|
|
5808
|
+
codeHtml = highlightIns.highlightAuto(code).value;
|
|
5809
|
+
}
|
|
5810
|
+
return showCodeRowNumber ? generateCodeRowNumber(codeHtml) : `<span class="code-block">${codeHtml}</span>`;
|
|
5811
|
+
}
|
|
5812
|
+
});
|
|
5813
|
+
}
|
|
5771
5814
|
marked.setOptions(__spreadValues({
|
|
5772
5815
|
breaks: true
|
|
5773
5816
|
}, markedOptions));
|
|
5774
|
-
if (
|
|
5817
|
+
if (markedExtensions instanceof Array && markedExtensions.length > 0) {
|
|
5775
5818
|
marked.use({
|
|
5776
|
-
extensions:
|
|
5777
|
-
kaTexExtensions.inline(prefix, katexIns),
|
|
5778
|
-
kaTexExtensions.block(prefix, katexIns)
|
|
5779
|
-
]
|
|
5819
|
+
extensions: markedExtensions
|
|
5780
5820
|
});
|
|
5781
5821
|
}
|
|
5822
|
+
marked.use({
|
|
5823
|
+
extensions: [Alert]
|
|
5824
|
+
});
|
|
5782
5825
|
if (highlightIns) {
|
|
5783
5826
|
marked.setOptions({
|
|
5784
5827
|
highlight: (code, language) => {
|
|
@@ -5796,18 +5839,14 @@ const useMarked = (props, mermaidData) => {
|
|
|
5796
5839
|
}
|
|
5797
5840
|
});
|
|
5798
5841
|
}
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
extensions: markedExtensions
|
|
5802
|
-
});
|
|
5803
|
-
}
|
|
5842
|
+
const katexInited = useKatex(props, marked);
|
|
5843
|
+
const mermaidData = useMermaid(props);
|
|
5804
5844
|
const html = ref(props.sanitize(marked(props.value || "", { renderer })));
|
|
5805
5845
|
const markHtml = debounce(() => {
|
|
5806
5846
|
heads.value = [];
|
|
5807
|
-
|
|
5808
|
-
html.value
|
|
5809
|
-
|
|
5810
|
-
props.onHtmlChanged(_html);
|
|
5847
|
+
html.value = props.sanitize(marked(props.value || "", { renderer }));
|
|
5848
|
+
bus.emit(editorId, "buildFinished", html.value);
|
|
5849
|
+
props.onHtmlChanged(html.value);
|
|
5811
5850
|
}, (editorConfig == null ? void 0 : editorConfig.renderDelay) !== void 0 ? editorConfig == null ? void 0 : editorConfig.renderDelay : previewOnly ? 0 : 500);
|
|
5812
5851
|
watch([
|
|
5813
5852
|
highlightInited,
|
|
@@ -5877,9 +5916,7 @@ const useMarked = (props, mermaidData) => {
|
|
|
5877
5916
|
}
|
|
5878
5917
|
});
|
|
5879
5918
|
});
|
|
5880
|
-
return
|
|
5881
|
-
html
|
|
5882
|
-
};
|
|
5919
|
+
return html;
|
|
5883
5920
|
};
|
|
5884
5921
|
const useAutoScroll = (props, html, textAreaRef, previewRef, htmlRef) => {
|
|
5885
5922
|
const previewOnly = inject("previewOnly");
|
|
@@ -5892,20 +5929,23 @@ const useAutoScroll = (props, html, textAreaRef, previewRef, htmlRef) => {
|
|
|
5892
5929
|
const initCopyEntry = () => {
|
|
5893
5930
|
document.querySelectorAll(`#${editorId}-preview pre`).forEach((pre) => {
|
|
5894
5931
|
var _a, _b;
|
|
5932
|
+
let clearTimer = -1;
|
|
5895
5933
|
(_a = pre.querySelector(".copy-button")) == null ? void 0 : _a.remove();
|
|
5896
5934
|
const copyBtnText = ((_b = ult.value.copyCode) == null ? void 0 : _b.text) || "\u590D\u5236\u4EE3\u7801";
|
|
5897
5935
|
const copyButton = document.createElement("span");
|
|
5898
5936
|
copyButton.setAttribute("class", "copy-button");
|
|
5899
|
-
copyButton.
|
|
5937
|
+
copyButton.dataset.tips = copyBtnText;
|
|
5938
|
+
copyButton.innerHTML = `<svg class="${prefix}-icon" aria-hidden="true"><use xlink:href="#${prefix}-icon-copy"></use></svg>`;
|
|
5900
5939
|
copyButton.addEventListener("click", () => {
|
|
5901
5940
|
var _a2, _b2;
|
|
5941
|
+
clearTimeout(clearTimer);
|
|
5902
5942
|
const codeText = pre.querySelector("code").innerText;
|
|
5903
5943
|
const success = copyToClipboard(props.formatCopiedText(codeText));
|
|
5904
5944
|
const succssTip = ((_a2 = ult.value.copyCode) == null ? void 0 : _a2.successTips) || "\u5DF2\u590D\u5236\uFF01";
|
|
5905
5945
|
const failTip = ((_b2 = ult.value.copyCode) == null ? void 0 : _b2.failTips) || "\u5DF2\u590D\u5236\uFF01";
|
|
5906
|
-
copyButton.
|
|
5907
|
-
setTimeout(() => {
|
|
5908
|
-
copyButton.
|
|
5946
|
+
copyButton.dataset.tips = success ? succssTip : failTip;
|
|
5947
|
+
clearTimer = window.setTimeout(() => {
|
|
5948
|
+
copyButton.dataset.tips = copyBtnText;
|
|
5909
5949
|
}, 1500);
|
|
5910
5950
|
});
|
|
5911
5951
|
pre.appendChild(copyButton);
|
|
@@ -6177,6 +6217,16 @@ const contentProps = () => ({
|
|
|
6177
6217
|
},
|
|
6178
6218
|
autoDetectCode: {
|
|
6179
6219
|
type: Boolean
|
|
6220
|
+
},
|
|
6221
|
+
onBlur: {
|
|
6222
|
+
type: Function,
|
|
6223
|
+
default: () => {
|
|
6224
|
+
}
|
|
6225
|
+
},
|
|
6226
|
+
onFocus: {
|
|
6227
|
+
type: Function,
|
|
6228
|
+
default: () => {
|
|
6229
|
+
}
|
|
6180
6230
|
}
|
|
6181
6231
|
});
|
|
6182
6232
|
var Content = defineComponent({
|
|
@@ -6191,10 +6241,7 @@ var Content = defineComponent({
|
|
|
6191
6241
|
const textAreaRef = ref();
|
|
6192
6242
|
const previewRef = ref();
|
|
6193
6243
|
const htmlRef = ref();
|
|
6194
|
-
const
|
|
6195
|
-
const {
|
|
6196
|
-
html
|
|
6197
|
-
} = useMarked(props, mermaidData);
|
|
6244
|
+
const html = useMarked(props);
|
|
6198
6245
|
useAutoScroll(props, html, textAreaRef, previewRef, htmlRef);
|
|
6199
6246
|
useAutoGenrator(props, textAreaRef);
|
|
6200
6247
|
useHistory(props, textAreaRef, completeStatus);
|
|
@@ -6202,17 +6249,20 @@ var Content = defineComponent({
|
|
|
6202
6249
|
userZoom(props, html);
|
|
6203
6250
|
useAttach(textAreaRef);
|
|
6204
6251
|
return () => {
|
|
6205
|
-
const attrs = omit(props, ["formatCopiedText", "markedHeadingId", "noKatex", "noMermaid", "onChange", "onGetCatalog", "onHtmlChanged", "sanitize", "scrollAuto", "setting", "autoDetectCode"]);
|
|
6252
|
+
const attrs = omit(props, ["formatCopiedText", "markedHeadingId", "noKatex", "noMermaid", "onChange", "onGetCatalog", "onHtmlChanged", "sanitize", "scrollAuto", "setting", "autoDetectCode", "onBlur", "onFocus"]);
|
|
6206
6253
|
return createVNode(Fragment, null, [createVNode("div", {
|
|
6207
6254
|
"class": `${prefix}-content`
|
|
6208
6255
|
}, [!previewOnly && createVNode("div", {
|
|
6209
6256
|
"class": `${prefix}-input-wrapper`
|
|
6210
6257
|
}, [createVNode("textarea", mergeProps(attrs, {
|
|
6211
6258
|
"id": `${editorId}-textarea`,
|
|
6259
|
+
"class": [props.setting.preview || props.setting.htmlPreview ? "" : "textarea-only"],
|
|
6212
6260
|
"ref": textAreaRef,
|
|
6213
|
-
"onBlur": () => {
|
|
6261
|
+
"onBlur": (e) => {
|
|
6214
6262
|
bus.emit(editorId, "selectTextChange");
|
|
6263
|
+
props.onBlur(e);
|
|
6215
6264
|
},
|
|
6265
|
+
"onFocus": props.onFocus,
|
|
6216
6266
|
"onKeydown": () => {
|
|
6217
6267
|
bus.emit(editorId, "saveHistoryPos", true);
|
|
6218
6268
|
},
|
|
@@ -6224,8 +6274,7 @@ var Content = defineComponent({
|
|
|
6224
6274
|
},
|
|
6225
6275
|
"onCompositionend": () => {
|
|
6226
6276
|
completeStatus.value = true;
|
|
6227
|
-
}
|
|
6228
|
-
"class": [props.setting.preview || props.setting.htmlPreview ? "" : "textarea-only"]
|
|
6277
|
+
}
|
|
6229
6278
|
}), null)]), props.setting.preview && createVNode("div", {
|
|
6230
6279
|
"id": `${editorId}-preview-wrapper`,
|
|
6231
6280
|
"class": `${prefix}-preview-wrapper`,
|
|
@@ -6786,6 +6835,12 @@ const editorProps = () => ({
|
|
|
6786
6835
|
},
|
|
6787
6836
|
autoDetectCode: {
|
|
6788
6837
|
type: Boolean
|
|
6838
|
+
},
|
|
6839
|
+
onBlur: {
|
|
6840
|
+
type: Function
|
|
6841
|
+
},
|
|
6842
|
+
onFocus: {
|
|
6843
|
+
type: Function
|
|
6789
6844
|
}
|
|
6790
6845
|
});
|
|
6791
6846
|
const markedHeadingId = (text) => text;
|
|
@@ -6794,7 +6849,7 @@ var all = "";
|
|
|
6794
6849
|
const Editor = defineComponent({
|
|
6795
6850
|
name: "MdEditorV3",
|
|
6796
6851
|
props: editorProps(),
|
|
6797
|
-
emits: ["onChange", "onSave", "onUploadImg", "onHtmlChanged", "onGetCatalog", "onError", "update:modelValue"],
|
|
6852
|
+
emits: ["onChange", "onSave", "onUploadImg", "onHtmlChanged", "onGetCatalog", "onError", "update:modelValue", "onBlur", "onFocus"],
|
|
6798
6853
|
setup(props, context) {
|
|
6799
6854
|
const {
|
|
6800
6855
|
editorId,
|
|
@@ -6841,6 +6896,19 @@ const Editor = defineComponent({
|
|
|
6841
6896
|
"noUploadImg": noUploadImg
|
|
6842
6897
|
}, null), createVNode(Content, {
|
|
6843
6898
|
"value": props.modelValue,
|
|
6899
|
+
"setting": setting,
|
|
6900
|
+
"markedHeadingId": props.markedHeadingId,
|
|
6901
|
+
"noMermaid": noMermaid,
|
|
6902
|
+
"sanitize": props.sanitize,
|
|
6903
|
+
"placeholder": props.placeholder,
|
|
6904
|
+
"noKatex": noKatex,
|
|
6905
|
+
"scrollAuto": state.scrollAuto,
|
|
6906
|
+
"formatCopiedText": props.formatCopiedText,
|
|
6907
|
+
"autofocus": props.autoFocus,
|
|
6908
|
+
"disabled": props.disabled,
|
|
6909
|
+
"readonly": props.readOnly,
|
|
6910
|
+
"maxlength": props.maxLength,
|
|
6911
|
+
"autoDetectCode": props.autoDetectCode,
|
|
6844
6912
|
"onChange": (value) => {
|
|
6845
6913
|
bus.emit(editorId, "saveHistoryPos");
|
|
6846
6914
|
if (props.onChange) {
|
|
@@ -6850,7 +6918,6 @@ const Editor = defineComponent({
|
|
|
6850
6918
|
context.emit("onChange", value);
|
|
6851
6919
|
}
|
|
6852
6920
|
},
|
|
6853
|
-
"setting": setting,
|
|
6854
6921
|
"onHtmlChanged": (html) => {
|
|
6855
6922
|
if (props.onHtmlChanged) {
|
|
6856
6923
|
props.onHtmlChanged(html);
|
|
@@ -6865,18 +6932,20 @@ const Editor = defineComponent({
|
|
|
6865
6932
|
context.emit("onGetCatalog", list);
|
|
6866
6933
|
}
|
|
6867
6934
|
},
|
|
6868
|
-
"
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
"
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6935
|
+
"onBlur": (e) => {
|
|
6936
|
+
if (props.onBlur) {
|
|
6937
|
+
props.onBlur(e);
|
|
6938
|
+
} else {
|
|
6939
|
+
context.emit("onBlur", e);
|
|
6940
|
+
}
|
|
6941
|
+
},
|
|
6942
|
+
"onFocus": (e) => {
|
|
6943
|
+
if (props.onFocus) {
|
|
6944
|
+
props.onFocus(e);
|
|
6945
|
+
} else {
|
|
6946
|
+
context.emit("onFocus", e);
|
|
6947
|
+
}
|
|
6948
|
+
}
|
|
6880
6949
|
}, null), !previewOnly && ((_a = props.footers) == null ? void 0 : _a.length) > 0 && createVNode(Footer, {
|
|
6881
6950
|
"modelValue": props.modelValue,
|
|
6882
6951
|
"footers": props.footers,
|