vditor 4.0.2-alpha.1 → 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 +7328 -5406
- 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 +3 -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 +61 -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/dist/ts/constants.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare abstract class Constants {
|
|
|
18
18
|
codeBlockPreview: boolean;
|
|
19
19
|
fixTermTypo: boolean;
|
|
20
20
|
footnotes: boolean;
|
|
21
|
+
imgPathAllowSpace: boolean;
|
|
21
22
|
imageCaption: boolean;
|
|
22
23
|
linkBase: string;
|
|
23
24
|
linkPrefix: string;
|
|
@@ -37,6 +38,7 @@ export declare abstract class Constants {
|
|
|
37
38
|
style: string;
|
|
38
39
|
};
|
|
39
40
|
static readonly MATH_OPTIONS: IMath;
|
|
41
|
+
static readonly PLANTUML_OPTIONS: IPlantumlOptions;
|
|
40
42
|
static readonly THEME_OPTIONS: {
|
|
41
43
|
current: string;
|
|
42
44
|
list: {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="./types" />
|
|
2
|
+
export declare class Find {
|
|
3
|
+
private vditor;
|
|
4
|
+
element: HTMLElement;
|
|
5
|
+
private query;
|
|
6
|
+
private replacement;
|
|
7
|
+
private sensitive;
|
|
8
|
+
private count;
|
|
9
|
+
private replaceRow;
|
|
10
|
+
private replaceButtons;
|
|
11
|
+
private navigationButtons;
|
|
12
|
+
private index;
|
|
13
|
+
private total;
|
|
14
|
+
private composing;
|
|
15
|
+
private timer;
|
|
16
|
+
private observer;
|
|
17
|
+
private events;
|
|
18
|
+
private highlightName;
|
|
19
|
+
private highlightStyle;
|
|
20
|
+
private sourceHighlight;
|
|
21
|
+
private sourceContent;
|
|
22
|
+
private sourceMatch;
|
|
23
|
+
private resizeObserver;
|
|
24
|
+
constructor(vditor: IVditor);
|
|
25
|
+
open(): void;
|
|
26
|
+
close(focus?: boolean): void;
|
|
27
|
+
refresh(): void;
|
|
28
|
+
find(query: string, options?: IFindOptions): IFindResult;
|
|
29
|
+
replace(query: string, replacement: string, options?: IFindOptions): number;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
private editable;
|
|
32
|
+
private replaceCurrent;
|
|
33
|
+
private move;
|
|
34
|
+
private schedule;
|
|
35
|
+
private clearHighlight;
|
|
36
|
+
private input;
|
|
37
|
+
private button;
|
|
38
|
+
private highlightSource;
|
|
39
|
+
private scrollSourceHighlight;
|
|
40
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const countMatches: (text: string, query: string, caseSensitive: boolean) => number;
|
|
2
|
+
export declare const findText: (element: HTMLElement, query: string, caseSensitive: boolean, index?: number) => IFindResult;
|
|
3
|
+
export declare const replaceText: (element: HTMLElement, query: string, replacement: string, caseSensitive: boolean, index?: number) => number;
|
|
4
|
+
export declare const displayRange: (range: Range) => Range;
|
package/dist/ts/hint/index.d.ts
CHANGED
|
@@ -5,7 +5,11 @@ export declare class Hint {
|
|
|
5
5
|
recentLanguage: string;
|
|
6
6
|
private splitChar;
|
|
7
7
|
private lastIndex;
|
|
8
|
+
private requestId;
|
|
9
|
+
private dismiss;
|
|
8
10
|
constructor(hintExtends: IHintExtend[]);
|
|
11
|
+
hide(): void;
|
|
12
|
+
destroy(): void;
|
|
9
13
|
render(vditor: IVditor): void;
|
|
10
14
|
genHTML(data: IHintData[], key: string, vditor: IVditor): void;
|
|
11
15
|
fillEmoji: (element: HTMLElement, vditor: IVditor) => void;
|
package/dist/ts/ir/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const bindCodeCopy: (menu: HTMLElement, textarea: HTMLTextAreaElement, button: HTMLElement) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const highlightRender: (hljsOption?: IHljs, element?: HTMLElement | Document, cdn?: string) => void;
|
|
1
|
+
export declare const highlightRender: (hljsOption?: IHljs, element?: HTMLElement | Document, cdn?: string, canRenderEditable?: () => boolean) => void;
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
declare global {
|
|
2
2
|
interface Window {
|
|
3
|
-
MathJax:
|
|
3
|
+
MathJax: {
|
|
4
|
+
loader?: {
|
|
5
|
+
paths: {
|
|
6
|
+
mathjax: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
startup: {
|
|
10
|
+
typeset?: boolean;
|
|
11
|
+
promise?: Promise<void>;
|
|
12
|
+
document?: {
|
|
13
|
+
clear(): void;
|
|
14
|
+
updateDocument(): void;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
tex?: {
|
|
18
|
+
macros: object;
|
|
19
|
+
};
|
|
20
|
+
getMetricsFor?(element: Element): {
|
|
21
|
+
display?: boolean;
|
|
22
|
+
};
|
|
23
|
+
tex2svgPromise?(math: string, options: {
|
|
24
|
+
display?: boolean;
|
|
25
|
+
}): Promise<Element>;
|
|
26
|
+
};
|
|
4
27
|
}
|
|
5
28
|
}
|
|
6
29
|
export declare const mathRender: (element?: (HTMLElement | Document), options?: {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const getOutlineHeadings: (contentElement: HTMLElement, assignIDs?: boolean) => HTMLElement[];
|
|
2
|
+
export declare const outlineRender: (contentElement: HTMLElement, targetElement: Element, vditorOrClick?: IVditor | ((heading: HTMLElement, event: Event) => void)) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const plantumlRender: (element?: (HTMLElement | Document), cdn?: string) => void;
|
|
1
|
+
export declare const plantumlRender: (element?: (HTMLElement | Document), cdn?: string, plantuml?: IPlantumlOptions) => void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="./types" />
|
|
2
2
|
export declare class Outline {
|
|
3
3
|
element: HTMLElement;
|
|
4
|
+
resizeElement: HTMLElement;
|
|
4
5
|
constructor(outlineLabel: string);
|
|
6
|
+
bindResize(vditor: IVditor): void;
|
|
5
7
|
render(vditor: IVditor): string;
|
|
6
8
|
toggle(vditor: IVditor, show?: boolean, focus?: boolean): void;
|
|
7
9
|
}
|
package/dist/ts/sv/index.d.ts
CHANGED
package/dist/ts/tip/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
/// <reference types="./types" />
|
|
1
2
|
export declare class Tip {
|
|
3
|
+
private tips?;
|
|
2
4
|
element: HTMLElement;
|
|
3
|
-
|
|
5
|
+
private timeoutId;
|
|
6
|
+
private positionTimeoutId;
|
|
7
|
+
private visible;
|
|
8
|
+
constructor(tips?: ICustomTips);
|
|
4
9
|
show(text: string, time?: number): void;
|
|
5
10
|
hide(): void;
|
|
6
11
|
}
|
package/dist/ts/undo/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare class Undo {
|
|
|
10
10
|
resetIcon(vditor: IVditor): void;
|
|
11
11
|
undo(vditor: IVditor): void;
|
|
12
12
|
redo(vditor: IVditor): void;
|
|
13
|
+
private flushPendingUndoStack;
|
|
13
14
|
recordFirstPosition(vditor: IVditor, event: KeyboardEvent): void;
|
|
14
15
|
addToUndoStack(vditor: IVditor): void;
|
|
15
16
|
private renderDiff;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uploadLinkToImg: (vditor: IVditor, src: string, afterRender: () => void) => void;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const addScript: (path: string, id: string) => Promise<unknown>;
|
|
1
|
+
export declare const addScript: (path: string, id: string) => Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setCodeHighlight: (code: Element, html: string) => void;
|
|
@@ -2,6 +2,6 @@ export declare const isSafari: () => boolean;
|
|
|
2
2
|
export declare const isFirefox: () => boolean;
|
|
3
3
|
export declare const accessLocalStorage: () => boolean;
|
|
4
4
|
export declare const getEventName: () => "click" | "touchstart";
|
|
5
|
-
export declare const isCtrl: (event: KeyboardEvent) => boolean;
|
|
5
|
+
export declare const isCtrl: (event: Pick<KeyboardEvent, "ctrlKey" | "metaKey">) => boolean;
|
|
6
6
|
export declare const updateHotkeyTip: (hotkey: string) => string;
|
|
7
7
|
export declare const isChrome: () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const expandHTMLTags: (root: HTMLElement, range: Range, className: string) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const fixGSKeyBackspace: (event: KeyboardEvent, vditor: IVditor, startContainer: Node) => boolean;
|
|
2
|
+
export declare const backspaceEmptyHeading: (event: KeyboardEvent, vditor: IVditor, range: Range) => boolean;
|
|
2
3
|
export declare const fixCJKPosition: (range: Range, vditor: IVditor, event: KeyboardEvent) => void;
|
|
3
4
|
export declare const fixCursorDownInlineMath: (range: Range, key: string) => void;
|
|
4
5
|
export declare const insertEmptyBlock: (vditor: IVditor, position: InsertPosition) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const bindImageDrag: (vditor: IVditor, editor: HTMLElement) => (event: DragEvent) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const notifyConfigChange: (vditor: IVditor) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const parseMarkdownTableRows: (text: string) => string[][] | null;
|
|
2
|
+
export declare const pasteIntoTable: (vditor: IVditor, html: string, markdown?: string) => boolean;
|
|
3
|
+
export declare const buildTableSelectionClipboard: (vditor: IVditor, range: Range) => {
|
|
4
|
+
html: string;
|
|
5
|
+
plain: string;
|
|
6
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getPastedLink: (vditor: IVditor, text: string) => string;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export declare const isPlainTextPaste: (html: string, editorData: string) => boolean;
|
|
1
2
|
export declare const processPasteCode: (html: string, text: string, type?: string) => string | false;
|
|
3
|
+
export declare const highlightEditableCode: (previewPanel: HTMLElement, vditor: IVditor) => void;
|
|
2
4
|
export declare const processCodeRender: (previewPanel: HTMLElement, vditor: IVditor) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const bindTableWheel: (element: HTMLElement) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const bindTaskNavigation: (vditor: IVditor, root: HTMLElement) => void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ interface IObject {
|
|
|
36
36
|
[key: string]: string;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
interface IOutlineItem {
|
|
40
|
+
text: string;
|
|
41
|
+
level: number;
|
|
42
|
+
id: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
interface ILuteNode {
|
|
40
46
|
TokensStr: () => string;
|
|
41
47
|
__internal_object__: {
|
|
@@ -216,6 +222,8 @@ declare class Lute {
|
|
|
216
222
|
|
|
217
223
|
public SetSup(enable: boolean): void;
|
|
218
224
|
|
|
225
|
+
public SetImgPathAllowSpace(enable: boolean): void;
|
|
226
|
+
|
|
219
227
|
public PutEmojis(emojis: IObject): void;
|
|
220
228
|
|
|
221
229
|
public GetEmojis(): IObject;
|
|
@@ -392,6 +400,9 @@ interface IUpload {
|
|
|
392
400
|
/** 剪切板中包含图片地址时,使用此 url 重新上传 */
|
|
393
401
|
linkToImgUrl?: string;
|
|
394
402
|
|
|
403
|
+
/** 自定义外链图片转存,返回替换 URL;空字符串保留原图,异常通过提示显示;优先于 linkToImgUrl */
|
|
404
|
+
linkToImgHandler?(url: string): string | Promise<string>;
|
|
405
|
+
|
|
395
406
|
/** 剪切板中包含图片地址时,使用此方法进行自定义 */
|
|
396
407
|
renderLinkDest?(vditor: IVditor, node: ILuteNode, entering: boolean): [string, number];
|
|
397
408
|
|
|
@@ -403,7 +414,7 @@ interface IUpload {
|
|
|
403
414
|
withCredentials?: boolean;
|
|
404
415
|
/** 请求头设置 */
|
|
405
416
|
headers?: IObject;
|
|
406
|
-
/**
|
|
417
|
+
/** 额外请求参数;linkToImgUrl 的 JSON 请求仅发送字符串值,url 字段由当前图片地址提供 */
|
|
407
418
|
extraData?: {[key: string]: string | Blob};
|
|
408
419
|
/** 是否允许多文件上传。默认值:true */
|
|
409
420
|
multiple?: boolean;
|
|
@@ -544,6 +555,8 @@ interface IMarkdownConfig {
|
|
|
544
555
|
sup?: boolean;
|
|
545
556
|
/** 支持下标 */
|
|
546
557
|
sub?: boolean;
|
|
558
|
+
/** 允许图片和链接路径包含未转义的空格。默认值: false */
|
|
559
|
+
imgPathAllowSpace?: boolean;
|
|
547
560
|
}
|
|
548
561
|
|
|
549
562
|
/** @link https://ld246.com/article/1549638745630#options-preview */
|
|
@@ -596,6 +609,15 @@ interface IPreviewActionCustom {
|
|
|
596
609
|
click: (key: string) => void;
|
|
597
610
|
}
|
|
598
611
|
|
|
612
|
+
interface IPlantumlOptions {
|
|
613
|
+
/** PlantUML 服务地址,需以 `/` 结尾。默认值: 'https://www.plantuml.com/plantuml/svg/' */
|
|
614
|
+
server?: string;
|
|
615
|
+
/** 自定义渲染。传入后不再请求 PlantUML 服务,可用于接入离线渲染引擎,实现方式参见
|
|
616
|
+
* https://github.com/Vanessa219/vditor#optionsplantuml
|
|
617
|
+
*/
|
|
618
|
+
renderer?: (code: string, element: HTMLElement) => void | Promise<void>;
|
|
619
|
+
}
|
|
620
|
+
|
|
599
621
|
interface IPreviewOptions {
|
|
600
622
|
mode: "dark" | "light";
|
|
601
623
|
customEmoji?: IObject;
|
|
@@ -615,6 +637,8 @@ interface IPreviewOptions {
|
|
|
615
637
|
theme?: IPreviewTheme;
|
|
616
638
|
icon?: "ant" | "material" | undefined;
|
|
617
639
|
render?: IPreviewRender;
|
|
640
|
+
/** @link https://github.com/Vanessa219/vditor#optionsplantuml */
|
|
641
|
+
plantuml?: IPlantumlOptions;
|
|
618
642
|
|
|
619
643
|
transform?(html: string): string;
|
|
620
644
|
|
|
@@ -679,6 +703,8 @@ interface IOutline {
|
|
|
679
703
|
enable: boolean;
|
|
680
704
|
/** 大纲位置:'left', 'right'。默认值: 'left' */
|
|
681
705
|
position: "left" | "right";
|
|
706
|
+
/** 大纲初始宽度(像素),拖拽时更新;未设置时沿用 CSS 宽度 */
|
|
707
|
+
width?: number;
|
|
682
708
|
}
|
|
683
709
|
|
|
684
710
|
interface IResize {
|
|
@@ -689,11 +715,33 @@ interface IResize {
|
|
|
689
715
|
}
|
|
690
716
|
|
|
691
717
|
/** @link https://ld246.com/article/1549638745630#options */
|
|
718
|
+
interface IEditorPreferences {
|
|
719
|
+
mode: "wysiwyg" | "ir" | "sv";
|
|
720
|
+
theme: "classic" | "dark";
|
|
721
|
+
preview: {
|
|
722
|
+
mode: "both" | "editor";
|
|
723
|
+
theme: {current: string};
|
|
724
|
+
hljs: {style: string};
|
|
725
|
+
};
|
|
726
|
+
outline: IOutline;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
interface ICustomTips {
|
|
730
|
+
show(text: string, time: number): void;
|
|
731
|
+
hide(): void;
|
|
732
|
+
}
|
|
733
|
+
|
|
692
734
|
interface IOptions {
|
|
735
|
+
/** 工具栏、模式快捷键及主题/预览 API 操作后的偏好快照;不在初始化或正文输入时调用 */
|
|
736
|
+
configChange?(preferences: IEditorPreferences): void;
|
|
737
|
+
/** 自定义消息提示;time 为 0 时保持显示,其他情况到期调用 hide */
|
|
738
|
+
tips?: ICustomTips;
|
|
693
739
|
/** RTL */
|
|
694
740
|
rtl?: boolean;
|
|
695
|
-
/**
|
|
741
|
+
/** 历史记录间隔;0 表示在每次编辑完成时同步记录,输入法候选期间不记录中间态 */
|
|
696
742
|
undoDelay?: number;
|
|
743
|
+
/** 替换前接收完整 Markdown;返回 false 可阻止替换 */
|
|
744
|
+
beforeReplace?(markdown: string): boolean | void;
|
|
697
745
|
/** 内部调试时使用 */
|
|
698
746
|
_lutePath?: string;
|
|
699
747
|
/** 编辑器初始化值。默认值: '' */
|
|
@@ -761,10 +809,14 @@ interface IOptions {
|
|
|
761
809
|
mode?: "wysiwyg" | "sv" | "ir";
|
|
762
810
|
/** @link https://ld246.com/article/1549638745630#options-preview */
|
|
763
811
|
preview?: IPreview;
|
|
812
|
+
/** @link https://github.com/Vanessa219/vditor#optionsplantuml */
|
|
813
|
+
plantuml?: IPlantumlOptions;
|
|
764
814
|
/** @link https://ld246.com/article/1549638745630#options-link */
|
|
765
815
|
link?: {
|
|
766
816
|
/** 是否打开链接地址。默认值: true */
|
|
767
817
|
isOpen?: boolean;
|
|
818
|
+
/** 编辑区链接是否按住 Ctrl(macOS 为 ⌘)点击才跳转。默认值: false */
|
|
819
|
+
ctrlClick?: boolean;
|
|
768
820
|
/** 点击链接事件 */
|
|
769
821
|
click?: (bom: Element) => void;
|
|
770
822
|
},
|
|
@@ -842,7 +894,30 @@ interface IEChart {
|
|
|
842
894
|
resize(): void;
|
|
843
895
|
}
|
|
844
896
|
|
|
897
|
+
interface IFindOptions {
|
|
898
|
+
/** 默认不区分大小写 */
|
|
899
|
+
caseSensitive?: boolean;
|
|
900
|
+
/** 从 0 开始;查找默认首项,替换时省略表示替换全部 */
|
|
901
|
+
index?: number;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
interface IFindResult {
|
|
905
|
+
total: number;
|
|
906
|
+
index: number;
|
|
907
|
+
/** 正文偏移相对当前段落、列表项、单元格或代码块,SV 偏移相对全文;range 仅在正文模式提供 */
|
|
908
|
+
match?: {start: number; end: number; range?: Range};
|
|
909
|
+
}
|
|
910
|
+
|
|
845
911
|
interface IVditor {
|
|
912
|
+
find?: {
|
|
913
|
+
element: HTMLElement;
|
|
914
|
+
open(): void;
|
|
915
|
+
close(focus?: boolean): void;
|
|
916
|
+
refresh(): void;
|
|
917
|
+
find(query: string, options?: IFindOptions): IFindResult;
|
|
918
|
+
replace(query: string, replacement: string, options?: IFindOptions): number;
|
|
919
|
+
destroy(): void;
|
|
920
|
+
};
|
|
846
921
|
element: HTMLElement;
|
|
847
922
|
options: IOptions;
|
|
848
923
|
originalInnerHTML: string;
|
|
@@ -854,6 +929,8 @@ interface IVditor {
|
|
|
854
929
|
};
|
|
855
930
|
outline: {
|
|
856
931
|
element: HTMLElement,
|
|
932
|
+
resizeElement: HTMLElement,
|
|
933
|
+
bindResize(vditor: IVditor): void,
|
|
857
934
|
render(vditor: IVditor): string,
|
|
858
935
|
toggle(vditor: IVditor, show?: boolean, focus?: boolean): void,
|
|
859
936
|
};
|
|
@@ -878,6 +955,8 @@ interface IVditor {
|
|
|
878
955
|
timeId: number
|
|
879
956
|
element: HTMLDivElement
|
|
880
957
|
recentLanguage: string
|
|
958
|
+
hide(): void;
|
|
959
|
+
destroy(): void;
|
|
881
960
|
fillEmoji(element: HTMLElement, vditor: IVditor): void
|
|
882
961
|
render(vditor: IVditor): void,
|
|
883
962
|
genHTML(data: IHintData[], key: string, vditor: IVditor): void
|
|
@@ -910,6 +989,7 @@ interface IVditor {
|
|
|
910
989
|
selectPopover: HTMLDivElement,
|
|
911
990
|
popover: HTMLDivElement,
|
|
912
991
|
afterRenderTimeoutId: number,
|
|
992
|
+
pendingUndoStack: boolean,
|
|
913
993
|
hlToolbarTimeoutId: number,
|
|
914
994
|
preventInput: boolean,
|
|
915
995
|
composingLock: boolean,
|
|
@@ -926,11 +1006,13 @@ interface IVditor {
|
|
|
926
1006
|
composingLock: boolean,
|
|
927
1007
|
preventInput: boolean,
|
|
928
1008
|
processTimeoutId: number,
|
|
1009
|
+
pendingUndoStack: boolean,
|
|
929
1010
|
hlToolbarTimeoutId: number,
|
|
930
1011
|
};
|
|
931
1012
|
sv?: {
|
|
932
1013
|
element: HTMLTextAreaElement,
|
|
933
1014
|
processTimeoutId: number,
|
|
1015
|
+
pendingUndoStack: boolean,
|
|
934
1016
|
composingLock: boolean,
|
|
935
1017
|
};
|
|
936
1018
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vditor",
|
|
3
|
-
"version": "4.0.2-alpha.
|
|
3
|
+
"version": "4.0.2-alpha.10",
|
|
4
4
|
"description": "♏ 易于使用的 Markdown 编辑器,为适配不同的应用场景而生",
|
|
5
5
|
"author": "Vanessa <v@b3log.org> (http://vanessa.b3log.org)",
|
|
6
6
|
"homepage": "https://b3log.org/vditor",
|
|
7
7
|
"jsdelivr": "dist/index.min.js",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.mjs",
|
|
9
10
|
"funding": "https://ld246.com/sponsor",
|
|
10
11
|
"files": [
|
|
11
12
|
"dist/*",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"ts-loader": "^9.5.1",
|
|
55
56
|
"typescript": "^4.9.5",
|
|
56
57
|
"typescript-eslint": "^8.9.0",
|
|
57
|
-
"webpack": "^5.
|
|
58
|
+
"webpack": "^5.104.1",
|
|
58
59
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
59
60
|
"webpack-cli": "^5.1.4",
|
|
60
61
|
"webpack-dev-server": "^5.1.0"
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.vditor-find {
|
|
2
|
+
padding: 8px;
|
|
3
|
+
border-bottom: 1px solid var(--border-color);
|
|
4
|
+
background-color: var(--toolbar-background-color);
|
|
5
|
+
color: var(--textarea-text-color);
|
|
6
|
+
max-height: 45vh;
|
|
7
|
+
overflow: auto;
|
|
8
|
+
flex-shrink: 0;
|
|
9
|
+
|
|
10
|
+
&__row {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 8px;
|
|
15
|
+
|
|
16
|
+
& + & {
|
|
17
|
+
margin-top: 8px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
> .vditor-input {
|
|
21
|
+
flex: 1 1 160px;
|
|
22
|
+
min-width: 100px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
> label {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
gap: 4px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&[hidden] {
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__source {
|
|
37
|
+
position: absolute;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
color: transparent;
|
|
41
|
+
z-index: 1;
|
|
42
|
+
|
|
43
|
+
> div {
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
mark {
|
|
48
|
+
color: var(--find-text-color);
|
|
49
|
+
background-color: var(--find-background-color);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.vditor-button {
|
|
55
|
+
border: 1px solid var(--border-color);
|
|
56
|
+
border-radius: 3px;
|
|
57
|
+
padding: 4px 8px;
|
|
58
|
+
font: inherit;
|
|
59
|
+
color: var(--toolbar-icon-color);
|
|
60
|
+
background-color: var(--panel-background-color);
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
|
|
63
|
+
&:focus-visible {
|
|
64
|
+
outline: 2px solid var(--toolbar-icon-hover-color);
|
|
65
|
+
outline-offset: 1px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
color: var(--toolbar-icon-hover-color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&:disabled {
|
|
73
|
+
opacity: 0.5;
|
|
74
|
+
cursor: default;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media (pointer: coarse) {
|
|
79
|
+
.vditor-find .vditor-button,
|
|
80
|
+
.vditor-find .vditor-input,
|
|
81
|
+
.vditor-find label {
|
|
82
|
+
min-height: 44px;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -322,6 +322,14 @@
|
|
|
322
322
|
overflow: auto;
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
p.indent--2 {
|
|
326
|
+
text-indent: 2em;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
&--indent p[data-block="0"] {
|
|
330
|
+
text-indent: 2em;
|
|
331
|
+
}
|
|
332
|
+
|
|
325
333
|
kbd {
|
|
326
334
|
display: inline-block;
|
|
327
335
|
padding: 3px 5px;
|
|
@@ -603,11 +611,26 @@
|
|
|
603
611
|
|
|
604
612
|
&-outline {
|
|
605
613
|
width: 250px;
|
|
614
|
+
max-width: calc(100% - 140px);
|
|
615
|
+
flex-shrink: 0;
|
|
606
616
|
border-right: 1px solid var(--border-color);
|
|
607
617
|
background-color: var(--panel-background-color);
|
|
608
618
|
display: none;
|
|
609
619
|
overflow: auto;
|
|
610
620
|
|
|
621
|
+
&__resize {
|
|
622
|
+
display: none;
|
|
623
|
+
width: 5px;
|
|
624
|
+
flex-shrink: 0;
|
|
625
|
+
cursor: col-resize;
|
|
626
|
+
touch-action: none;
|
|
627
|
+
|
|
628
|
+
&:hover,
|
|
629
|
+
&:focus-visible {
|
|
630
|
+
background-color: var(--border-color);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
611
634
|
&--right {
|
|
612
635
|
border-right: 0;
|
|
613
636
|
border-left: 1px solid var(--border-color);
|
|
@@ -671,6 +694,12 @@
|
|
|
671
694
|
}
|
|
672
695
|
}
|
|
673
696
|
|
|
697
|
+
@media (pointer: coarse) {
|
|
698
|
+
.vditor-outline__resize {
|
|
699
|
+
width: 16px;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
674
703
|
.vditor-reset .callout,
|
|
675
704
|
.vditor-wysiwyg blockquote.callout,
|
|
676
705
|
.vditor-ir blockquote.callout {
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
&:hover::after,
|
|
62
62
|
&:active::before,
|
|
63
63
|
&:active::after,
|
|
64
|
-
&:focus::before,
|
|
65
|
-
&:focus::after {
|
|
64
|
+
&:focus:not(.vditor-menu--disabled)::before,
|
|
65
|
+
&:focus:not(.vditor-menu--disabled)::after {
|
|
66
66
|
display: inline-block;
|
|
67
67
|
text-decoration: none;
|
|
68
68
|
animation-name: tooltip-appear;
|
|
@@ -51,6 +51,10 @@
|
|
|
51
51
|
padding-right: 0 !important;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
&__kbd-marker:not(.vditor-wysiwyg__kbd-marker--expand) {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
54
58
|
&__block {
|
|
55
59
|
// Source visibility is serialized both by Lute and by CSSStyleDeclaration.
|
|
56
60
|
// Keep the preview laid out for asynchronous wrapped line-number measurements.
|