md-editor-v3 5.5.1-0 → 5.6.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/lib/cjs/MdEditor.cjs +53 -48
- package/lib/cjs/chunks/dom.cjs +4 -5
- package/lib/cjs/chunks/index.cjs +7 -0
- package/lib/es/MdEditor.mjs +56 -51
- package/lib/es/chunks/dom.mjs +4 -5
- package/lib/es/chunks/index.mjs +12 -5
- package/lib/es/chunks/index3.mjs +1 -1
- package/lib/es/chunks/index4.mjs +1 -1
- package/lib/types/MdEditor/Editor.d.ts +3 -0
- package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +2 -0
- package/lib/types/MdEditor/layouts/Toolbar/props.d.ts +3 -0
- package/lib/types/MdEditor/props.d.ts +7 -0
- package/lib/types/MdEditor/utils/content-help.d.ts +4 -0
- package/lib/umd/index.js +119 -119
- package/package.json +8 -1
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -87,6 +87,9 @@ const toolbarProps = {
|
|
|
87
87
|
},
|
|
88
88
|
codeTheme: {
|
|
89
89
|
type: String
|
|
90
|
+
},
|
|
91
|
+
insertLinkDirect: {
|
|
92
|
+
type: Boolean
|
|
90
93
|
}
|
|
91
94
|
};
|
|
92
95
|
const useSreenfull = (props2) => {
|
|
@@ -831,8 +834,12 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
831
834
|
if (disabled == null ? void 0 : disabled.value) {
|
|
832
835
|
return false;
|
|
833
836
|
}
|
|
834
|
-
|
|
835
|
-
|
|
837
|
+
if (props2.insertLinkDirect) {
|
|
838
|
+
emitHandler("link");
|
|
839
|
+
} else {
|
|
840
|
+
modalData.type = "link";
|
|
841
|
+
modalData.linkVisible = true;
|
|
842
|
+
}
|
|
836
843
|
}
|
|
837
844
|
}, [vue.createVNode(MdModal.Icon, {
|
|
838
845
|
"name": "link"
|
|
@@ -848,8 +855,12 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
848
855
|
if (disabled == null ? void 0 : disabled.value) {
|
|
849
856
|
return false;
|
|
850
857
|
}
|
|
851
|
-
|
|
852
|
-
|
|
858
|
+
if (props2.insertLinkDirect) {
|
|
859
|
+
emitHandler("image");
|
|
860
|
+
} else {
|
|
861
|
+
modalData.type = "image";
|
|
862
|
+
modalData.linkVisible = true;
|
|
863
|
+
}
|
|
853
864
|
}
|
|
854
865
|
}, [vue.createVNode(MdModal.Icon, {
|
|
855
866
|
"name": "image"
|
|
@@ -865,14 +876,18 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
865
876
|
"overlay": vue.createVNode("ul", {
|
|
866
877
|
"class": `${config.prefix}-menu`,
|
|
867
878
|
"onClick": () => {
|
|
868
|
-
visible.
|
|
879
|
+
visible.image = false;
|
|
869
880
|
},
|
|
870
881
|
"role": "menu"
|
|
871
882
|
}, [vue.createVNode("li", {
|
|
872
883
|
"class": `${config.prefix}-menu-item ${config.prefix}-menu-item-image`,
|
|
873
884
|
"onClick": () => {
|
|
874
|
-
|
|
875
|
-
|
|
885
|
+
if (props2.insertLinkDirect) {
|
|
886
|
+
emitHandler("image");
|
|
887
|
+
} else {
|
|
888
|
+
modalData.type = "image";
|
|
889
|
+
modalData.linkVisible = true;
|
|
890
|
+
}
|
|
876
891
|
},
|
|
877
892
|
"role": "menuitem",
|
|
878
893
|
"tabindex": "0"
|
|
@@ -1442,7 +1457,16 @@ const directive2flag = async (direct, codeMirrorUt, params) => {
|
|
|
1442
1457
|
return handleTable(params);
|
|
1443
1458
|
}
|
|
1444
1459
|
case "link": {
|
|
1445
|
-
|
|
1460
|
+
const { desc = "", url = "" } = params;
|
|
1461
|
+
const text = `[${desc}](${url})`;
|
|
1462
|
+
return {
|
|
1463
|
+
text,
|
|
1464
|
+
options: {
|
|
1465
|
+
select: url === "",
|
|
1466
|
+
deviationStart: text.length - url.length - 1,
|
|
1467
|
+
deviationEnd: -1
|
|
1468
|
+
}
|
|
1469
|
+
};
|
|
1446
1470
|
}
|
|
1447
1471
|
case "image": {
|
|
1448
1472
|
return handleImage(params);
|
|
@@ -1540,11 +1564,7 @@ const handleMultiLine = (type, codeMirrorUt) => {
|
|
|
1540
1564
|
const deviationStart = lines.length === 1 ? firstLinePrefix.length : 0;
|
|
1541
1565
|
return {
|
|
1542
1566
|
text: formattedLines.join("\n"),
|
|
1543
|
-
options: {
|
|
1544
|
-
deviationStart,
|
|
1545
|
-
replaceStart,
|
|
1546
|
-
replaceEnd
|
|
1547
|
-
}
|
|
1567
|
+
options: { deviationStart, replaceStart, replaceEnd }
|
|
1548
1568
|
};
|
|
1549
1569
|
};
|
|
1550
1570
|
const handleCodeBlock = (params, codeMirrorUt) => {
|
|
@@ -1587,7 +1607,7 @@ ${mermaidTemplates[type]}
|
|
|
1587
1607
|
};
|
|
1588
1608
|
};
|
|
1589
1609
|
const handleImage = (params) => {
|
|
1590
|
-
const { desc, url, urls } = params;
|
|
1610
|
+
const { desc = "", url = "", urls } = params;
|
|
1591
1611
|
let text = "";
|
|
1592
1612
|
if (urls instanceof Array) {
|
|
1593
1613
|
text = urls.reduce((pVal, _url) => {
|
|
@@ -1603,7 +1623,14 @@ const handleImage = (params) => {
|
|
|
1603
1623
|
text = `
|
|
1604
1624
|
`;
|
|
1605
1625
|
}
|
|
1606
|
-
return {
|
|
1626
|
+
return {
|
|
1627
|
+
text,
|
|
1628
|
+
options: {
|
|
1629
|
+
select: url === "",
|
|
1630
|
+
deviationStart: text.length - url.length - 2,
|
|
1631
|
+
deviationEnd: -2
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1607
1634
|
};
|
|
1608
1635
|
const handleTable = (params) => {
|
|
1609
1636
|
const { selectedShape = { x: 1, y: 1 } } = params;
|
|
@@ -1623,13 +1650,7 @@ const handleTable = (params) => {
|
|
|
1623
1650
|
}
|
|
1624
1651
|
}
|
|
1625
1652
|
text += "\n";
|
|
1626
|
-
return {
|
|
1627
|
-
text,
|
|
1628
|
-
options: {
|
|
1629
|
-
deviationStart: 3,
|
|
1630
|
-
deviationEnd: 10 - text.length
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1653
|
+
return { text, options: { deviationStart: 3, deviationEnd: 10 - text.length } };
|
|
1633
1654
|
};
|
|
1634
1655
|
const handleUniversal = (selectedText, params) => {
|
|
1635
1656
|
const { generate } = params;
|
|
@@ -1643,9 +1664,7 @@ const handleUniversal = (selectedText, params) => {
|
|
|
1643
1664
|
}
|
|
1644
1665
|
};
|
|
1645
1666
|
};
|
|
1646
|
-
const getSelectedInfo = (codeMirrorUt, options = {
|
|
1647
|
-
wholeLine: false
|
|
1648
|
-
}) => {
|
|
1667
|
+
const getSelectedInfo = (codeMirrorUt, options = { wholeLine: false }) => {
|
|
1649
1668
|
const state2 = codeMirrorUt.view.state;
|
|
1650
1669
|
const selection2 = state2.selection.main;
|
|
1651
1670
|
if (selection2.empty) {
|
|
@@ -2594,10 +2613,7 @@ const useCodeMirror = (props2) => {
|
|
|
2594
2613
|
const { text, options } = await directive2flag(
|
|
2595
2614
|
direct,
|
|
2596
2615
|
codeMirrorUt.value,
|
|
2597
|
-
{
|
|
2598
|
-
...params,
|
|
2599
|
-
url
|
|
2600
|
-
}
|
|
2616
|
+
{ ...params, url }
|
|
2601
2617
|
);
|
|
2602
2618
|
(_a2 = codeMirrorUt.value) == null ? void 0 : _a2.replaceSelectedText(text, options, editorId);
|
|
2603
2619
|
}).catch((err) => {
|
|
@@ -2624,9 +2640,7 @@ const useCodeMirror = (props2) => {
|
|
|
2624
2640
|
name: eventName.EVENT_LISTENER,
|
|
2625
2641
|
callback: util.throttle((handlers) => {
|
|
2626
2642
|
var _a;
|
|
2627
|
-
const nextDomEventHandlers = {
|
|
2628
|
-
...domEventHandlers
|
|
2629
|
-
};
|
|
2643
|
+
const nextDomEventHandlers = { ...domEventHandlers };
|
|
2630
2644
|
const defaultEventNames = Object.keys(domEventHandlers);
|
|
2631
2645
|
for (const eventName2 in handlers) {
|
|
2632
2646
|
const en = eventName2;
|
|
@@ -2653,9 +2667,7 @@ const useCodeMirror = (props2) => {
|
|
|
2653
2667
|
callback: (lineNumber, value) => {
|
|
2654
2668
|
const line = view2.state.doc.line(lineNumber);
|
|
2655
2669
|
view2.dispatch(
|
|
2656
|
-
view2.state.update({
|
|
2657
|
-
changes: { from: line.from, to: line.to, insert: value }
|
|
2658
|
-
})
|
|
2670
|
+
view2.state.update({ changes: { from: line.from, to: line.to, insert: value } })
|
|
2659
2671
|
);
|
|
2660
2672
|
}
|
|
2661
2673
|
});
|
|
@@ -2675,9 +2687,7 @@ const useCodeMirror = (props2) => {
|
|
|
2675
2687
|
effects: themeComp.reconfigure(theme.value === "light" ? oneLight : oneDark)
|
|
2676
2688
|
});
|
|
2677
2689
|
},
|
|
2678
|
-
{
|
|
2679
|
-
deep: true
|
|
2680
|
-
}
|
|
2690
|
+
{ deep: true }
|
|
2681
2691
|
);
|
|
2682
2692
|
vue.watch(
|
|
2683
2693
|
() => props2.completions,
|
|
@@ -2687,9 +2697,7 @@ const useCodeMirror = (props2) => {
|
|
|
2687
2697
|
effects: autocompletionComp.reconfigure(createAutocompletion(props2.completions))
|
|
2688
2698
|
});
|
|
2689
2699
|
},
|
|
2690
|
-
{
|
|
2691
|
-
deep: true
|
|
2692
|
-
}
|
|
2700
|
+
{ deep: true }
|
|
2693
2701
|
);
|
|
2694
2702
|
vue.watch(
|
|
2695
2703
|
() => props2.modelValue,
|
|
@@ -2735,12 +2743,8 @@ const useCodeMirror = (props2) => {
|
|
|
2735
2743
|
codeMirrorUt,
|
|
2736
2744
|
resetHistory() {
|
|
2737
2745
|
var _a, _b;
|
|
2738
|
-
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({
|
|
2739
|
-
|
|
2740
|
-
});
|
|
2741
|
-
(_b = codeMirrorUt.value) == null ? void 0 : _b.view.dispatch({
|
|
2742
|
-
effects: historyComp.reconfigure(commands.history())
|
|
2743
|
-
});
|
|
2746
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({ effects: historyComp.reconfigure([]) });
|
|
2747
|
+
(_b = codeMirrorUt.value) == null ? void 0 : _b.view.dispatch({ effects: historyComp.reconfigure(commands.history()) });
|
|
2744
2748
|
}
|
|
2745
2749
|
};
|
|
2746
2750
|
};
|
|
@@ -3164,7 +3168,8 @@ const Editor = /* @__PURE__ */ vue.defineComponent({
|
|
|
3164
3168
|
"noUploadImg": noUploadImg,
|
|
3165
3169
|
"showToolbarName": props2.showToolbarName,
|
|
3166
3170
|
"catalogVisible": catalogVisible.value,
|
|
3167
|
-
"codeTheme": props2.codeTheme
|
|
3171
|
+
"codeTheme": props2.codeTheme,
|
|
3172
|
+
"insertLinkDirect": props2.insertLinkDirect
|
|
3168
3173
|
}, null), vue.createVNode(Content, {
|
|
3169
3174
|
"ref": codeRef,
|
|
3170
3175
|
"modelValue": props2.modelValue,
|
package/lib/cjs/chunks/dom.cjs
CHANGED
|
@@ -12,7 +12,6 @@ const StrIcon = (name, customIcon) => {
|
|
|
12
12
|
}
|
|
13
13
|
return iconMaps[name];
|
|
14
14
|
};
|
|
15
|
-
const StrIcon$1 = StrIcon;
|
|
16
15
|
const keyMove = (trigger, moveHandler) => {
|
|
17
16
|
const triggerMouseDown = (mdown) => {
|
|
18
17
|
const parent = trigger.parentElement || document.body;
|
|
@@ -197,7 +196,7 @@ const zoomMermaid = /* @__PURE__ */ (() => {
|
|
|
197
196
|
if (!actionDiv) {
|
|
198
197
|
mm.insertAdjacentHTML(
|
|
199
198
|
"beforeend",
|
|
200
|
-
`<div class="${config.prefix}-mermaid-action">${StrIcon
|
|
199
|
+
`<div class="${config.prefix}-mermaid-action">${StrIcon("pin-off", options.customIcon)}</div>`
|
|
201
200
|
);
|
|
202
201
|
actionDiv = mm.querySelector(`.${config.prefix}-mermaid-action`);
|
|
203
202
|
}
|
|
@@ -207,12 +206,12 @@ const zoomMermaid = /* @__PURE__ */ (() => {
|
|
|
207
206
|
current.removeEvent();
|
|
208
207
|
mm.removeAttribute("data-grab");
|
|
209
208
|
removeEventsMap.set(mm, { removeClick: current.removeClick });
|
|
210
|
-
actionDiv.innerHTML = StrIcon
|
|
209
|
+
actionDiv.innerHTML = StrIcon("pin-off", options.customIcon);
|
|
211
210
|
} else {
|
|
212
211
|
const removeEvent = addEvent(mm);
|
|
213
212
|
mm.setAttribute("data-grab", "");
|
|
214
213
|
removeEventsMap.set(mm, { removeEvent, removeClick: current == null ? void 0 : current.removeClick });
|
|
215
|
-
actionDiv.innerHTML = StrIcon
|
|
214
|
+
actionDiv.innerHTML = StrIcon("pin", options.customIcon);
|
|
216
215
|
}
|
|
217
216
|
};
|
|
218
217
|
actionDiv.addEventListener("click", onClick);
|
|
@@ -230,7 +229,7 @@ const zoomMermaid = /* @__PURE__ */ (() => {
|
|
|
230
229
|
};
|
|
231
230
|
return handler;
|
|
232
231
|
})();
|
|
233
|
-
exports.StrIcon = StrIcon
|
|
232
|
+
exports.StrIcon = StrIcon;
|
|
234
233
|
exports.appendHandler = appendHandler;
|
|
235
234
|
exports.keyMove = keyMove;
|
|
236
235
|
exports.updateHandler = updateHandler;
|
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -2335,6 +2335,13 @@ const editorProps = {
|
|
|
2335
2335
|
catalogMaxDepth: {
|
|
2336
2336
|
type: Number,
|
|
2337
2337
|
default: void 0
|
|
2338
|
+
},
|
|
2339
|
+
/**
|
|
2340
|
+
* 工具栏直接插入内容到输入框
|
|
2341
|
+
*/
|
|
2342
|
+
insertLinkDirect: {
|
|
2343
|
+
type: Boolean,
|
|
2344
|
+
default: false
|
|
2338
2345
|
}
|
|
2339
2346
|
};
|
|
2340
2347
|
const mdPreviewEmits = [
|
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { draggingScroll, linkTo, throttle, createSmoothScroll } from "@vavt/util
|
|
|
7
7
|
import { a as Dropdown, D as DropdownToolbar } from "./chunks/index2.mjs";
|
|
8
8
|
import { b as bus, C as CHANGE_FULL_SCREEN, E as ERROR_CATCHER, U as UPLOAD_IMAGE, O as OPEN_MODALS, R as REPLACE, a as CHANGE_CATALOG_VISIBLE, c as ON_SAVE, d as CTRL_SHIFT_Z, e as CTRL_Z, f as EVENT_LISTENER, T as TASK_STATE_CHANGED, S as SEND_EDITOR_VIEW, G as GET_EDITOR_VIEW } from "./chunks/event-name.mjs";
|
|
9
9
|
import { a as appendHandler } from "./chunks/dom.mjs";
|
|
10
|
-
import { C as CDN_IDS, c as contentProps, a as ContentPreview, e as
|
|
10
|
+
import { C as CDN_IDS, c as contentProps, a as ContentPreview, e as editorEmits, b as editorProps, u as useProvide, d as useConfig, f as useCatalog, g as useOnSave, h as useExpansion, i as useErrorCatcher, j as useExpose, M as MdPreview } from "./chunks/index.mjs";
|
|
11
11
|
import { M as MdModal, I as Icon } from "./chunks/index4.mjs";
|
|
12
12
|
import { b as base642File } from "./chunks/index5.mjs";
|
|
13
13
|
import { s as scrollAuto, a as scrollAutoWithScale, M as MdCatalog } from "./chunks/index3.mjs";
|
|
@@ -16,8 +16,8 @@ import { EditorView, placeholder, keymap, drawSelection } from "@codemirror/view
|
|
|
16
16
|
import { languages } from "@codemirror/language-data";
|
|
17
17
|
import { markdown } from "@codemirror/lang-markdown";
|
|
18
18
|
import { EditorSelection, EditorState, Compartment, StateEffect } from "@codemirror/state";
|
|
19
|
-
import { deleteLine,
|
|
20
|
-
import {
|
|
19
|
+
import { deleteLine, defaultKeymap, historyKeymap, indentWithTab, history, undo, redo } from "@codemirror/commands";
|
|
20
|
+
import { syntaxHighlighting, HighlightStyle, indentUnit } from "@codemirror/language";
|
|
21
21
|
import { tags } from "@lezer/highlight";
|
|
22
22
|
import { autocompletion } from "@codemirror/autocomplete";
|
|
23
23
|
import { searchKeymap } from "@codemirror/search";
|
|
@@ -86,6 +86,9 @@ const toolbarProps = {
|
|
|
86
86
|
},
|
|
87
87
|
codeTheme: {
|
|
88
88
|
type: String
|
|
89
|
+
},
|
|
90
|
+
insertLinkDirect: {
|
|
91
|
+
type: Boolean
|
|
89
92
|
}
|
|
90
93
|
};
|
|
91
94
|
const useSreenfull = (props2) => {
|
|
@@ -830,8 +833,12 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
830
833
|
if (disabled == null ? void 0 : disabled.value) {
|
|
831
834
|
return false;
|
|
832
835
|
}
|
|
833
|
-
|
|
834
|
-
|
|
836
|
+
if (props2.insertLinkDirect) {
|
|
837
|
+
emitHandler("link");
|
|
838
|
+
} else {
|
|
839
|
+
modalData.type = "link";
|
|
840
|
+
modalData.linkVisible = true;
|
|
841
|
+
}
|
|
835
842
|
}
|
|
836
843
|
}, [createVNode(Icon, {
|
|
837
844
|
"name": "link"
|
|
@@ -847,8 +854,12 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
847
854
|
if (disabled == null ? void 0 : disabled.value) {
|
|
848
855
|
return false;
|
|
849
856
|
}
|
|
850
|
-
|
|
851
|
-
|
|
857
|
+
if (props2.insertLinkDirect) {
|
|
858
|
+
emitHandler("image");
|
|
859
|
+
} else {
|
|
860
|
+
modalData.type = "image";
|
|
861
|
+
modalData.linkVisible = true;
|
|
862
|
+
}
|
|
852
863
|
}
|
|
853
864
|
}, [createVNode(Icon, {
|
|
854
865
|
"name": "image"
|
|
@@ -864,14 +875,18 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
864
875
|
"overlay": createVNode("ul", {
|
|
865
876
|
"class": `${prefix}-menu`,
|
|
866
877
|
"onClick": () => {
|
|
867
|
-
visible.
|
|
878
|
+
visible.image = false;
|
|
868
879
|
},
|
|
869
880
|
"role": "menu"
|
|
870
881
|
}, [createVNode("li", {
|
|
871
882
|
"class": `${prefix}-menu-item ${prefix}-menu-item-image`,
|
|
872
883
|
"onClick": () => {
|
|
873
|
-
|
|
874
|
-
|
|
884
|
+
if (props2.insertLinkDirect) {
|
|
885
|
+
emitHandler("image");
|
|
886
|
+
} else {
|
|
887
|
+
modalData.type = "image";
|
|
888
|
+
modalData.linkVisible = true;
|
|
889
|
+
}
|
|
875
890
|
},
|
|
876
891
|
"role": "menuitem",
|
|
877
892
|
"tabindex": "0"
|
|
@@ -1441,7 +1456,16 @@ const directive2flag = async (direct, codeMirrorUt, params) => {
|
|
|
1441
1456
|
return handleTable(params);
|
|
1442
1457
|
}
|
|
1443
1458
|
case "link": {
|
|
1444
|
-
|
|
1459
|
+
const { desc = "", url = "" } = params;
|
|
1460
|
+
const text = `[${desc}](${url})`;
|
|
1461
|
+
return {
|
|
1462
|
+
text,
|
|
1463
|
+
options: {
|
|
1464
|
+
select: url === "",
|
|
1465
|
+
deviationStart: text.length - url.length - 1,
|
|
1466
|
+
deviationEnd: -1
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1445
1469
|
}
|
|
1446
1470
|
case "image": {
|
|
1447
1471
|
return handleImage(params);
|
|
@@ -1539,11 +1563,7 @@ const handleMultiLine = (type, codeMirrorUt) => {
|
|
|
1539
1563
|
const deviationStart = lines.length === 1 ? firstLinePrefix.length : 0;
|
|
1540
1564
|
return {
|
|
1541
1565
|
text: formattedLines.join("\n"),
|
|
1542
|
-
options: {
|
|
1543
|
-
deviationStart,
|
|
1544
|
-
replaceStart,
|
|
1545
|
-
replaceEnd
|
|
1546
|
-
}
|
|
1566
|
+
options: { deviationStart, replaceStart, replaceEnd }
|
|
1547
1567
|
};
|
|
1548
1568
|
};
|
|
1549
1569
|
const handleCodeBlock = (params, codeMirrorUt) => {
|
|
@@ -1586,7 +1606,7 @@ ${mermaidTemplates[type]}
|
|
|
1586
1606
|
};
|
|
1587
1607
|
};
|
|
1588
1608
|
const handleImage = (params) => {
|
|
1589
|
-
const { desc, url, urls } = params;
|
|
1609
|
+
const { desc = "", url = "", urls } = params;
|
|
1590
1610
|
let text = "";
|
|
1591
1611
|
if (urls instanceof Array) {
|
|
1592
1612
|
text = urls.reduce((pVal, _url) => {
|
|
@@ -1602,7 +1622,14 @@ const handleImage = (params) => {
|
|
|
1602
1622
|
text = `
|
|
1603
1623
|
`;
|
|
1604
1624
|
}
|
|
1605
|
-
return {
|
|
1625
|
+
return {
|
|
1626
|
+
text,
|
|
1627
|
+
options: {
|
|
1628
|
+
select: url === "",
|
|
1629
|
+
deviationStart: text.length - url.length - 2,
|
|
1630
|
+
deviationEnd: -2
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1606
1633
|
};
|
|
1607
1634
|
const handleTable = (params) => {
|
|
1608
1635
|
const { selectedShape = { x: 1, y: 1 } } = params;
|
|
@@ -1622,13 +1649,7 @@ const handleTable = (params) => {
|
|
|
1622
1649
|
}
|
|
1623
1650
|
}
|
|
1624
1651
|
text += "\n";
|
|
1625
|
-
return {
|
|
1626
|
-
text,
|
|
1627
|
-
options: {
|
|
1628
|
-
deviationStart: 3,
|
|
1629
|
-
deviationEnd: 10 - text.length
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1652
|
+
return { text, options: { deviationStart: 3, deviationEnd: 10 - text.length } };
|
|
1632
1653
|
};
|
|
1633
1654
|
const handleUniversal = (selectedText, params) => {
|
|
1634
1655
|
const { generate } = params;
|
|
@@ -1642,9 +1663,7 @@ const handleUniversal = (selectedText, params) => {
|
|
|
1642
1663
|
}
|
|
1643
1664
|
};
|
|
1644
1665
|
};
|
|
1645
|
-
const getSelectedInfo = (codeMirrorUt, options = {
|
|
1646
|
-
wholeLine: false
|
|
1647
|
-
}) => {
|
|
1666
|
+
const getSelectedInfo = (codeMirrorUt, options = { wholeLine: false }) => {
|
|
1648
1667
|
const state = codeMirrorUt.view.state;
|
|
1649
1668
|
const selection2 = state.selection.main;
|
|
1650
1669
|
if (selection2.empty) {
|
|
@@ -2593,10 +2612,7 @@ const useCodeMirror = (props2) => {
|
|
|
2593
2612
|
const { text, options } = await directive2flag(
|
|
2594
2613
|
direct,
|
|
2595
2614
|
codeMirrorUt.value,
|
|
2596
|
-
{
|
|
2597
|
-
...params,
|
|
2598
|
-
url
|
|
2599
|
-
}
|
|
2615
|
+
{ ...params, url }
|
|
2600
2616
|
);
|
|
2601
2617
|
(_a2 = codeMirrorUt.value) == null ? void 0 : _a2.replaceSelectedText(text, options, editorId);
|
|
2602
2618
|
}).catch((err) => {
|
|
@@ -2623,9 +2639,7 @@ const useCodeMirror = (props2) => {
|
|
|
2623
2639
|
name: EVENT_LISTENER,
|
|
2624
2640
|
callback: throttle((handlers) => {
|
|
2625
2641
|
var _a;
|
|
2626
|
-
const nextDomEventHandlers = {
|
|
2627
|
-
...domEventHandlers
|
|
2628
|
-
};
|
|
2642
|
+
const nextDomEventHandlers = { ...domEventHandlers };
|
|
2629
2643
|
const defaultEventNames = Object.keys(domEventHandlers);
|
|
2630
2644
|
for (const eventName in handlers) {
|
|
2631
2645
|
const en = eventName;
|
|
@@ -2652,9 +2666,7 @@ const useCodeMirror = (props2) => {
|
|
|
2652
2666
|
callback: (lineNumber, value) => {
|
|
2653
2667
|
const line = view.state.doc.line(lineNumber);
|
|
2654
2668
|
view.dispatch(
|
|
2655
|
-
view.state.update({
|
|
2656
|
-
changes: { from: line.from, to: line.to, insert: value }
|
|
2657
|
-
})
|
|
2669
|
+
view.state.update({ changes: { from: line.from, to: line.to, insert: value } })
|
|
2658
2670
|
);
|
|
2659
2671
|
}
|
|
2660
2672
|
});
|
|
@@ -2674,9 +2686,7 @@ const useCodeMirror = (props2) => {
|
|
|
2674
2686
|
effects: themeComp.reconfigure(theme.value === "light" ? oneLight : oneDark)
|
|
2675
2687
|
});
|
|
2676
2688
|
},
|
|
2677
|
-
{
|
|
2678
|
-
deep: true
|
|
2679
|
-
}
|
|
2689
|
+
{ deep: true }
|
|
2680
2690
|
);
|
|
2681
2691
|
watch(
|
|
2682
2692
|
() => props2.completions,
|
|
@@ -2686,9 +2696,7 @@ const useCodeMirror = (props2) => {
|
|
|
2686
2696
|
effects: autocompletionComp.reconfigure(createAutocompletion(props2.completions))
|
|
2687
2697
|
});
|
|
2688
2698
|
},
|
|
2689
|
-
{
|
|
2690
|
-
deep: true
|
|
2691
|
-
}
|
|
2699
|
+
{ deep: true }
|
|
2692
2700
|
);
|
|
2693
2701
|
watch(
|
|
2694
2702
|
() => props2.modelValue,
|
|
@@ -2734,12 +2742,8 @@ const useCodeMirror = (props2) => {
|
|
|
2734
2742
|
codeMirrorUt,
|
|
2735
2743
|
resetHistory() {
|
|
2736
2744
|
var _a, _b;
|
|
2737
|
-
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({
|
|
2738
|
-
|
|
2739
|
-
});
|
|
2740
|
-
(_b = codeMirrorUt.value) == null ? void 0 : _b.view.dispatch({
|
|
2741
|
-
effects: historyComp.reconfigure(history())
|
|
2742
|
-
});
|
|
2745
|
+
(_a = codeMirrorUt.value) == null ? void 0 : _a.view.dispatch({ effects: historyComp.reconfigure([]) });
|
|
2746
|
+
(_b = codeMirrorUt.value) == null ? void 0 : _b.view.dispatch({ effects: historyComp.reconfigure(history()) });
|
|
2743
2747
|
}
|
|
2744
2748
|
};
|
|
2745
2749
|
};
|
|
@@ -3163,7 +3167,8 @@ const Editor = /* @__PURE__ */ defineComponent({
|
|
|
3163
3167
|
"noUploadImg": noUploadImg,
|
|
3164
3168
|
"showToolbarName": props2.showToolbarName,
|
|
3165
3169
|
"catalogVisible": catalogVisible.value,
|
|
3166
|
-
"codeTheme": props2.codeTheme
|
|
3170
|
+
"codeTheme": props2.codeTheme,
|
|
3171
|
+
"insertLinkDirect": props2.insertLinkDirect
|
|
3167
3172
|
}, null), createVNode(Content, {
|
|
3168
3173
|
"ref": codeRef,
|
|
3169
3174
|
"modelValue": props2.modelValue,
|
package/lib/es/chunks/dom.mjs
CHANGED
|
@@ -11,7 +11,6 @@ const StrIcon = (name, customIcon) => {
|
|
|
11
11
|
}
|
|
12
12
|
return iconMaps[name];
|
|
13
13
|
};
|
|
14
|
-
const StrIcon$1 = StrIcon;
|
|
15
14
|
const keyMove = (trigger, moveHandler) => {
|
|
16
15
|
const triggerMouseDown = (mdown) => {
|
|
17
16
|
const parent = trigger.parentElement || document.body;
|
|
@@ -196,7 +195,7 @@ const zoomMermaid = /* @__PURE__ */ (() => {
|
|
|
196
195
|
if (!actionDiv) {
|
|
197
196
|
mm.insertAdjacentHTML(
|
|
198
197
|
"beforeend",
|
|
199
|
-
`<div class="${prefix}-mermaid-action">${StrIcon
|
|
198
|
+
`<div class="${prefix}-mermaid-action">${StrIcon("pin-off", options.customIcon)}</div>`
|
|
200
199
|
);
|
|
201
200
|
actionDiv = mm.querySelector(`.${prefix}-mermaid-action`);
|
|
202
201
|
}
|
|
@@ -206,12 +205,12 @@ const zoomMermaid = /* @__PURE__ */ (() => {
|
|
|
206
205
|
current.removeEvent();
|
|
207
206
|
mm.removeAttribute("data-grab");
|
|
208
207
|
removeEventsMap.set(mm, { removeClick: current.removeClick });
|
|
209
|
-
actionDiv.innerHTML = StrIcon
|
|
208
|
+
actionDiv.innerHTML = StrIcon("pin-off", options.customIcon);
|
|
210
209
|
} else {
|
|
211
210
|
const removeEvent = addEvent(mm);
|
|
212
211
|
mm.setAttribute("data-grab", "");
|
|
213
212
|
removeEventsMap.set(mm, { removeEvent, removeClick: current == null ? void 0 : current.removeClick });
|
|
214
|
-
actionDiv.innerHTML = StrIcon
|
|
213
|
+
actionDiv.innerHTML = StrIcon("pin", options.customIcon);
|
|
215
214
|
}
|
|
216
215
|
};
|
|
217
216
|
actionDiv.addEventListener("click", onClick);
|
|
@@ -230,7 +229,7 @@ const zoomMermaid = /* @__PURE__ */ (() => {
|
|
|
230
229
|
return handler;
|
|
231
230
|
})();
|
|
232
231
|
export {
|
|
233
|
-
StrIcon
|
|
232
|
+
StrIcon as S,
|
|
234
233
|
appendHandler as a,
|
|
235
234
|
keyMove as k,
|
|
236
235
|
updateHandler as u,
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { inject, onMounted, watch, toRef, nextTick, shallowRef, ref, computed, onBeforeUnmount, defineComponent, createVNode, Fragment,
|
|
2
|
-
import { p as prefix, d as configOption, f as codeCss, s as staticTextDefault,
|
|
3
|
-
import { b as bus, E as ERROR_CATCHER, g as CATALOG_CHANGED, P as PUSH_CATALOG, h as RERENDER, B as BUILD_FINISHED, T as TASK_STATE_CHANGED,
|
|
1
|
+
import { inject, onMounted, watch, toRef, nextTick, shallowRef, ref, computed, onBeforeUnmount, defineComponent, createVNode, Fragment, provide, useId, reactive } from "vue";
|
|
2
|
+
import { p as prefix, d as configOption, f as codeCss, s as staticTextDefault, b as allFooter, a as allToolbar } from "./config.mjs";
|
|
3
|
+
import { b as bus, E as ERROR_CATCHER, g as CATALOG_CHANGED, P as PUSH_CATALOG, h as RERENDER, B as BUILD_FINISHED, T as TASK_STATE_CHANGED, U as UPLOAD_IMAGE, a as CHANGE_CATALOG_VISIBLE, c as ON_SAVE, i as PAGE_FULL_SCREEN_CHANGED, F as FULL_SCREEN_CHANGED, j as PREVIEW_CHANGED, k as PREVIEW_ONLY_CHANGED, H as HTML_PREVIEW_CHANGED, l as CATALOG_VISIBLE_CHANGED, R as REPLACE, f as EVENT_LISTENER, C as CHANGE_FULL_SCREEN } from "./event-name.mjs";
|
|
4
4
|
import { debounce, randomId, deepMerge, deepClone } from "@vavt/util";
|
|
5
5
|
import { a as appendHandler, u as updateHandler, S as StrIcon, z as zoomMermaid } from "./dom.mjs";
|
|
6
6
|
import mediumZoom from "medium-zoom";
|
|
@@ -2334,6 +2334,13 @@ const editorProps = {
|
|
|
2334
2334
|
catalogMaxDepth: {
|
|
2335
2335
|
type: Number,
|
|
2336
2336
|
default: void 0
|
|
2337
|
+
},
|
|
2338
|
+
/**
|
|
2339
|
+
* 工具栏直接插入内容到输入框
|
|
2340
|
+
*/
|
|
2341
|
+
insertLinkDirect: {
|
|
2342
|
+
type: Boolean,
|
|
2343
|
+
default: false
|
|
2337
2344
|
}
|
|
2338
2345
|
};
|
|
2339
2346
|
const mdPreviewEmits = [
|
|
@@ -2435,10 +2442,10 @@ export {
|
|
|
2435
2442
|
CDN_IDS as C,
|
|
2436
2443
|
MdPreview as M,
|
|
2437
2444
|
ContentPreview as a,
|
|
2438
|
-
|
|
2445
|
+
editorProps as b,
|
|
2439
2446
|
contentProps as c,
|
|
2440
2447
|
useConfig as d,
|
|
2441
|
-
|
|
2448
|
+
editorEmits as e,
|
|
2442
2449
|
useCatalog as f,
|
|
2443
2450
|
useOnSave as g,
|
|
2444
2451
|
useExpansion as h,
|
package/lib/es/chunks/index3.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { defineComponent, inject, ref, watch, onMounted, createVNode, reactive,
|
|
|
2
2
|
import { p as prefix } from "./config.mjs";
|
|
3
3
|
import { a as getRelativeTop } from "./index5.mjs";
|
|
4
4
|
import { b as bus, g as CATALOG_CHANGED, G as GET_EDITOR_VIEW, P as PUSH_CATALOG, S as SEND_EDITOR_VIEW } from "./event-name.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { createSmoothScroll, debounce } from "@vavt/util";
|
|
6
6
|
const DATA_LINE_SELECTOR = `.${prefix}-preview > [data-line]`;
|
|
7
7
|
const getComputedStyleNum = (ele, key) => {
|
|
8
8
|
return +getComputedStyle(ele).getPropertyValue(key).replace("px", "");
|
package/lib/es/chunks/index4.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createVNode, defineComponent, h, inject, ref, shallowRef, reactive, com
|
|
|
2
2
|
import { p as prefix, d as configOption } from "./config.mjs";
|
|
3
3
|
import { g as getSlot } from "./vue-tsx.mjs";
|
|
4
4
|
import { k as keyMove } from "./dom.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { Upload, Trash2, X, SquareSigma, ChartArea, ListTree, CodeXml, Eye, View, Expand, Shrink, Maximize2, Minimize2, SquareCode, Save, Forward, Reply, Table, Image, Link, Code, ListTodo, ListOrdered, List, Quote, Superscript, Subscript, Heading, Strikethrough, Italic, Underline, Bold } from "lucide-vue-next";
|
|
6
6
|
import { c as getZIndexIncrement } from "./index5.mjs";
|
|
7
7
|
const Github = () => createVNode("svg", {
|
|
8
8
|
"xmlns": "http://www.w3.org/2000/svg",
|
|
@@ -22,6 +22,7 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
22
22
|
readonly inputBoxWidth: string;
|
|
23
23
|
readonly transformImgUrl: (t: string) => string | Promise<string>;
|
|
24
24
|
readonly catalogLayout: "fixed" | "flat";
|
|
25
|
+
readonly insertLinkDirect: boolean;
|
|
25
26
|
readonly modelValue: string;
|
|
26
27
|
readonly theme: import("./type").Themes;
|
|
27
28
|
readonly showCodeRowNumber: boolean;
|
|
@@ -292,6 +293,7 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
292
293
|
readonly inputBoxWidth: string;
|
|
293
294
|
readonly transformImgUrl: (t: string) => string | Promise<string>;
|
|
294
295
|
readonly catalogLayout: "fixed" | "flat";
|
|
296
|
+
readonly insertLinkDirect: boolean;
|
|
295
297
|
readonly modelValue: string;
|
|
296
298
|
readonly theme: import("./type").Themes;
|
|
297
299
|
readonly showCodeRowNumber: boolean;
|
|
@@ -598,6 +600,7 @@ declare const Editor: import("vue").DefineComponent<{
|
|
|
598
600
|
transformImgUrl: (t: string) => string | Promise<string>;
|
|
599
601
|
catalogLayout: "fixed" | "flat";
|
|
600
602
|
catalogMaxDepth: number;
|
|
603
|
+
insertLinkDirect: boolean;
|
|
601
604
|
modelValue: string;
|
|
602
605
|
theme: import("./type").Themes;
|
|
603
606
|
editorId: string;
|
|
@@ -14,6 +14,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
14
14
|
}> | undefined;
|
|
15
15
|
readonly noUploadImg: boolean | undefined;
|
|
16
16
|
readonly showToolbarName: boolean | undefined;
|
|
17
|
+
readonly insertLinkDirect: boolean | undefined;
|
|
17
18
|
readonly codeTheme: string | undefined;
|
|
18
19
|
readonly catalogVisible: boolean | undefined;
|
|
19
20
|
}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
@@ -30,6 +31,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
30
31
|
}> | undefined;
|
|
31
32
|
readonly noUploadImg: boolean | undefined;
|
|
32
33
|
readonly showToolbarName: boolean | undefined;
|
|
34
|
+
readonly insertLinkDirect: boolean | undefined;
|
|
33
35
|
readonly codeTheme: string | undefined;
|
|
34
36
|
readonly catalogVisible: boolean | undefined;
|
|
35
37
|
}> & Readonly<{}>, {
|