feat: add vditor locally

This commit is contained in:
merlin
2025-11-12 14:39:23 +08:00
parent 16e8fd2d65
commit 4e21c62e26
532 changed files with 43947 additions and 38 deletions

8
public/vditor/ts/util/Options.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
/// <reference types="./types" />
export declare class Options {
options: IOptions;
private defaultOptions;
constructor(options: IOptions);
merge(): IOptions;
private mergeToolbar;
}

18
public/vditor/ts/util/RecordMedia.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
export declare class RecordMedia {
SAMPLE_RATE: number;
DEFAULT_SAMPLE_RATE: number;
isRecording: boolean;
readyFlag: boolean;
leftChannel: Float32List[];
rightChannel: Float32List[];
recordingLength: number;
recorder: ScriptProcessorNode;
constructor(e: MediaStream);
cloneChannelData(leftChannelData: Float32List, rightChannelData: Float32List): void;
startRecordingNewWavFile(): void;
stopRecording(): void;
buildWavFileBlob(): Blob;
private downSampleBuffer;
private mergeBuffers;
private writeUTFBytes;
}

2
public/vditor/ts/util/addScript.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare const addScriptSync: (path: string, id: string) => boolean;
export declare const addScript: (path: string, id: string) => Promise<unknown>;

1
public/vditor/ts/util/addStyle.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export declare const addStyle: (url: string, id: string) => void;

View File

@@ -0,0 +1 @@
export declare const code160to32: (text: string) => string;

View File

@@ -0,0 +1,7 @@
export declare const isSafari: () => boolean;
export declare const isFirefox: () => boolean;
export declare const accessLocalStorage: () => boolean;
export declare const getEventName: () => "click" | "touchstart";
export declare const isCtrl: (event: KeyboardEvent) => boolean;
export declare const updateHotkeyTip: (hotkey: string) => string;
export declare const isChrome: () => boolean;

View File

@@ -0,0 +1,9 @@
export declare const focusEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const dblclickEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const blurEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const dropEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const copyEvent: (vditor: IVditor, editorElement: HTMLElement, copy: (event: ClipboardEvent, vditor: IVditor) => void) => void;
export declare const cutEvent: (vditor: IVditor, editorElement: HTMLElement, copy: (event: ClipboardEvent, vditor: IVditor) => void) => void;
export declare const scrollCenter: (vditor: IVditor) => void;
export declare const hotkeyEvent: (vditor: IVditor, editorElement: HTMLElement) => void;
export declare const selectEvent: (vditor: IVditor, editorElement: HTMLElement) => void;

View File

@@ -0,0 +1,39 @@
export declare const fixGSKeyBackspace: (event: KeyboardEvent, vditor: IVditor, startContainer: Node) => boolean;
export declare const fixCJKPosition: (range: Range, vditor: IVditor, event: KeyboardEvent) => void;
export declare const fixCursorDownInlineMath: (range: Range, key: string) => void;
export declare const insertEmptyBlock: (vditor: IVditor, position: InsertPosition) => void;
export declare const isFirstCell: (cellElement: HTMLElement) => false | HTMLTableElement;
export declare const isLastCell: (cellElement: HTMLElement) => false | HTMLTableElement;
export declare const insertAfterBlock: (vditor: IVditor, event: KeyboardEvent, range: Range, element: HTMLElement, blockElement: HTMLElement) => boolean;
export declare const insertBeforeBlock: (vditor: IVditor, event: KeyboardEvent, range: Range, element: HTMLElement, blockElement: HTMLElement) => boolean;
export declare const listToggle: (vditor: IVditor, range: Range, type: string, cancel?: boolean) => void;
export declare const listIndent: (vditor: IVditor, liElement: HTMLElement, range: Range) => void;
export declare const listOutdent: (vditor: IVditor, liElement: HTMLElement, range: Range, topListElement: HTMLElement) => void;
export declare const setTableAlign: (tableElement: HTMLTableElement, type: string) => void;
export declare const isHrMD: (text: string) => boolean;
export declare const isHeadingMD: (text: string) => boolean;
export declare const execAfterRender: (vditor: IVditor, options?: {
enableAddUndoStack: boolean;
enableHint: boolean;
enableInput: boolean;
}) => void;
export declare const fixList: (range: Range, vditor: IVditor, pElement: HTMLElement | false, event: KeyboardEvent) => boolean;
export declare const fixTab: (vditor: IVditor, range: Range, event: KeyboardEvent) => boolean;
export declare const fixMarkdown: (event: KeyboardEvent, vditor: IVditor, pElement: HTMLElement | false, range: Range) => boolean;
export declare const insertRow: (vditor: IVditor, range: Range, cellElement: HTMLElement) => void;
export declare const insertRowAbove: (vditor: IVditor, range: Range, cellElement: HTMLElement) => void;
export declare const insertColumn: (vditor: IVditor, tableElement: HTMLTableElement, cellElement: HTMLElement, type?: InsertPosition) => void;
export declare const deleteRow: (vditor: IVditor, range: Range, cellElement: HTMLElement) => void;
export declare const deleteColumn: (vditor: IVditor, range: Range, tableElement: HTMLTableElement, cellElement: HTMLElement) => void;
export declare const fixTable: (vditor: IVditor, event: KeyboardEvent, range: Range) => boolean;
export declare const fixCodeBlock: (vditor: IVditor, event: KeyboardEvent, codeRenderElement: HTMLElement, range: Range) => boolean;
export declare const fixBlockquote: (vditor: IVditor, range: Range, event: KeyboardEvent, pElement: HTMLElement | false) => boolean;
export declare const fixTask: (vditor: IVditor, range: Range, event: KeyboardEvent) => boolean;
export declare const fixDelete: (vditor: IVditor, range: Range, event: KeyboardEvent, pElement: HTMLElement | false) => boolean;
export declare const fixHR: (range: Range) => void;
export declare const fixFirefoxArrowUpTable: (event: KeyboardEvent, blockElement: false | HTMLElement, range: Range) => boolean;
export declare const paste: (vditor: IVditor, event: (ClipboardEvent | DragEvent) & {
target: HTMLElement;
}, callback: {
pasteCode(code: string): void;
}) => Promise<void>;

