vditor 4.0.2-alpha.7 → 4.0.2-alpha.8
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 +69 -5
- package/dist/index.css +35 -29
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6484 -5444
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +17599 -0
- package/dist/js/graphviz/LICENSE.expat +21 -0
- package/dist/js/graphviz/LICENSE.graphviz +277 -0
- package/dist/js/graphviz/LICENSE.viz +21 -0
- package/dist/js/graphviz/README.md +10 -0
- package/dist/js/graphviz/viz.js +6 -330
- package/dist/js/lute/lute.min.js +3 -3
- package/dist/method.d.ts +2 -2
- package/dist/method.js +2017 -1903
- package/dist/method.min.js +1 -1
- package/dist/method.mjs +3243 -0
- package/dist/ts/constants.d.ts +2 -0
- package/dist/ts/ir/index.d.ts +1 -0
- package/dist/ts/markdown/mathRender.d.ts +24 -1
- package/dist/ts/markdown/outlineRender.d.ts +2 -1
- package/dist/ts/markdown/plantumlRender.d.ts +1 -1
- package/dist/ts/outline/index.d.ts +2 -0
- package/dist/ts/sv/index.d.ts +1 -0
- package/dist/ts/tip/index.d.ts +6 -1
- package/dist/ts/undo/index.d.ts +1 -0
- package/dist/ts/upload/linkToImg.d.ts +1 -0
- package/dist/ts/util/addScript.d.ts +1 -2
- package/dist/ts/util/compatibility.d.ts +1 -1
- package/dist/ts/util/expandHTMLTags.d.ts +1 -0
- package/dist/ts/util/imageDrag.d.ts +1 -0
- package/dist/ts/util/notifyConfigChange.d.ts +1 -0
- package/dist/ts/util/pairedSymbols.d.ts +5 -0
- package/dist/ts/util/pasteIntoTable.d.ts +6 -0
- package/dist/ts/util/pasteLink.d.ts +1 -0
- package/dist/ts/util/processCode.d.ts +1 -0
- package/dist/ts/util/tableWheel.d.ts +1 -0
- package/dist/ts/util/taskNavigation.d.ts +1 -0
- package/dist/ts/wysiwyg/index.d.ts +1 -0
- package/dist/types/index.d.ts +56 -1
- package/package.json +3 -2
- package/src/assets/less/_hint.less +6 -0
- package/src/assets/less/_reset.less +29 -0
- package/src/assets/less/_tooltipped.less +2 -2
- package/src/assets/less/_wysiwyg.less +4 -0
- package/src/index.ts +28 -6
- package/src/ts/constants.ts +4 -0
- package/src/ts/ir/expandMarker.ts +3 -0
- package/src/ts/ir/index.ts +11 -1
- package/src/ts/ir/process.ts +3 -0
- package/src/ts/markdown/chartRender.ts +28 -2
- package/src/ts/markdown/graphvizRender.ts +51 -39
- package/src/ts/markdown/highlightRender.ts +6 -2
- package/src/ts/markdown/mathRender.ts +26 -38
- package/src/ts/markdown/mediaRender.ts +1 -1
- package/src/ts/markdown/mermaidRender.ts +4 -3
- package/src/ts/markdown/outlineRender.ts +44 -15
- package/src/ts/markdown/plantumlRender.ts +24 -5
- package/src/ts/markdown/previewRender.ts +5 -1
- package/src/ts/markdown/setLute.ts +1 -0
- package/src/ts/outline/index.ts +72 -0
- package/src/ts/preview/index.ts +1 -1
- package/src/ts/sv/index.ts +1 -0
- package/src/ts/sv/process.ts +3 -0
- package/src/ts/tip/index.ts +25 -9
- package/src/ts/toolbar/CodeTheme.ts +2 -0
- package/src/ts/toolbar/ContentTheme.ts +2 -0
- package/src/ts/toolbar/EditMode.ts +4 -0
- package/src/ts/toolbar/Headings.ts +4 -6
- package/src/ts/toolbar/Outline.ts +2 -0
- package/src/ts/toolbar/Record.ts +5 -0
- package/src/ts/ui/initUI.ts +9 -1
- package/src/ts/ui/setPreviewMode.ts +2 -0
- package/src/ts/undo/index.ts +14 -4
- package/src/ts/upload/index.ts +1 -1
- package/src/ts/upload/linkToImg.ts +91 -0
- package/src/ts/util/Options.ts +2 -0
- package/src/ts/util/addScript.ts +15 -24
- package/src/ts/util/compatibility.ts +2 -2
- package/src/ts/util/editorCommonEvent.ts +47 -4
- package/src/ts/util/expandHTMLTags.ts +36 -0
- package/src/ts/util/fixBrowserBehavior.ts +29 -61
- package/src/ts/util/imageDrag.ts +108 -0
- package/src/ts/util/notifyConfigChange.ts +16 -0
- package/src/ts/util/pairedSymbols.ts +109 -0
- package/src/ts/util/pasteIntoTable.ts +136 -0
- package/src/ts/util/pasteLink.ts +51 -0
- package/src/ts/util/processCode.ts +33 -8
- package/src/ts/util/selection.ts +11 -2
- package/src/ts/util/tableWheel.ts +31 -0
- package/src/ts/util/taskNavigation.ts +113 -0
- package/src/ts/util/toc.ts +9 -3
- package/src/ts/wysiwyg/afterRenderEvent.ts +3 -0
- package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +5 -4
- package/src/ts/wysiwyg/index.ts +17 -6
- package/src/ts/wysiwyg/setHeading.ts +4 -0
- package/dist/js/graphviz/full.render.js +0 -90
package/src/ts/util/selection.ts
CHANGED
|
@@ -271,8 +271,17 @@ export const insertHTML = (html: string, vditor: IVditor) => {
|
|
|
271
271
|
vditor[vditor.currentMode].element.insertAdjacentHTML("beforeend", pasteElement.innerHTML);
|
|
272
272
|
} else {
|
|
273
273
|
const liElement = hasClosestByMatchTag(range.startContainer, "LI");
|
|
274
|
-
if (liElement && pasteElement.firstElementChild.tagName === "UL"
|
|
275
|
-
|
|
274
|
+
if (liElement && pasteElement.childElementCount === 1 && (pasteElement.firstElementChild.tagName === "UL" ||
|
|
275
|
+
pasteElement.firstElementChild.tagName === "OL")) {
|
|
276
|
+
const before = range.cloneRange();
|
|
277
|
+
before.selectNodeContents(liElement);
|
|
278
|
+
before.setEnd(range.startContainer, range.startOffset);
|
|
279
|
+
const prefix = document.createElement("div");
|
|
280
|
+
prefix.appendChild(before.cloneContents());
|
|
281
|
+
prefix.querySelectorAll(".vditor-ir__marker, input").forEach(item => item.remove());
|
|
282
|
+
const atStart = prefix.textContent.replace(/\u200b/g, "").trim() === "" &&
|
|
283
|
+
!prefix.querySelector("img, video, audio, iframe, ul, ol, table, pre");
|
|
284
|
+
liElement.insertAdjacentHTML(atStart ? "beforebegin" : "afterend", pasteElement.firstElementChild.innerHTML);
|
|
276
285
|
} else {
|
|
277
286
|
blockElement.insertAdjacentHTML("afterend", pasteElement.innerHTML);
|
|
278
287
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const boundElements = new WeakSet<HTMLElement>();
|
|
2
|
+
|
|
3
|
+
export const bindTableWheel = (element: HTMLElement) => {
|
|
4
|
+
if (boundElements.has(element)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
boundElements.add(element);
|
|
8
|
+
element.addEventListener("wheel", (event: WheelEvent) => {
|
|
9
|
+
if (!event.cancelable || event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey ||
|
|
10
|
+
event.deltaX !== 0 || event.deltaY === 0) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const target = event.target instanceof Element ? event.target : (event.target as Node).parentElement;
|
|
14
|
+
const table = target?.closest("table");
|
|
15
|
+
if (!table || !element.contains(table) || table.scrollWidth <= table.clientWidth) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const style = getComputedStyle(table);
|
|
19
|
+
if (!/auto|scroll/.test(style.overflowX)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const scale = event.deltaMode === WheelEvent.DOM_DELTA_LINE ? (parseFloat(style.lineHeight) || 20) :
|
|
23
|
+
event.deltaMode === WheelEvent.DOM_DELTA_PAGE ? table.clientWidth : 1;
|
|
24
|
+
const before = table.scrollLeft;
|
|
25
|
+
table.scrollLeft += event.deltaY * scale * (style.direction === "rtl" ? -1 : 1);
|
|
26
|
+
// 到达横向边界后交给页面滚动,避免滚轮被表格持续截留。
|
|
27
|
+
if (table.scrollLeft !== before) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
}
|
|
30
|
+
}, {passive: false});
|
|
31
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const getTaskPrefix = (root: HTMLElement, range: Range) => {
|
|
2
|
+
const element = range.startContainer.nodeType === Node.ELEMENT_NODE ?
|
|
3
|
+
range.startContainer as Element : range.startContainer.parentElement;
|
|
4
|
+
const item = element?.closest("li.vditor-task");
|
|
5
|
+
const firstElement = item?.firstElementChild;
|
|
6
|
+
const checkbox = firstElement?.tagName === "P" ? firstElement.firstElementChild : firstElement;
|
|
7
|
+
if (!item || !root.contains(item) || checkbox?.tagName !== "INPUT" ||
|
|
8
|
+
checkbox.getAttribute("type") !== "checkbox") {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const body = document.createRange();
|
|
12
|
+
let text = checkbox.nextSibling;
|
|
13
|
+
while (text?.nodeType === Node.TEXT_NODE && text.textContent === "") {
|
|
14
|
+
text = text.nextSibling;
|
|
15
|
+
}
|
|
16
|
+
if (text?.nodeType === Node.TEXT_NODE && text.textContent === " " && text.nextSibling &&
|
|
17
|
+
!(text.nextSibling instanceof Element && text.nextSibling.matches("ul, ol"))) {
|
|
18
|
+
body.selectNodeContents(text.nextSibling);
|
|
19
|
+
} else if (text?.nodeType === Node.TEXT_NODE) {
|
|
20
|
+
body.setStart(text, text.textContent.startsWith(" ") ? 1 : 0);
|
|
21
|
+
} else if (text) {
|
|
22
|
+
body.selectNodeContents(text);
|
|
23
|
+
} else {
|
|
24
|
+
body.setStartAfter(checkbox);
|
|
25
|
+
}
|
|
26
|
+
body.collapse(true);
|
|
27
|
+
if (range.compareBoundaryPoints(Range.START_TO_START, body) < 0) {
|
|
28
|
+
return {item, body};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const skipTaskPrefix = (root: HTMLElement, event: KeyboardEvent) => {
|
|
33
|
+
const selection = window.getSelection();
|
|
34
|
+
if (document.activeElement !== root || root.getAttribute("contenteditable") !== "true" ||
|
|
35
|
+
!selection?.isCollapsed || !selection.rangeCount || !root.contains(selection.anchorNode)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
let prefix = getTaskPrefix(root, selection.getRangeAt(0));
|
|
39
|
+
if (!prefix) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const body = prefix.body;
|
|
43
|
+
const item = prefix.item;
|
|
44
|
+
const backwardKey = getComputedStyle(prefix.item).direction === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
45
|
+
if (event.key !== backwardKey || typeof selection.modify !== "function") {
|
|
46
|
+
selection.removeAllRanges();
|
|
47
|
+
selection.addRange(body);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 复选框附近可能有多个等价的 DOM 边界,继续沿浏览器原生方向移动到正文。
|
|
52
|
+
const visited = new Map<Node, Set<number>>();
|
|
53
|
+
while (prefix) {
|
|
54
|
+
const node = selection.anchorNode;
|
|
55
|
+
const offset = selection.anchorOffset;
|
|
56
|
+
const offsets = visited.get(node) || new Set<number>();
|
|
57
|
+
if (offsets.has(offset)) {
|
|
58
|
+
selection.removeAllRanges();
|
|
59
|
+
selection.addRange(body);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
offsets.add(offset);
|
|
63
|
+
visited.set(node, offsets);
|
|
64
|
+
selection.modify("move", event.key === "ArrowLeft" ? "left" : "right", "character");
|
|
65
|
+
if (!selection.rangeCount || !root.contains(selection.anchorNode)) {
|
|
66
|
+
selection.removeAllRanges();
|
|
67
|
+
selection.addRange(body);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
prefix = getTaskPrefix(root, selection.getRangeAt(0));
|
|
71
|
+
if (prefix && prefix.item !== item) {
|
|
72
|
+
selection.removeAllRanges();
|
|
73
|
+
selection.addRange(prefix.body);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const bindTaskNavigation = (vditor: IVditor, root: HTMLElement) => {
|
|
80
|
+
let navigation: KeyboardEvent;
|
|
81
|
+
let timeout: number;
|
|
82
|
+
root.addEventListener("compositionstart", () => {
|
|
83
|
+
clearTimeout(timeout);
|
|
84
|
+
navigation = undefined;
|
|
85
|
+
});
|
|
86
|
+
root.addEventListener("keydown", event => {
|
|
87
|
+
clearTimeout(timeout);
|
|
88
|
+
navigation = undefined;
|
|
89
|
+
if (vditor.currentMode === "sv" || vditor[vditor.currentMode].composingLock || event.isComposing ||
|
|
90
|
+
event.shiftKey || event.ctrlKey || event.metaKey ||
|
|
91
|
+
event.altKey || (event.key !== "ArrowLeft" && event.key !== "ArrowRight") ||
|
|
92
|
+
!window.getSelection()?.isCollapsed) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
navigation = event;
|
|
96
|
+
// 等待默认光标移动,按住方向键时每次重复也会跳过任务标记。
|
|
97
|
+
timeout = window.setTimeout(() => {
|
|
98
|
+
if (navigation === event && !event.defaultPrevented) {
|
|
99
|
+
skipTaskPrefix(root, event);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}, true);
|
|
103
|
+
root.addEventListener("keyup", event => {
|
|
104
|
+
if (navigation?.key === event.key) {
|
|
105
|
+
clearTimeout(timeout);
|
|
106
|
+
if (!navigation.defaultPrevented && !event.isComposing && !event.shiftKey && !event.ctrlKey &&
|
|
107
|
+
!event.metaKey && !event.altKey) {
|
|
108
|
+
skipTaskPrefix(root, event);
|
|
109
|
+
}
|
|
110
|
+
navigation = undefined;
|
|
111
|
+
}
|
|
112
|
+
}, true);
|
|
113
|
+
};
|
package/src/ts/util/toc.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {mathRender} from "../markdown/mathRender";
|
|
2
2
|
import {execAfterRender, insertAfterBlock, insertBeforeBlock} from "./fixBrowserBehavior";
|
|
3
|
-
import {hasClosestByClassName
|
|
4
|
-
import {getSelectPosition} from "./selection";
|
|
3
|
+
import {hasClosestByClassName} from "./hasClosest";
|
|
4
|
+
import {getSelectPosition, setSelectionFocus} from "./selection";
|
|
5
5
|
|
|
6
6
|
export const renderToc = (vditor: IVditor) => {
|
|
7
7
|
if (vditor.currentMode === "sv") {
|
|
@@ -22,10 +22,16 @@ export const renderToc = (vditor: IVditor) => {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const clickToc = (event: MouseEvent & { target: HTMLElement }, vditor: IVditor) => {
|
|
25
|
-
const spanElement =
|
|
25
|
+
const spanElement = event.target.closest<HTMLElement>("[data-target-id]");
|
|
26
26
|
if (spanElement && hasClosestByClassName(spanElement, "vditor-toc")) {
|
|
27
27
|
const headingElement = vditor[vditor.currentMode].element.querySelector("#" + spanElement.getAttribute("data-target-id")) as HTMLElement;
|
|
28
28
|
if (headingElement) {
|
|
29
|
+
const editorElement = vditor[vditor.currentMode].element;
|
|
30
|
+
const range = editorElement.ownerDocument.createRange();
|
|
31
|
+
range.selectNodeContents(headingElement);
|
|
32
|
+
range.collapse(true);
|
|
33
|
+
editorElement.focus({preventScroll: true});
|
|
34
|
+
setSelectionFocus(range);
|
|
29
35
|
if (vditor.options.height === "auto") {
|
|
30
36
|
let windowScrollY = headingElement.offsetTop + vditor.element.offsetTop;
|
|
31
37
|
if (!vditor.options.toolbarConfig.pin) {
|
|
@@ -7,6 +7,7 @@ export const afterRenderEvent = (vditor: IVditor, options = {
|
|
|
7
7
|
enableHint: false,
|
|
8
8
|
enableInput: true,
|
|
9
9
|
}) => {
|
|
10
|
+
vditor.wysiwyg.pendingUndoStack = options.enableAddUndoStack && vditor.options.undoDelay !== 0;
|
|
10
11
|
renderImageCaptions(vditor.wysiwyg.element, "wysiwyg", vditor.options.preview.markdown.imageCaption);
|
|
11
12
|
if (options.enableAddUndoStack && vditor.options.undoDelay === 0) {
|
|
12
13
|
vditor.undo.addToUndoStack(vditor);
|
|
@@ -16,6 +17,8 @@ export const afterRenderEvent = (vditor: IVditor, options = {
|
|
|
16
17
|
}
|
|
17
18
|
clearTimeout(vditor.wysiwyg.afterRenderTimeoutId);
|
|
18
19
|
vditor.wysiwyg.afterRenderTimeoutId = window.setTimeout(() => {
|
|
20
|
+
vditor.wysiwyg.afterRenderTimeoutId = 0;
|
|
21
|
+
vditor.wysiwyg.pendingUndoStack = false;
|
|
19
22
|
if (vditor.wysiwyg.composingLock) {
|
|
20
23
|
return;
|
|
21
24
|
}
|
|
@@ -34,6 +34,7 @@ import {removeBlockElement} from "./processKeydown";
|
|
|
34
34
|
import {renderToc} from "../util/toc";
|
|
35
35
|
import {getMarkdown} from "../markdown/getMarkdown";
|
|
36
36
|
import {renderImageCaptions} from "../markdown/imageCaptionRender";
|
|
37
|
+
import {expandHTMLTags} from "../util/expandHTMLTags";
|
|
37
38
|
|
|
38
39
|
export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
|
|
39
40
|
clearTimeout(vditor.wysiwyg.hlToolbarTimeoutId);
|
|
@@ -51,6 +52,10 @@ export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
|
|
|
51
52
|
enableToolbar(vditor.toolbar.elements, Constants.EDIT_TOOLBARS);
|
|
52
53
|
|
|
53
54
|
const range = getSelection().getRangeAt(0);
|
|
55
|
+
vditor.wysiwyg.element.querySelectorAll(".vditor-wysiwyg__kbd-marker--expand").forEach(element => {
|
|
56
|
+
element.classList.remove("vditor-wysiwyg__kbd-marker--expand");
|
|
57
|
+
});
|
|
58
|
+
expandHTMLTags(vditor.wysiwyg.element, range, "vditor-wysiwyg__kbd-marker--expand");
|
|
54
59
|
let typeElement = range.startContainer as HTMLElement;
|
|
55
60
|
if (range.startContainer.nodeType === 3) {
|
|
56
61
|
typeElement = range.startContainer.parentElement;
|
|
@@ -226,8 +231,6 @@ export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
|
|
|
226
231
|
|
|
227
232
|
// table popover
|
|
228
233
|
if (tableElement) {
|
|
229
|
-
const lang: keyof II18n | "" = vditor.options.lang;
|
|
230
|
-
const options: IOptions = vditor.options;
|
|
231
234
|
vditor.wysiwyg.popover.innerHTML = "";
|
|
232
235
|
const updateTable = () => {
|
|
233
236
|
const oldRow = tableElement.rows.length;
|
|
@@ -566,8 +569,6 @@ export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
|
|
|
566
569
|
// footnote popover
|
|
567
570
|
const footnotesRefElement = hasClosestByAttribute(typeElement, "data-type", "footnotes-ref");
|
|
568
571
|
if (footnotesRefElement) {
|
|
569
|
-
const lang: keyof II18n | "" = vditor.options.lang;
|
|
570
|
-
const options: IOptions = vditor.options;
|
|
571
572
|
vditor.wysiwyg.popover.innerHTML = "";
|
|
572
573
|
|
|
573
574
|
const inputWrap = document.createElement("span");
|
package/src/ts/wysiwyg/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
selectEvent,
|
|
12
12
|
} from "../util/editorCommonEvent";
|
|
13
13
|
import {isHeadingMD, isHrMD, paste} from "../util/fixBrowserBehavior";
|
|
14
|
+
import {buildTableSelectionClipboard} from "../util/pasteIntoTable";
|
|
14
15
|
import {
|
|
15
16
|
hasClosestBlock, hasClosestByAttribute,
|
|
16
17
|
hasClosestByClassName, hasClosestByMatchTag,
|
|
@@ -36,6 +37,7 @@ class WYSIWYG {
|
|
|
36
37
|
public popover: HTMLDivElement;
|
|
37
38
|
public selectPopover: HTMLDivElement;
|
|
38
39
|
public afterRenderTimeoutId: number;
|
|
40
|
+
public pendingUndoStack = false;
|
|
39
41
|
public hlToolbarTimeoutId: number;
|
|
40
42
|
public preventInput: boolean;
|
|
41
43
|
public composingLock = false;
|
|
@@ -236,6 +238,13 @@ class WYSIWYG {
|
|
|
236
238
|
return;
|
|
237
239
|
}
|
|
238
240
|
|
|
241
|
+
const tableClip = buildTableSelectionClipboard(vditor, range);
|
|
242
|
+
if (tableClip) {
|
|
243
|
+
event.clipboardData.setData("text/html", tableClip.html);
|
|
244
|
+
event.clipboardData.setData("text/plain", tableClip.plain);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
239
248
|
const tempElement = document.createElement("div");
|
|
240
249
|
tempElement.appendChild(range.cloneContents());
|
|
241
250
|
|
|
@@ -441,13 +450,15 @@ class WYSIWYG {
|
|
|
441
450
|
// 打开链接
|
|
442
451
|
const a = hasClosestByMatchTag(event.target, "A");
|
|
443
452
|
if (a) {
|
|
444
|
-
if (vditor.options.link.click) {
|
|
445
|
-
vditor.options.link.click(a);
|
|
446
|
-
} else if (vditor.options.link.isOpen) {
|
|
447
|
-
window.open(a.getAttribute("href"));
|
|
448
|
-
}
|
|
449
453
|
event.preventDefault();
|
|
450
|
-
|
|
454
|
+
if (!vditor.options.link.ctrlClick || isCtrl(event)) {
|
|
455
|
+
if (vditor.options.link.click) {
|
|
456
|
+
vditor.options.link.click(a);
|
|
457
|
+
} else if (vditor.options.link.isOpen) {
|
|
458
|
+
window.open(a.getAttribute("href"));
|
|
459
|
+
}
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
451
462
|
}
|
|
452
463
|
|
|
453
464
|
const range = getEditorRange(vditor);
|
|
@@ -121,6 +121,10 @@ export const setHeading = (vditor: IVditor, tagName: string) => {
|
|
|
121
121
|
} else {
|
|
122
122
|
replaceBlockElement(blockElement, tagName);
|
|
123
123
|
}
|
|
124
|
+
const headingElement = wbrElement.closest(tagName);
|
|
125
|
+
if (headingElement && (headingElement.textContent.includes("\n") || headingElement.querySelector("br"))) {
|
|
126
|
+
headingElement.outerHTML = vditor.lute.SpinVditorDOM(headingElement.outerHTML);
|
|
127
|
+
}
|
|
124
128
|
setRangeByWbr(vditor.wysiwyg.element, range);
|
|
125
129
|
renderToc(vditor);
|
|
126
130
|
}
|