md-editor-v3 2.7.1 → 2.7.3-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/README.md +2 -0
- package/lib/md-editor-v3.es.js +70 -123
- package/lib/md-editor-v3.umd.js +67 -67
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -571,6 +571,8 @@ Use `MdEditor.config(option: ConfigOption)` to reconfigure `renderer`.
|
|
|
571
571
|
|
|
572
572
|
## 🪡 Shortcut Key
|
|
573
573
|
|
|
574
|
+
_Pay attention: shortcut keys are only available when the textarea is focused!_
|
|
575
|
+
|
|
574
576
|
| key | function | description |
|
|
575
577
|
| --- | --- | --- |
|
|
576
578
|
| TAB | insert space | Insert space, the length eq `tabWidth`, default: 2, support multiline |
|
package/lib/md-editor-v3.es.js
CHANGED
|
@@ -584,10 +584,6 @@ const useKeyBoard = (props, context) => {
|
|
|
584
584
|
buildFinished: false,
|
|
585
585
|
html: ""
|
|
586
586
|
});
|
|
587
|
-
const initFunc = (name) => {
|
|
588
|
-
var _a, _b;
|
|
589
|
-
return ((_a = props.toolbars) == null ? void 0 : _a.includes(name)) && !((_b = props.toolbarsExclude) == null ? void 0 : _b.includes(name));
|
|
590
|
-
};
|
|
591
587
|
const keyDownHandler = (event) => {
|
|
592
588
|
if (event.target !== document.querySelector(`#${props.editorId}-textarea`)) {
|
|
593
589
|
return;
|
|
@@ -597,106 +593,76 @@ const useKeyBoard = (props, context) => {
|
|
|
597
593
|
switch (event.code) {
|
|
598
594
|
case "KeyS": {
|
|
599
595
|
if (event.shiftKey) {
|
|
600
|
-
|
|
601
|
-
bus.emit(editorId, "replace", "strikeThrough");
|
|
602
|
-
}
|
|
596
|
+
bus.emit(editorId, "replace", "strikeThrough");
|
|
603
597
|
} else {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
event.preventDefault();
|
|
607
|
-
}
|
|
598
|
+
bus.emit(editorId, ON_SAVE, props.modelValue);
|
|
599
|
+
event.preventDefault();
|
|
608
600
|
}
|
|
609
601
|
break;
|
|
610
602
|
}
|
|
611
603
|
case "KeyB": {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
event.preventDefault();
|
|
615
|
-
}
|
|
604
|
+
bus.emit(editorId, "replace", "bold");
|
|
605
|
+
event.preventDefault();
|
|
616
606
|
break;
|
|
617
607
|
}
|
|
618
608
|
case "KeyU": {
|
|
619
609
|
if (event.shiftKey) {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
event.preventDefault();
|
|
623
|
-
}
|
|
610
|
+
bus.emit(editorId, "replace", "unorderedList");
|
|
611
|
+
event.preventDefault();
|
|
624
612
|
} else {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
event.preventDefault();
|
|
628
|
-
}
|
|
613
|
+
bus.emit(editorId, "replace", "underline");
|
|
614
|
+
event.preventDefault();
|
|
629
615
|
}
|
|
630
616
|
break;
|
|
631
617
|
}
|
|
632
618
|
case "KeyI": {
|
|
633
619
|
if (event.shiftKey) {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
event.preventDefault();
|
|
637
|
-
}
|
|
620
|
+
bus.emit(editorId, "openModals", "image");
|
|
621
|
+
event.preventDefault();
|
|
638
622
|
} else {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
event.preventDefault();
|
|
642
|
-
}
|
|
623
|
+
bus.emit(editorId, "replace", "italic");
|
|
624
|
+
event.preventDefault();
|
|
643
625
|
}
|
|
644
626
|
break;
|
|
645
627
|
}
|
|
646
628
|
case "Digit1": {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
event.preventDefault();
|
|
650
|
-
}
|
|
629
|
+
bus.emit(editorId, "replace", "h1");
|
|
630
|
+
event.preventDefault();
|
|
651
631
|
break;
|
|
652
632
|
}
|
|
653
633
|
case "Digit2": {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
event.preventDefault();
|
|
657
|
-
}
|
|
634
|
+
bus.emit(editorId, "replace", "h2");
|
|
635
|
+
event.preventDefault();
|
|
658
636
|
break;
|
|
659
637
|
}
|
|
660
638
|
case "Digit3": {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
event.preventDefault();
|
|
664
|
-
}
|
|
639
|
+
bus.emit(editorId, "replace", "h3");
|
|
640
|
+
event.preventDefault();
|
|
665
641
|
break;
|
|
666
642
|
}
|
|
667
643
|
case "Digit4": {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
event.preventDefault();
|
|
671
|
-
}
|
|
644
|
+
bus.emit(editorId, "replace", "h4");
|
|
645
|
+
event.preventDefault();
|
|
672
646
|
break;
|
|
673
647
|
}
|
|
674
648
|
case "Digit5": {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
event.preventDefault();
|
|
678
|
-
}
|
|
649
|
+
bus.emit(editorId, "replace", "h5");
|
|
650
|
+
event.preventDefault();
|
|
679
651
|
break;
|
|
680
652
|
}
|
|
681
653
|
case "Digit6": {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
event.preventDefault();
|
|
685
|
-
}
|
|
654
|
+
bus.emit(editorId, "replace", "h6");
|
|
655
|
+
event.preventDefault();
|
|
686
656
|
break;
|
|
687
657
|
}
|
|
688
658
|
case "ArrowUp": {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
event.preventDefault();
|
|
692
|
-
}
|
|
659
|
+
bus.emit(editorId, "replace", "sup");
|
|
660
|
+
event.preventDefault();
|
|
693
661
|
break;
|
|
694
662
|
}
|
|
695
663
|
case "ArrowDown": {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
event.preventDefault();
|
|
699
|
-
}
|
|
664
|
+
bus.emit(editorId, "replace", "sub");
|
|
665
|
+
event.preventDefault();
|
|
700
666
|
break;
|
|
701
667
|
}
|
|
702
668
|
case "KeyQ": {
|
|
@@ -718,23 +684,17 @@ const useKeyBoard = (props, context) => {
|
|
|
718
684
|
}
|
|
719
685
|
}
|
|
720
686
|
case "KeyO": {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
event.preventDefault();
|
|
724
|
-
}
|
|
687
|
+
bus.emit(editorId, "replace", "orderedList");
|
|
688
|
+
event.preventDefault();
|
|
725
689
|
break;
|
|
726
690
|
}
|
|
727
691
|
case "KeyC": {
|
|
728
692
|
if (event.shiftKey) {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
event.preventDefault();
|
|
732
|
-
}
|
|
693
|
+
bus.emit(editorId, "replace", "code");
|
|
694
|
+
event.preventDefault();
|
|
733
695
|
} else if (event.altKey) {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
event.preventDefault();
|
|
737
|
-
}
|
|
696
|
+
bus.emit(editorId, "replace", "codeRow");
|
|
697
|
+
event.preventDefault();
|
|
738
698
|
} else {
|
|
739
699
|
event.preventDefault();
|
|
740
700
|
bus.emit(editorId, "replace", "ctrlC");
|
|
@@ -743,10 +703,8 @@ const useKeyBoard = (props, context) => {
|
|
|
743
703
|
break;
|
|
744
704
|
}
|
|
745
705
|
case "KeyL": {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
event.preventDefault();
|
|
749
|
-
}
|
|
706
|
+
bus.emit(editorId, "openModals", "link");
|
|
707
|
+
event.preventDefault();
|
|
750
708
|
break;
|
|
751
709
|
}
|
|
752
710
|
case "KeyZ": {
|
|
@@ -754,30 +712,22 @@ const useKeyBoard = (props, context) => {
|
|
|
754
712
|
return;
|
|
755
713
|
}
|
|
756
714
|
if (event.shiftKey) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
event.preventDefault();
|
|
760
|
-
}
|
|
715
|
+
bus.emit(editorId, "ctrlShiftZ");
|
|
716
|
+
event.preventDefault();
|
|
761
717
|
} else {
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
event.preventDefault();
|
|
765
|
-
}
|
|
718
|
+
bus.emit(editorId, "ctrlZ");
|
|
719
|
+
event.preventDefault();
|
|
766
720
|
}
|
|
767
721
|
break;
|
|
768
722
|
}
|
|
769
723
|
case "KeyW": {
|
|
770
724
|
if (event.key === "z") {
|
|
771
725
|
if (event.shiftKey) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
event.preventDefault();
|
|
775
|
-
}
|
|
726
|
+
bus.emit(editorId, "ctrlShiftZ");
|
|
727
|
+
event.preventDefault();
|
|
776
728
|
} else {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
event.preventDefault();
|
|
780
|
-
}
|
|
729
|
+
bus.emit(editorId, "ctrlZ");
|
|
730
|
+
event.preventDefault();
|
|
781
731
|
}
|
|
782
732
|
break;
|
|
783
733
|
} else {
|
|
@@ -786,7 +736,7 @@ const useKeyBoard = (props, context) => {
|
|
|
786
736
|
}
|
|
787
737
|
case "KeyF": {
|
|
788
738
|
if (event.shiftKey) {
|
|
789
|
-
if (
|
|
739
|
+
if (!noPrettier) {
|
|
790
740
|
bus.emit(editorId, "replace", "prettier");
|
|
791
741
|
event.preventDefault();
|
|
792
742
|
}
|
|
@@ -795,10 +745,8 @@ const useKeyBoard = (props, context) => {
|
|
|
795
745
|
}
|
|
796
746
|
case "KeyT": {
|
|
797
747
|
if (event.altKey && event.shiftKey) {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
event.preventDefault();
|
|
801
|
-
}
|
|
748
|
+
bus.emit(editorId, "replace", "table");
|
|
749
|
+
event.preventDefault();
|
|
802
750
|
}
|
|
803
751
|
break;
|
|
804
752
|
}
|
|
@@ -1734,7 +1682,6 @@ var Modals = defineComponent({
|
|
|
1734
1682
|
const useSreenfull = (props) => {
|
|
1735
1683
|
var _a, _b, _c, _d;
|
|
1736
1684
|
const editorId = inject("editorId");
|
|
1737
|
-
const previewOnly = inject("previewOnly");
|
|
1738
1685
|
let screenfull = (_b = (_a = configOption.editorExtensions) == null ? void 0 : _a.screenfull) == null ? void 0 : _b.instance;
|
|
1739
1686
|
const screenfullJs = (_d = (_c = configOption.editorExtensions) == null ? void 0 : _c.screenfull) == null ? void 0 : _d.js;
|
|
1740
1687
|
const screenfullMe = ref(false);
|
|
@@ -1774,7 +1721,7 @@ const useSreenfull = (props) => {
|
|
|
1774
1721
|
};
|
|
1775
1722
|
onMounted(() => {
|
|
1776
1723
|
onScreenfullEvent();
|
|
1777
|
-
if (!
|
|
1724
|
+
if (!screenfull) {
|
|
1778
1725
|
const screenScript = document.createElement("script");
|
|
1779
1726
|
screenScript.src = screenfullJs || screenfullUrl;
|
|
1780
1727
|
screenScript.onload = screenfullLoad;
|
|
@@ -1783,12 +1730,10 @@ const useSreenfull = (props) => {
|
|
|
1783
1730
|
}
|
|
1784
1731
|
});
|
|
1785
1732
|
onMounted(() => {
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
});
|
|
1791
|
-
}
|
|
1733
|
+
bus.on(editorId, {
|
|
1734
|
+
name: CHANGE_FULL_SCREEN,
|
|
1735
|
+
callback: fullscreenHandler
|
|
1736
|
+
});
|
|
1792
1737
|
});
|
|
1793
1738
|
return { fullscreenHandler };
|
|
1794
1739
|
};
|
|
@@ -2522,7 +2467,7 @@ var ToolBar = defineComponent({
|
|
|
2522
2467
|
return () => {
|
|
2523
2468
|
const LeftBar = splitedbar.value[0].map((barItem) => barRender(barItem));
|
|
2524
2469
|
const RightBar = splitedbar.value[1].map((barItem) => barRender(barItem));
|
|
2525
|
-
return createVNode("div", {
|
|
2470
|
+
return createVNode(Fragment, null, [props.toolbars.length > 0 && createVNode("div", {
|
|
2526
2471
|
"class": `${prefix}-toolbar-wrapper`,
|
|
2527
2472
|
"id": wrapperId
|
|
2528
2473
|
}, [createVNode("div", {
|
|
@@ -2532,7 +2477,7 @@ var ToolBar = defineComponent({
|
|
|
2532
2477
|
"ref": toolbarLeftRef
|
|
2533
2478
|
}, [LeftBar]), createVNode("div", {
|
|
2534
2479
|
"class": `${prefix}-toolbar-right`
|
|
2535
|
-
}, [RightBar])]), createVNode("input", {
|
|
2480
|
+
}, [RightBar])])]), createVNode("input", {
|
|
2536
2481
|
"ref": uploadRef,
|
|
2537
2482
|
"accept": "image/*",
|
|
2538
2483
|
"type": "file",
|
|
@@ -6052,17 +5997,17 @@ ${nextOrder}. `;
|
|
|
6052
5997
|
})));
|
|
6053
5998
|
}
|
|
6054
5999
|
});
|
|
6000
|
+
bus.on(editorId, {
|
|
6001
|
+
name: "selectTextChange",
|
|
6002
|
+
callback() {
|
|
6003
|
+
selectedText.value = getSelectionText(textAreaRef.value);
|
|
6004
|
+
}
|
|
6005
|
+
});
|
|
6055
6006
|
}
|
|
6056
6007
|
});
|
|
6057
6008
|
watch(() => props.value, () => {
|
|
6058
6009
|
selectedText.value = "";
|
|
6059
6010
|
});
|
|
6060
|
-
bus.on(editorId, {
|
|
6061
|
-
name: "selectTextChange",
|
|
6062
|
-
callback() {
|
|
6063
|
-
selectedText.value = getSelectionText(textAreaRef.value);
|
|
6064
|
-
}
|
|
6065
|
-
});
|
|
6066
6011
|
};
|
|
6067
6012
|
const useMermaid = (props) => {
|
|
6068
6013
|
const theme = inject("theme");
|
|
@@ -6144,7 +6089,7 @@ const usePasteUpload = (props, textAreaRef) => {
|
|
|
6144
6089
|
const userZoom = (props, html) => {
|
|
6145
6090
|
const editorId = inject("editorId");
|
|
6146
6091
|
const zoomHander = debounce(() => {
|
|
6147
|
-
const imgs =
|
|
6092
|
+
const imgs = document.querySelectorAll(`#${editorId}-preview img[zoom]`);
|
|
6148
6093
|
if (imgs.length === 0) {
|
|
6149
6094
|
return;
|
|
6150
6095
|
}
|
|
@@ -6157,12 +6102,14 @@ const userZoom = (props, html) => {
|
|
|
6157
6102
|
};
|
|
6158
6103
|
const useAttach = (textAreaRef) => {
|
|
6159
6104
|
const editorId = inject("editorId");
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6105
|
+
onMounted(() => {
|
|
6106
|
+
bus.on(editorId, {
|
|
6107
|
+
name: TEXTAREA_FOCUS,
|
|
6108
|
+
callback() {
|
|
6109
|
+
var _a;
|
|
6110
|
+
(_a = textAreaRef.value) == null ? void 0 : _a.focus();
|
|
6111
|
+
}
|
|
6112
|
+
});
|
|
6166
6113
|
});
|
|
6167
6114
|
};
|
|
6168
6115
|
const contentProps = () => ({
|