3
public/vditor/ts/util/function.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare const genUUID: () => string;
export declare const getSearch: (key: string, link?: string) => string;
export declare const looseJsonParse: (text: string) => any;

View File

@@ -0,0 +1 @@
export declare const getSelectText: (editor: HTMLElement, range?: Range) => string;

9
public/vditor/ts/util/hasClosest.d.ts vendored Normal file
View File

@@ -0,0 +1,9 @@
export declare const hasTopClosestByClassName: (element: Node, className: string) => false | HTMLElement;
export declare const hasTopClosestByAttribute: (element: Node, attr: string, value: string) => false | HTMLElement;
export declare const hasTopClosestByTag: (element: Node, nodeName: string) => false | HTMLElement;
export declare const getTopList: (element: Node) => false | HTMLElement;
export declare const hasClosestByAttribute: (element: Node, attr: string, value: string) => false | HTMLElement;
export declare const hasClosestBlock: (element: Node) => false | HTMLElement;
export declare const hasClosestByMatchTag: (element: Node, nodeName: string) => false | HTMLElement;
export declare const hasClosestByClassName: (element: Node, className: string) => false | HTMLElement;
export declare const getLastNode: (node: Node) => Node;

View File

@@ -0,0 +1,2 @@
export declare const hasClosestByTag: (element: Node, nodeName: string) => false | HTMLElement;
export declare const hasClosestByHeadings: (element: Node) => false | HTMLElement;

View File

@@ -0,0 +1 @@
export declare const highlightToolbar: (vditor: IVditor) => void;

1
public/vditor/ts/util/hotKey.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export declare const matchHotKey: (hotKey: string, event: KeyboardEvent) => boolean;

1
public/vditor/ts/util/log.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export declare const log: (method: string, content: string, type: string, print: boolean) => void;

1
public/vditor/ts/util/merge.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export declare const merge: (...options: any[]) => any;

View File

@@ -0,0 +1,2 @@
export declare const processPasteCode: (html: string, text: string, type?: string) => string | false;
export declare const processCodeRender: (previewPanel: HTMLElement, vditor: IVditor) => void;

14
public/vditor/ts/util/selection.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
export declare const getEditorRange: (vditor: IVditor) => Range;
export declare const getCursorPosition: (editor: HTMLElement) => {
left: number;
top: number;
};
export declare const selectIsEditor: (editor: HTMLElement, range?: Range) => boolean;
export declare const setSelectionFocus: (range: Range) => void;
export declare const getSelectPosition: (selectElement: HTMLElement, editorElement: HTMLElement, range?: Range) => {
end: number;
start: number;
};
export declare const setSelectionByPosition: (start: number, end: number, editor: HTMLElement) => Range;
export declare const setRangeByWbr: (element: HTMLElement, range: Range) => void;
export declare const insertHTML: (html: string, vditor: IVditor) => void;

5
public/vditor/ts/util/toc.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
export declare const renderToc: (vditor: IVditor) => void;
export declare const clickToc: (event: MouseEvent & {
target: HTMLElement;
}, vditor: IVditor) => void;
export declare const keydownToc: (blockElement: HTMLElement, vditor: IVditor, event: KeyboardEvent, range: Range) => boolean;