vditor 4.0.2-alpha.0 → 4.0.2-alpha.10
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 +75 -5
- package/dist/index.css +108 -29
- package/dist/index.d.ts +5 -0
- package/dist/index.js +7338 -5352
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +18244 -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/i18n/de_DE.js +6 -0
- package/dist/js/i18n/en_US.js +6 -0
- package/dist/js/i18n/es_ES.js +6 -0
- package/dist/js/i18n/fr_FR.js +6 -0
- package/dist/js/i18n/ja_JP.js +6 -0
- package/dist/js/i18n/ko_KR.js +6 -0
- package/dist/js/i18n/pt_BR.js +6 -0
- package/dist/js/i18n/ru_RU.js +6 -0
- package/dist/js/i18n/sv_SE.js +6 -0
- package/dist/js/i18n/vi_VN.js +6 -0
- package/dist/js/i18n/zh_CN.js +6 -0
- package/dist/js/i18n/zh_TW.js +6 -0
- package/dist/js/icons/LICENSE-lucide.txt +46 -0
- package/dist/js/icons/ant.js +6 -0
- package/dist/js/icons/material.js +6 -0
- package/dist/js/lute/lute.min.js +21 -19
- package/dist/method.d.ts +3 -3
- package/dist/method.js +2125 -1847
- package/dist/method.min.js +1 -1
- package/dist/method.mjs +3243 -0
- package/dist/ts/constants.d.ts +2 -0
- package/dist/ts/find/index.d.ts +40 -0
- package/dist/ts/find/text.d.ts +4 -0
- package/dist/ts/hint/index.d.ts +4 -0
- package/dist/ts/ir/index.d.ts +1 -0
- package/dist/ts/markdown/codeCopy.d.ts +1 -0
- package/dist/ts/markdown/highlightRender.d.ts +1 -1
- 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/toolbar/Find.d.ts +5 -0
- 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/codeDOM.d.ts +2 -0
- package/dist/ts/util/codeSelection.d.ts +1 -0
- package/dist/ts/util/compatibility.d.ts +1 -1
- package/dist/ts/util/expandHTMLTags.d.ts +1 -0
- package/dist/ts/util/fixBrowserBehavior.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 +2 -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 +84 -2
- package/package.json +4 -2
- package/src/assets/less/_find.less +84 -0
- 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/assets/less/index.less +3 -0
- package/src/index.ts +49 -6
- package/src/ts/constants.ts +4 -0
- package/src/ts/find/index.ts +310 -0
- package/src/ts/find/text.ts +208 -0
- package/src/ts/hint/index.ts +31 -8
- package/src/ts/ir/expandMarker.ts +3 -0
- package/src/ts/ir/index.ts +16 -3
- package/src/ts/ir/process.ts +7 -1
- package/src/ts/ir/processKeydown.ts +5 -0
- package/src/ts/markdown/chartRender.ts +28 -2
- package/src/ts/markdown/codeCopy.ts +41 -0
- package/src/ts/markdown/codeRender.ts +19 -8
- package/src/ts/markdown/graphvizRender.ts +51 -39
- package/src/ts/markdown/highlightRender.ts +25 -12
- 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 +10 -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 +7 -1
- 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 +5 -0
- package/src/ts/toolbar/Find.ts +12 -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/toolbar/index.ts +5 -1
- package/src/ts/toolbar/setToolbar.ts +1 -1
- package/src/ts/ui/initUI.ts +10 -1
- package/src/ts/ui/setPreviewMode.ts +2 -0
- package/src/ts/undo/index.ts +41 -9
- package/src/ts/upload/index.ts +1 -1
- package/src/ts/upload/linkToImg.ts +91 -0
- package/src/ts/util/Options.ts +9 -0
- package/src/ts/util/addScript.ts +15 -24
- package/src/ts/util/codeDOM.ts +21 -0
- package/src/ts/util/codeSelection.ts +37 -0
- package/src/ts/util/compatibility.ts +2 -2
- package/src/ts/util/editorCommonEvent.ts +48 -5
- package/src/ts/util/expandHTMLTags.ts +36 -0
- package/src/ts/util/fixBrowserBehavior.ts +124 -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 +46 -9
- 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 +7 -1
- package/src/ts/wysiwyg/highlightToolbarWYSIWYG.ts +6 -5
- package/src/ts/wysiwyg/index.ts +20 -6
- package/src/ts/wysiwyg/processKeydown.ts +5 -0
- package/src/ts/wysiwyg/setHeading.ts +4 -0
- package/dist/js/graphviz/full.render.js +0 -90
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
|
|
|
@@ -327,6 +336,9 @@ class WYSIWYG {
|
|
|
327
336
|
input(vditor, getSelection().getRangeAt(0).cloneRange(), event);
|
|
328
337
|
}
|
|
329
338
|
this.composingLock = false;
|
|
339
|
+
if (vditor.options.undoDelay === 0 && !isFirefox()) {
|
|
340
|
+
vditor.undo.addToUndoStack(vditor);
|
|
341
|
+
}
|
|
330
342
|
});
|
|
331
343
|
|
|
332
344
|
this.element.addEventListener("input", (event: InputEvent) => {
|
|
@@ -438,13 +450,15 @@ class WYSIWYG {
|
|
|
438
450
|
// 打开链接
|
|
439
451
|
const a = hasClosestByMatchTag(event.target, "A");
|
|
440
452
|
if (a) {
|
|
441
|
-
if (vditor.options.link.click) {
|
|
442
|
-
vditor.options.link.click(a);
|
|
443
|
-
} else if (vditor.options.link.isOpen) {
|
|
444
|
-
window.open(a.getAttribute("href"));
|
|
445
|
-
}
|
|
446
453
|
event.preventDefault();
|
|
447
|
-
|
|
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
|
+
}
|
|
448
462
|
}
|
|
449
463
|
|
|
450
464
|
const range = getEditorRange(vditor);
|
|
@@ -2,6 +2,7 @@ import {Constants} from "../constants";
|
|
|
2
2
|
import {isCtrl, isFirefox} from "../util/compatibility";
|
|
3
3
|
import {scrollCenter} from "../util/editorCommonEvent";
|
|
4
4
|
import {
|
|
5
|
+
backspaceEmptyHeading,
|
|
5
6
|
fixBlockquote, fixCJKPosition,
|
|
6
7
|
fixCodeBlock, fixCursorDownInlineMath, fixDelete, fixFirefoxArrowUpTable, fixGSKeyBackspace, fixHR,
|
|
7
8
|
fixList,
|
|
@@ -84,6 +85,10 @@ export const processKeydown = (vditor: IVditor, event: KeyboardEvent) => {
|
|
|
84
85
|
const range = getEditorRange(vditor);
|
|
85
86
|
const startContainer = range.startContainer;
|
|
86
87
|
|
|
88
|
+
if (backspaceEmptyHeading(event, vditor, range)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
87
92
|
// Android 输入法的编辑面板无法在 contenteditable 中正确处理方向键和 End
|
|
88
93
|
if (fixAndroidCursor(vditor, range, event)) {
|
|
89
94
|
return true;
|
|
@@ -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
|
}
|