md-editor-v3 2.0.0-beta.6 → 2.0.0-beta.9
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 +33 -16
- package/lib/MdEditor/Editor.d.ts +3 -3
- package/lib/MdEditor/index.d.ts +8 -8
- package/lib/MdEditor/type.d.ts +6 -1
- package/lib/md-editor-v3.es.js +85 -65
- package/lib/md-editor-v3.umd.js +31 -31
- package/lib/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ mark and emoji extensions
|
|
|
62
62
|
| noMermaid | boolean | false | Use mermaid or not |
|
|
63
63
|
| placeholder | string | '' | |
|
|
64
64
|
| noKatex | boolean | false | Use katex or not |
|
|
65
|
-
|
|
|
65
|
+
| codeTheme | 'atom' \| 'a11y' \| 'github' \| 'gradient' \| 'kimbie' \| 'paraiso' \| 'qtcreator' \| 'stackoverflow' | 'atom' | [Highlight](https://www.jsdelivr.com/package/npm/highlight.js?path=styles) code style, can be customized also |
|
|
66
66
|
| markedHeadingId | (text: string, level: number) => string | (text) => text | H1-H6 `ID` generator |
|
|
67
67
|
| sanitize | (html: string) => string | (html) => html | Sanitize the html, prevent XSS |
|
|
68
68
|
|
|
@@ -183,7 +183,8 @@ export interface StaticTextDefaultValue {
|
|
|
183
183
|
// Copy code tips, v1.1.4
|
|
184
184
|
copyCode?: {
|
|
185
185
|
text?: string;
|
|
186
|
-
|
|
186
|
+
successTips?: string;
|
|
187
|
+
failTips?: string;
|
|
187
188
|
};
|
|
188
189
|
// 1.8.0
|
|
189
190
|
mermaid?: {
|
|
@@ -216,7 +217,7 @@ export interface StaticTextDefaultValue {
|
|
|
216
217
|
|
|
217
218
|
`NormalToolbar` component example:
|
|
218
219
|
|
|
219
|
-
```
|
|
220
|
+
```vue
|
|
220
221
|
<template>
|
|
221
222
|
<md-editor>
|
|
222
223
|
<template #defToolbars>
|
|
@@ -230,12 +231,15 @@ export interface StaticTextDefaultValue {
|
|
|
230
231
|
</template>
|
|
231
232
|
</md-editor>
|
|
232
233
|
</template>
|
|
234
|
+
|
|
233
235
|
<script setup>
|
|
234
236
|
import MdEditor from 'md-editor-v3';
|
|
235
237
|
|
|
236
238
|
const NormalToolbar = MdEditor.NormalToolbar;
|
|
237
239
|
|
|
238
|
-
const handler = () => {
|
|
240
|
+
const handler = () => {
|
|
241
|
+
console.log('NormalToolbar clicked!');
|
|
242
|
+
};
|
|
239
243
|
</script>
|
|
240
244
|
```
|
|
241
245
|
|
|
@@ -248,6 +252,7 @@ const handler = () => { console.log('NormalToolbar clicked!') }
|
|
|
248
252
|
| onUploadImg | files:Array<File>, callback:Function | Upload picture event, when picture is uploading the modal will not close, please provide right urls to the callback function |
|
|
249
253
|
| onHtmlChanged | h:string | Compile markdown successful event, you can use it to get the html code |
|
|
250
254
|
| onGetCatalog | list: HeadList[] | Get catalog of article |
|
|
255
|
+
| onError | err: { name: string; message: string } | Catch run-time error, `Cropper`,`fullScreen` and `prettier` are used when they are not loaded |
|
|
251
256
|
|
|
252
257
|
## Config
|
|
253
258
|
|
|
@@ -299,12 +304,14 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
299
304
|
import MdEditor from 'md-editor-v3';
|
|
300
305
|
|
|
301
306
|
MdEditor.config({
|
|
302
|
-
|
|
303
|
-
languageUserDefined: {
|
|
307
|
+
editorConfig: {
|
|
308
|
+
languageUserDefined: { lang: StaticTextDefaultValue },
|
|
304
309
|
mermaidTemplate: {
|
|
305
|
-
flow: `flow tempalte
|
|
310
|
+
flow: `flow tempalte`,
|
|
306
311
|
...more
|
|
307
|
-
}
|
|
312
|
+
},
|
|
313
|
+
// ms
|
|
314
|
+
renderDelay: 500
|
|
308
315
|
}
|
|
309
316
|
});
|
|
310
317
|
```
|
|
@@ -491,9 +498,9 @@ export default defineComponent({
|
|
|
491
498
|
|
|
492
499
|
### Vue template
|
|
493
500
|
|
|
494
|
-
```
|
|
501
|
+
```vue
|
|
495
502
|
<template>
|
|
496
|
-
<md-editor v-model="text"
|
|
503
|
+
<md-editor v-model="text" preview-only />
|
|
497
504
|
</template>
|
|
498
505
|
|
|
499
506
|
<script setup>
|
|
@@ -501,7 +508,7 @@ import { ref } from 'vue';
|
|
|
501
508
|
import MdEditor from 'md-editor-v3';
|
|
502
509
|
import 'md-editor-v3/lib/style.css';
|
|
503
510
|
|
|
504
|
-
const text = ref('# Hello Editor')
|
|
511
|
+
const text = ref('# Hello Editor');
|
|
505
512
|
</script>
|
|
506
513
|
```
|
|
507
514
|
|
|
@@ -509,8 +516,18 @@ const text = ref('# Hello Editor')
|
|
|
509
516
|
|
|
510
517
|
> Tips:When you paste and upload GIF, it will upload a static picture. So you should upload it by file system!
|
|
511
518
|
|
|
512
|
-
|
|
513
|
-
|
|
519
|
+
<template>
|
|
520
|
+
<md-editor v-model="text" @onUploadImg="onUploadImg" />
|
|
521
|
+
</template>
|
|
522
|
+
|
|
523
|
+
<script setup>
|
|
524
|
+
import { ref } from 'vue';
|
|
525
|
+
import MdEditor from 'md-editor-v3';
|
|
526
|
+
import 'md-editor-v3/lib/style.css';
|
|
527
|
+
|
|
528
|
+
const text = ref('# Hello Editor');
|
|
529
|
+
|
|
530
|
+
const onUploadImg = async (files, callback) => {
|
|
514
531
|
const res = await Promise.all(
|
|
515
532
|
files.map((file) => {
|
|
516
533
|
return new Promise((rev, rej) => {
|
|
@@ -529,6 +546,6 @@ async onUploadImg(files: Array<File>, callback: (urls: string[]) => void) {
|
|
|
529
546
|
})
|
|
530
547
|
);
|
|
531
548
|
|
|
532
|
-
callback(res.map((item
|
|
533
|
-
}
|
|
534
|
-
|
|
549
|
+
callback(res.map((item) => item.data.url));
|
|
550
|
+
};
|
|
551
|
+
</script>
|
package/lib/MdEditor/Editor.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
115
115
|
onError: {
|
|
116
116
|
type: PropType<(err: InnerError) => void>;
|
|
117
117
|
};
|
|
118
|
-
|
|
118
|
+
codeTheme: {
|
|
119
119
|
type: PropType<string>;
|
|
120
120
|
default: string;
|
|
121
121
|
};
|
|
@@ -233,7 +233,7 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
233
233
|
onError: {
|
|
234
234
|
type: PropType<(err: InnerError) => void>;
|
|
235
235
|
};
|
|
236
|
-
|
|
236
|
+
codeTheme: {
|
|
237
237
|
type: PropType<string>;
|
|
238
238
|
default: string;
|
|
239
239
|
};
|
|
@@ -261,6 +261,6 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
261
261
|
sanitize: (html: string) => string;
|
|
262
262
|
placeholder: string;
|
|
263
263
|
noKatex: boolean;
|
|
264
|
-
|
|
264
|
+
codeTheme: string;
|
|
265
265
|
}>;
|
|
266
266
|
export default Editor;
|
package/lib/MdEditor/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare const _default: {
|
|
|
32
32
|
sanitize: (html: string) => string;
|
|
33
33
|
placeholder: string;
|
|
34
34
|
noKatex: boolean;
|
|
35
|
-
|
|
35
|
+
codeTheme: string;
|
|
36
36
|
}> & Omit<Readonly<import("vue").ExtractPropTypes<{
|
|
37
37
|
modelValue: {
|
|
38
38
|
type: import("vue").PropType<string>;
|
|
@@ -147,11 +147,11 @@ declare const _default: {
|
|
|
147
147
|
onError: {
|
|
148
148
|
type: import("vue").PropType<(err: import("./type").InnerError) => void>;
|
|
149
149
|
};
|
|
150
|
-
|
|
150
|
+
codeTheme: {
|
|
151
151
|
type: import("vue").PropType<string>;
|
|
152
152
|
default: string;
|
|
153
153
|
};
|
|
154
|
-
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "editorId" | "preview" | "htmlPreview" | "tabWidth" | "theme" | "historyLength" | "previewOnly" | "showCodeRowNumber" | "previewTheme" | "noPrettier" | "style" | "class" | "modelValue" | "pageFullScreen" | "language" | "toolbars" | "toolbarsExclude" | "markedHeadingId" | "tableShape" | "noMermaid" | "sanitize" | "placeholder" | "noKatex" | "
|
|
154
|
+
}>> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "editorId" | "preview" | "htmlPreview" | "tabWidth" | "theme" | "historyLength" | "previewOnly" | "showCodeRowNumber" | "previewTheme" | "noPrettier" | "style" | "class" | "modelValue" | "pageFullScreen" | "language" | "toolbars" | "toolbarsExclude" | "markedHeadingId" | "tableShape" | "noMermaid" | "sanitize" | "placeholder" | "noKatex" | "codeTheme">;
|
|
155
155
|
$attrs: {
|
|
156
156
|
[x: string]: unknown;
|
|
157
157
|
};
|
|
@@ -279,7 +279,7 @@ declare const _default: {
|
|
|
279
279
|
onError: {
|
|
280
280
|
type: import("vue").PropType<(err: import("./type").InnerError) => void>;
|
|
281
281
|
};
|
|
282
|
-
|
|
282
|
+
codeTheme: {
|
|
283
283
|
type: import("vue").PropType<string>;
|
|
284
284
|
default: string;
|
|
285
285
|
};
|
|
@@ -307,7 +307,7 @@ declare const _default: {
|
|
|
307
307
|
sanitize: (html: string) => string;
|
|
308
308
|
placeholder: string;
|
|
309
309
|
noKatex: boolean;
|
|
310
|
-
|
|
310
|
+
codeTheme: string;
|
|
311
311
|
}> & {
|
|
312
312
|
beforeCreate?: ((() => void) | (() => void)[]) | undefined;
|
|
313
313
|
created?: ((() => void) | (() => void)[]) | undefined;
|
|
@@ -442,7 +442,7 @@ declare const _default: {
|
|
|
442
442
|
onError: {
|
|
443
443
|
type: import("vue").PropType<(err: import("./type").InnerError) => void>;
|
|
444
444
|
};
|
|
445
|
-
|
|
445
|
+
codeTheme: {
|
|
446
446
|
type: import("vue").PropType<string>;
|
|
447
447
|
default: string;
|
|
448
448
|
};
|
|
@@ -564,7 +564,7 @@ declare const _default: {
|
|
|
564
564
|
onError: {
|
|
565
565
|
type: import("vue").PropType<(err: import("./type").InnerError) => void>;
|
|
566
566
|
};
|
|
567
|
-
|
|
567
|
+
codeTheme: {
|
|
568
568
|
type: import("vue").PropType<string>;
|
|
569
569
|
default: string;
|
|
570
570
|
};
|
|
@@ -592,7 +592,7 @@ declare const _default: {
|
|
|
592
592
|
sanitize: (html: string) => string;
|
|
593
593
|
placeholder: string;
|
|
594
594
|
noKatex: boolean;
|
|
595
|
-
|
|
595
|
+
codeTheme: string;
|
|
596
596
|
}> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
597
597
|
readonly NormalToolbar: typeof NormalToolbar;
|
|
598
598
|
readonly DropdownToolbar: typeof DropdownToolbar;
|
package/lib/MdEditor/type.d.ts
CHANGED
|
@@ -70,7 +70,8 @@ export interface StaticTextDefaultValue {
|
|
|
70
70
|
};
|
|
71
71
|
copyCode?: {
|
|
72
72
|
text?: string;
|
|
73
|
-
|
|
73
|
+
successTips?: string;
|
|
74
|
+
failTips?: string;
|
|
74
75
|
};
|
|
75
76
|
mermaid?: {
|
|
76
77
|
flow?: string;
|
|
@@ -200,6 +201,10 @@ export interface ConfigOption {
|
|
|
200
201
|
* 自定义内部mermaid模块
|
|
201
202
|
*/
|
|
202
203
|
mermaidTemplate?: MermaidTemplate;
|
|
204
|
+
/**
|
|
205
|
+
* 输入渲染延迟(ms)
|
|
206
|
+
*/
|
|
207
|
+
renderDelay?: number;
|
|
203
208
|
};
|
|
204
209
|
}
|
|
205
210
|
/**
|
package/lib/md-editor-v3.es.js
CHANGED
|
@@ -121,7 +121,8 @@ const staticTextDefault = {
|
|
|
121
121
|
},
|
|
122
122
|
copyCode: {
|
|
123
123
|
text: "\u590D\u5236\u4EE3\u7801",
|
|
124
|
-
|
|
124
|
+
successTips: "\u5DF2\u590D\u5236\uFF01",
|
|
125
|
+
failTips: "\u590D\u5236\u5931\u8D25\uFF01"
|
|
125
126
|
},
|
|
126
127
|
mermaid: {
|
|
127
128
|
flow: "\u6D41\u7A0B\u56FE",
|
|
@@ -195,7 +196,8 @@ const staticTextDefault = {
|
|
|
195
196
|
},
|
|
196
197
|
copyCode: {
|
|
197
198
|
text: "Copy",
|
|
198
|
-
|
|
199
|
+
successTips: "Copied!",
|
|
200
|
+
failTips: "Copy failed!"
|
|
199
201
|
},
|
|
200
202
|
mermaid: {
|
|
201
203
|
flow: "flow",
|
|
@@ -766,7 +768,7 @@ const useProvide = (props2, extension) => {
|
|
|
766
768
|
const cssList = __spreadValues(__spreadValues({}, codeCss), highlightConfig == null ? void 0 : highlightConfig.css);
|
|
767
769
|
return {
|
|
768
770
|
js: (highlightConfig == null ? void 0 : highlightConfig.js) || highlightUrl,
|
|
769
|
-
css: cssList[props2.
|
|
771
|
+
css: cssList[props2.codeTheme] ? cssList[props2.codeTheme][props2.theme] : codeCss.atom[props2.theme]
|
|
770
772
|
};
|
|
771
773
|
}));
|
|
772
774
|
provide("historyLength", props2.historyLength);
|
|
@@ -5202,7 +5204,7 @@ var kaTexExtensions = {
|
|
|
5202
5204
|
};
|
|
5203
5205
|
}
|
|
5204
5206
|
};
|
|
5205
|
-
const useHistory = (props2, textAreaRef) => {
|
|
5207
|
+
const useHistory = (props2, textAreaRef, completeStatus) => {
|
|
5206
5208
|
var _a, _b;
|
|
5207
5209
|
const previewOnly = inject("previewOnly");
|
|
5208
5210
|
const historyLength = inject("historyLength");
|
|
@@ -5222,68 +5224,88 @@ const useHistory = (props2, textAreaRef) => {
|
|
|
5222
5224
|
userUpdated: true,
|
|
5223
5225
|
curr: 0
|
|
5224
5226
|
};
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5227
|
+
let historyPos = [0, 0];
|
|
5228
|
+
const keyZCallback = (curr) => {
|
|
5229
|
+
var _a2, _b2;
|
|
5230
|
+
const startPos = ((_a2 = textAreaRef.value) == null ? void 0 : _a2.selectionStart) || 0;
|
|
5231
|
+
const endPos = ((_b2 = textAreaRef.value) == null ? void 0 : _b2.selectionEnd) || 0;
|
|
5232
|
+
history.list[history.curr].startPos = startPos;
|
|
5233
|
+
history.list[history.curr].endPos = endPos;
|
|
5234
|
+
history.userUpdated = false;
|
|
5235
|
+
history.curr = curr;
|
|
5236
|
+
const currHistory = history.list[history.curr];
|
|
5237
|
+
props2.onChange(currHistory.content);
|
|
5238
|
+
setPosition(textAreaRef.value, currHistory.startPos, currHistory.endPos);
|
|
5239
|
+
};
|
|
5240
|
+
const saveHistory = (content) => {
|
|
5241
|
+
var _a2, _b2;
|
|
5242
|
+
clearTimeout(saveHistoryId);
|
|
5243
|
+
const startPos = ((_a2 = textAreaRef.value) == null ? void 0 : _a2.selectionStart) || 0;
|
|
5244
|
+
const endPos = ((_b2 = textAreaRef.value) == null ? void 0 : _b2.selectionEnd) || 0;
|
|
5245
|
+
saveHistoryId = setTimeout(() => {
|
|
5246
|
+
if (history.userUpdated) {
|
|
5247
|
+
if (history.curr < history.list.length - 1) {
|
|
5248
|
+
history.list = history.list.slice(0, history.curr + 1);
|
|
5249
|
+
}
|
|
5250
|
+
if (history.list.length > historyLength) {
|
|
5251
|
+
history.list.shift();
|
|
5252
|
+
}
|
|
5253
|
+
const lastStep = history.list.pop() || {
|
|
5254
|
+
startPos: 0,
|
|
5255
|
+
endPos: 0,
|
|
5256
|
+
content
|
|
5257
|
+
};
|
|
5258
|
+
lastStep.startPos = historyPos[0];
|
|
5259
|
+
lastStep.endPos = historyPos[1];
|
|
5260
|
+
Array.prototype.push.call(history.list, lastStep, {
|
|
5261
|
+
content,
|
|
5262
|
+
startPos,
|
|
5263
|
+
endPos
|
|
5264
|
+
});
|
|
5265
|
+
history.curr = history.list.length - 1;
|
|
5266
|
+
} else {
|
|
5267
|
+
history.userUpdated = true;
|
|
5258
5268
|
}
|
|
5259
|
-
});
|
|
5269
|
+
}, 150);
|
|
5270
|
+
};
|
|
5271
|
+
const saveHistoryPos = () => {
|
|
5272
|
+
var _a2, _b2;
|
|
5273
|
+
historyPos = [(_a2 = textAreaRef.value) == null ? void 0 : _a2.selectionStart, (_b2 = textAreaRef.value) == null ? void 0 : _b2.selectionEnd];
|
|
5274
|
+
};
|
|
5275
|
+
watch(() => props2.value, (val) => {
|
|
5276
|
+
if (completeStatus.value) {
|
|
5277
|
+
saveHistory(val);
|
|
5278
|
+
}
|
|
5279
|
+
});
|
|
5280
|
+
watch(() => completeStatus.value, () => {
|
|
5281
|
+
saveHistory(props2.value);
|
|
5260
5282
|
});
|
|
5261
5283
|
onMounted(() => {
|
|
5262
5284
|
bus.on(editorId, {
|
|
5263
5285
|
name: "ctrlZ",
|
|
5264
5286
|
callback() {
|
|
5265
|
-
history.
|
|
5266
|
-
history.curr = history.curr - 1 < 0 ? 0 : history.curr - 1;
|
|
5267
|
-
const currHistory = history.list[history.curr];
|
|
5268
|
-
props2.onChange(currHistory.content);
|
|
5269
|
-
setPosition(textAreaRef.value, currHistory.startPos, currHistory.endPos);
|
|
5287
|
+
keyZCallback(history.curr - 1 < 0 ? 0 : history.curr - 1);
|
|
5270
5288
|
}
|
|
5271
5289
|
});
|
|
5272
5290
|
bus.on(editorId, {
|
|
5273
5291
|
name: "ctrlShiftZ",
|
|
5274
5292
|
callback() {
|
|
5275
|
-
history.
|
|
5276
|
-
history.curr = history.curr + 1 === history.list.length ? history.curr : history.curr + 1;
|
|
5277
|
-
const currHistory = history.list[history.curr];
|
|
5278
|
-
props2.onChange(currHistory.content);
|
|
5279
|
-
setPosition(textAreaRef.value, currHistory.startPos, currHistory.endPos);
|
|
5293
|
+
keyZCallback(history.curr + 1 === history.list.length ? history.curr : history.curr + 1);
|
|
5280
5294
|
}
|
|
5281
5295
|
});
|
|
5296
|
+
textAreaRef.value.addEventListener("keydown", saveHistoryPos);
|
|
5297
|
+
textAreaRef.value.addEventListener("click", saveHistoryPos);
|
|
5282
5298
|
});
|
|
5283
5299
|
};
|
|
5284
5300
|
const useMarked = (props2, mermaidData) => {
|
|
5285
5301
|
var _a, _b, _c;
|
|
5286
|
-
const {
|
|
5302
|
+
const {
|
|
5303
|
+
markedRenderer,
|
|
5304
|
+
markedExtensions,
|
|
5305
|
+
markedOptions,
|
|
5306
|
+
editorExtensions,
|
|
5307
|
+
editorConfig
|
|
5308
|
+
} = inject("extension");
|
|
5287
5309
|
const showCodeRowNumber = inject("showCodeRowNumber");
|
|
5288
5310
|
const editorId = inject("editorId");
|
|
5289
5311
|
const highlightUrl2 = inject("highlight");
|
|
@@ -5381,7 +5403,7 @@ const useMarked = (props2, mermaidData) => {
|
|
|
5381
5403
|
const _html = props2.sanitize(marked(props2.value || "", { renderer }));
|
|
5382
5404
|
html.value = _html;
|
|
5383
5405
|
props2.onHtmlChanged(_html);
|
|
5384
|
-
}, 500);
|
|
5406
|
+
}, (editorConfig == null ? void 0 : editorConfig.renderDelay) !== void 0 ? editorConfig == null ? void 0 : editorConfig.renderDelay : 500);
|
|
5385
5407
|
watch([
|
|
5386
5408
|
highlightInited,
|
|
5387
5409
|
toRef(mermaidData, "reRender"),
|
|
@@ -5456,16 +5478,18 @@ const useAutoScroll = (props2, html, textAreaRef, previewRef, htmlRef) => {
|
|
|
5456
5478
|
const initCopyEntry = () => {
|
|
5457
5479
|
document.querySelectorAll(`#${editorId}-preview pre`).forEach((pre) => {
|
|
5458
5480
|
var _a;
|
|
5481
|
+
const copyBtnText = ((_a = ult.value.copyCode) == null ? void 0 : _a.text) || "\u590D\u5236\u4EE3\u7801";
|
|
5459
5482
|
const copyButton = document.createElement("span");
|
|
5460
5483
|
copyButton.setAttribute("class", "copy-button");
|
|
5461
|
-
copyButton.innerText =
|
|
5484
|
+
copyButton.innerText = copyBtnText;
|
|
5462
5485
|
copyButton.addEventListener("click", () => {
|
|
5463
|
-
var _a2;
|
|
5464
|
-
copyToClipboard(pre.querySelector("code").innerText);
|
|
5465
|
-
|
|
5486
|
+
var _a2, _b;
|
|
5487
|
+
const success = copyToClipboard(pre.querySelector("code").innerText);
|
|
5488
|
+
const succssTip = ((_a2 = ult.value.copyCode) == null ? void 0 : _a2.successTips) || "\u5DF2\u590D\u5236\uFF01";
|
|
5489
|
+
const failTip = ((_b = ult.value.copyCode) == null ? void 0 : _b.failTips) || "\u5DF2\u590D\u5236\uFF01";
|
|
5490
|
+
copyButton.innerText = success ? succssTip : failTip;
|
|
5466
5491
|
setTimeout(() => {
|
|
5467
|
-
|
|
5468
|
-
copyButton.innerText = ((_a3 = ult.value.copyCode) == null ? void 0 : _a3.text) || "\u590D\u5236\u4EE3\u7801";
|
|
5492
|
+
copyButton.innerText = copyBtnText;
|
|
5469
5493
|
}, 1500);
|
|
5470
5494
|
});
|
|
5471
5495
|
pre.appendChild(copyButton);
|
|
@@ -5704,7 +5728,7 @@ var Content = defineComponent({
|
|
|
5704
5728
|
const {
|
|
5705
5729
|
selectedText
|
|
5706
5730
|
} = useAutoGenrator(props2, textAreaRef);
|
|
5707
|
-
useHistory(props2, textAreaRef);
|
|
5731
|
+
useHistory(props2, textAreaRef, completeStatus);
|
|
5708
5732
|
usePasteUpload(textAreaRef);
|
|
5709
5733
|
userZoom(html);
|
|
5710
5734
|
return () => {
|
|
@@ -5721,10 +5745,9 @@ var Content = defineComponent({
|
|
|
5721
5745
|
},
|
|
5722
5746
|
"onInput": (e) => {
|
|
5723
5747
|
selectedText.value = "";
|
|
5724
|
-
props2.onChange(e.target.value
|
|
5748
|
+
props2.onChange(e.target.value);
|
|
5725
5749
|
},
|
|
5726
|
-
"onCompositionend": (
|
|
5727
|
-
bus.emit(editorId, "saveHistory", e.target.value);
|
|
5750
|
+
"onCompositionend": () => {
|
|
5728
5751
|
completeStatus.value = true;
|
|
5729
5752
|
},
|
|
5730
5753
|
"class": [props2.setting.preview || props2.setting.htmlPreview ? "" : "textarea-only"],
|
|
@@ -6003,7 +6026,7 @@ const props = {
|
|
|
6003
6026
|
onError: {
|
|
6004
6027
|
type: Function
|
|
6005
6028
|
},
|
|
6006
|
-
|
|
6029
|
+
codeTheme: {
|
|
6007
6030
|
type: String,
|
|
6008
6031
|
default: "atom"
|
|
6009
6032
|
}
|
|
@@ -6113,10 +6136,7 @@ const Editor = defineComponent({
|
|
|
6113
6136
|
"defToolbars": defToolbars
|
|
6114
6137
|
}, null), createVNode(Content, {
|
|
6115
6138
|
"value": props2.modelValue,
|
|
6116
|
-
"onChange": (value
|
|
6117
|
-
if (completeStatus) {
|
|
6118
|
-
bus.emit(editorId, "saveHistory", value);
|
|
6119
|
-
}
|
|
6139
|
+
"onChange": (value) => {
|
|
6120
6140
|
if (props2.onChange) {
|
|
6121
6141
|
props2.onChange(value);
|
|
6122
6142
|
} else {
|