@ones-editor/editor 1.0.6-bate.3 → 1.0.7
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/@ones-editor/code-block/src/index.d.ts +2 -2
- package/@ones-editor/context-menu/index.d.ts +3 -0
- package/@ones-editor/context-menu/package.json +8 -0
- package/@ones-editor/context-menu/src/helper/actions.d.ts +4 -0
- package/@ones-editor/context-menu/src/helper/command-items.d.ts +23 -0
- package/@ones-editor/context-menu/src/helper/utils.d.ts +4 -0
- package/@ones-editor/context-menu/src/locale/en-us.d.ts +14 -0
- package/@ones-editor/context-menu/src/locale/index.d.ts +1 -0
- package/@ones-editor/context-menu/src/locale/ja-jp.d.ts +14 -0
- package/@ones-editor/context-menu/src/locale/zh-cn.d.ts +14 -0
- package/@ones-editor/context-menu/src/menu/index.d.ts +17 -0
- package/@ones-editor/core/src/core/composition/editor-input.d.ts +1 -22
- package/@ones-editor/core/src/core/composition/index.d.ts +1 -1
- package/@ones-editor/core/src/core/doc/doc.d.ts +1 -0
- package/@ones-editor/core/src/core/editor-doc/editor-doc.d.ts +1 -0
- package/@ones-editor/core/src/core/input-handler/actions.d.ts +1 -0
- package/@ones-editor/core/src/core/input-handler/input-handler.d.ts +4 -3
- package/@ones-editor/core/src/core/keyboard/default-shortcuts.d.ts +2 -1
- package/@ones-editor/core/src/core/types.d.ts +25 -3
- package/@ones-editor/core/src/local-doc/index.d.ts +1 -0
- package/@ones-editor/core/src/utils/blob-to-string.d.ts +1 -0
- package/@ones-editor/core/src/utils/index.d.ts +1 -0
- package/@ones-editor/graph-embed/src/config/index.d.ts +1 -1
- package/@ones-editor/image-embed/src/shortcuts/index.d.ts +2 -1
- package/@ones-editor/sharedb-doc/src/doc/sharedb-client.d.ts +4 -0
- package/@ones-editor/sharedb-doc/src/doc/sharedb-doc.d.ts +1 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/toolbar/toolbar-handler.d.ts +1 -0
- package/@ones-editor/ui-base/src/auto-suggest/auto-suggest-menu.d.ts +1 -0
- package/@ones-editor/versions/src/history-doc/history-doc.d.ts +1 -0
- package/@ones-editor/versions/src/version-dialog/version-list.d.ts +1 -1
- package/dist/index.js +75342 -827
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CodeBlock, CodeLineBlock, CodeTextDecorator } from './code-block';
|
|
1
|
+
import { CodeBlock, CodeLineBlock, CodeTextDecorator, CopyCodeInputHandler } from './code-block';
|
|
2
2
|
import './locale';
|
|
3
3
|
export * from './code-block/types';
|
|
4
|
-
export { CodeBlock, CodeLineBlock, CodeTextDecorator };
|
|
4
|
+
export { CodeBlock, CodeLineBlock, CodeTextDecorator, CopyCodeInputHandler };
|
|
5
5
|
export { isCodeBlock } from './code-block/code-block-dom';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { OnesEditor } from '../../../../@ones-editor/core';
|
|
2
|
+
export declare function handleCopyAction(editor: OnesEditor): Promise<void>;
|
|
3
|
+
export declare function handleCopyMarkdownAction(editor: OnesEditor): Promise<void>;
|
|
4
|
+
export declare function handleCutAction(editor: OnesEditor): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { OnesEditor, CommandItem } from '../../../../@ones-editor/core';
|
|
2
|
+
export default class ContextMenuCommandItems {
|
|
3
|
+
private editor;
|
|
4
|
+
private t;
|
|
5
|
+
private supportClipboard;
|
|
6
|
+
private isSecureContext;
|
|
7
|
+
private externalActionHandleMap;
|
|
8
|
+
constructor(editor: OnesEditor);
|
|
9
|
+
clipboardSupport(): void;
|
|
10
|
+
get isRangeCollapsed(): boolean;
|
|
11
|
+
get imageTypeCommandItems(): CommandItem[];
|
|
12
|
+
get copyTypeCommandItems(): CommandItem[];
|
|
13
|
+
get cutCommandItem(): CommandItem;
|
|
14
|
+
get stepItem(): CommandItem;
|
|
15
|
+
get selectionCommandItems(): CommandItem[];
|
|
16
|
+
destroy(): void;
|
|
17
|
+
handleActionByExternal: (item: CommandItem) => unknown;
|
|
18
|
+
getPasteCommandItem: () => Promise<CommandItem>;
|
|
19
|
+
getCommandItems: () => Promise<CommandItem[]>;
|
|
20
|
+
private getExternalContextMenuOptions;
|
|
21
|
+
private secureEnvTips;
|
|
22
|
+
private isFocusImageBlock;
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ImageObject } from '../../../../@ones-editor/image-embed';
|
|
2
|
+
export declare function blobToString(blob: Blob): Promise<string>;
|
|
3
|
+
export declare function isClipboardEmpty(): Promise<boolean>;
|
|
4
|
+
export declare function saveAs(resourceUrl: string, imageObject: ImageObject): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
contextMenu: {
|
|
3
|
+
copyMarkdown: string;
|
|
4
|
+
paste: string;
|
|
5
|
+
copyImage: string;
|
|
6
|
+
copyImageUrl: string;
|
|
7
|
+
imageSaveAs: string;
|
|
8
|
+
newTabOpenImage: string;
|
|
9
|
+
selectBlock: string;
|
|
10
|
+
selectAll: string;
|
|
11
|
+
uneditableBlockSelected: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
contextMenu: {
|
|
3
|
+
copyMarkdown: string;
|
|
4
|
+
paste: string;
|
|
5
|
+
copyImage: string;
|
|
6
|
+
copyImageUrl: string;
|
|
7
|
+
imageSaveAs: string;
|
|
8
|
+
newTabOpenImage: string;
|
|
9
|
+
selectBlock: string;
|
|
10
|
+
selectAll: string;
|
|
11
|
+
uneditableBlockSelected: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
contextMenu: {
|
|
3
|
+
copyMarkdown: string;
|
|
4
|
+
paste: string;
|
|
5
|
+
copyImage: string;
|
|
6
|
+
copyImageUrl: string;
|
|
7
|
+
imageSaveAs: string;
|
|
8
|
+
newTabOpenImage: string;
|
|
9
|
+
selectBlock: string;
|
|
10
|
+
selectAll: string;
|
|
11
|
+
uneditableBlockSelected: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OnesEditor } from '../../../../@ones-editor/core';
|
|
2
|
+
import './context-menu.scss';
|
|
3
|
+
declare class OnesEditorContextMenu {
|
|
4
|
+
private editor;
|
|
5
|
+
private contextMenu;
|
|
6
|
+
private contextMenuCommandItems;
|
|
7
|
+
constructor(editor: OnesEditor);
|
|
8
|
+
destroy: () => void;
|
|
9
|
+
private updateEditorCaret;
|
|
10
|
+
private handleContextMenu;
|
|
11
|
+
private isInMenu;
|
|
12
|
+
private isInEditor;
|
|
13
|
+
private handleContextMenuShown;
|
|
14
|
+
private handleContextMenuClick;
|
|
15
|
+
private handleImageEmbedAction;
|
|
16
|
+
}
|
|
17
|
+
export default OnesEditorContextMenu;
|
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { OnesEditorInput, OnesEditor, OnesEditorInputHandler, OnesEditorUndoAction, RemoteChangeType, PasteOptions } from '../types';
|
|
2
|
-
import {
|
|
3
|
-
export interface EditorInputCallbacks {
|
|
4
|
-
onInsertText: (event: Event, text: string) => void;
|
|
5
|
-
onCompositionStart: (event: Event) => void;
|
|
6
|
-
onUpdateCompositionText: (event: Event, text: string, end: boolean) => void;
|
|
7
|
-
onKeyDown: (event: KeyboardEvent) => boolean;
|
|
8
|
-
onChanged: (action: OnesEditorUndoAction) => void;
|
|
9
|
-
onRemoteChanged: (type: RemoteChangeType) => void;
|
|
10
|
-
onFocus: () => void;
|
|
11
|
-
onBlur: () => void;
|
|
12
|
-
onPaste: (event: ClipboardEvent) => void;
|
|
13
|
-
onPasteText: (text: string, options?: PasteOptions) => void;
|
|
14
|
-
onCopy: (event: ClipboardEvent) => void;
|
|
15
|
-
onCut: (event: ClipboardEvent) => void;
|
|
16
|
-
addHandler: (handler: OnesEditorInputHandler) => void;
|
|
17
|
-
removeHandler: (handler: OnesEditorInputHandler) => void;
|
|
18
|
-
defaultInsertText: (editor: OnesEditor, containerId: string, blockIndex: number, offset: number, text: string) => void;
|
|
19
|
-
defaultHandleKeydown: (editor: OnesEditor, event: KeyboardEvent) => boolean;
|
|
20
|
-
destroy: () => void;
|
|
21
|
-
pasteDoc: (doc: DocObject) => Promise<void>;
|
|
22
|
-
forEach: (callback: (handler: OnesEditorInputHandler) => void) => void;
|
|
23
|
-
}
|
|
2
|
+
import type { EditorInputCallbacks } from '../types';
|
|
24
3
|
export declare class EditorInput implements OnesEditorInput {
|
|
25
4
|
editor: OnesEditor;
|
|
26
5
|
composing: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { editorCopyBlock, addMetaToDoc, injectDocToHtmlFragment } from './clipboard/copy';
|
|
1
|
+
export { editorCopyBlock, addMetaToDoc, injectDocToHtmlFragment, editorCopyWithoutEvent } from './clipboard/copy';
|
|
2
2
|
export { copyResourcesFromDoc } from './clipboard/resources/copy-resources';
|
|
@@ -213,6 +213,7 @@ export interface OnesEditorDoc extends OnesEditorDocServer {
|
|
|
213
213
|
}[]) => void;
|
|
214
214
|
localDeleteChildContainers: (containerIds: string[]) => void;
|
|
215
215
|
addResources: (resourceIds: string[]) => Promise<string[]>;
|
|
216
|
+
patchSyncResources: (resourceIds: string[]) => Promise<string[]>;
|
|
216
217
|
uploadResource: (file: File, options?: UploadResourceOptions) => Promise<UploadResourceResult>;
|
|
217
218
|
request: <T = unknown>(url: string, options?: unknown) => Promise<T>;
|
|
218
219
|
broadcastMessage: (data: unknown) => void;
|
|
@@ -36,6 +36,7 @@ export default class EditorDoc extends EventCallbacks<OnesEditorDocCallbacks> im
|
|
|
36
36
|
onError(error: Error): void;
|
|
37
37
|
uploadResource(file: File, options?: UploadResourceOptions): Promise<UploadResourceResult>;
|
|
38
38
|
addResources(resourceIds: string[]): Promise<string[]>;
|
|
39
|
+
patchSyncResources(resourceIds: string[]): Promise<string[]>;
|
|
39
40
|
buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
|
|
40
41
|
request<T = unknown>(url: string, options?: unknown): Promise<T>;
|
|
41
42
|
broadcastMessage(data: unknown): void;
|
|
@@ -4,3 +4,4 @@ export declare function editorHandleDelete(editor: OnesEditor, event: Event): bo
|
|
|
4
4
|
export declare function editorHandleBackspace(editor: OnesEditor, event: Event): boolean;
|
|
5
5
|
export declare function editorHandleInsertBr(editor: OnesEditor, event: Event): boolean;
|
|
6
6
|
export declare function editorHandlePastePlainText(editor: OnesEditor): boolean;
|
|
7
|
+
export declare function editorHandleCopyMarkdown(editor: OnesEditor): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OnesEditor, OnesEditorInputHandler, OnesEditorUndoAction, RemoteChangeType, PasteOptions } from '../types';
|
|
1
|
+
import { OnesEditor, OnesEditorDocs, OnesEditorInputHandler, OnesEditorUndoAction, RemoteChangeType, PasteOptions } from '../types';
|
|
3
2
|
import { DocObject } from '../doc';
|
|
3
|
+
import type { EditorInputCallbacks } from '../types';
|
|
4
4
|
export declare class EditorInputHandlers implements EditorInputCallbacks {
|
|
5
5
|
editor: OnesEditor;
|
|
6
6
|
handlers: OnesEditorInputHandler[];
|
|
@@ -26,7 +26,8 @@ export declare class EditorInputHandlers implements EditorInputCallbacks {
|
|
|
26
26
|
defaultInsertText(editor: OnesEditor, containerId: string, blockIndex: number, offset: number, text: string): void;
|
|
27
27
|
defaultHandleKeydown(editor: OnesEditor, event: KeyboardEvent): boolean;
|
|
28
28
|
pasteDoc(doc: DocObject): Promise<void>;
|
|
29
|
-
|
|
29
|
+
pasteDocs(docs: OnesEditorDocs, event: ClipboardEvent | null, files: File[]): Promise<void>;
|
|
30
30
|
destroy(): void;
|
|
31
31
|
forEach(cb: (handler: OnesEditorInputHandler) => void): void;
|
|
32
|
+
private getClipboardData;
|
|
32
33
|
}
|
|
@@ -66,7 +66,6 @@ export interface Box {
|
|
|
66
66
|
handleClickBox?: (editor: OnesEditor, box: BoxElement, event: MouseEvent) => void;
|
|
67
67
|
toStandardText?: (editor: OnesEditor, box: DocBox) => Promise<DocBlockText | undefined>;
|
|
68
68
|
getBoxProperties?: (editor: OnesEditor, boxElement: BoxElement) => BoxProperties;
|
|
69
|
-
getResources?: (editor: OnesEditor, box: DocBox) => string[];
|
|
70
69
|
}
|
|
71
70
|
export interface Insertion {
|
|
72
71
|
insertionType: string;
|
|
@@ -98,7 +97,6 @@ export interface Embed {
|
|
|
98
97
|
data?: DocBlockAttributes;
|
|
99
98
|
}) => ConvertBlockResult | null;
|
|
100
99
|
toStandardDoc?: (editor: OnesEditor, blockData: DocBlock, doc: DocObject, path: BlockPath) => Promise<DocObject | undefined>;
|
|
101
|
-
getResources?: (editor: OnesEditor, blockData: DocBlock) => string[];
|
|
102
100
|
}
|
|
103
101
|
export interface ConvertBlockResult {
|
|
104
102
|
blockData: DocBlock;
|
|
@@ -228,7 +226,7 @@ export interface Block {
|
|
|
228
226
|
toStandardDoc?: (editor: OnesEditor, blockData: DocBlock, doc: DocObject) => Promise<DocObject | undefined>;
|
|
229
227
|
getBlockStyles?: (editor: OnesEditor, block: BlockElement) => BlockStyles;
|
|
230
228
|
blockToDoc?: (srcDoc: DocObject, srcBlockData: DocBlock, childBlockConverter: (srcDoc: DocObject, srcBlockData: DocBlock) => DocObject) => DocObject;
|
|
231
|
-
getResources?: (
|
|
229
|
+
getResources?: (data: DocBlock) => string[];
|
|
232
230
|
replaceResources?: (data: DocBlock, resources: Map<string, string>) => void;
|
|
233
231
|
}
|
|
234
232
|
export type TextStyles = {
|
|
@@ -391,6 +389,7 @@ export interface OnesEditorOptionalOptions {
|
|
|
391
389
|
colors?: string[];
|
|
392
390
|
scrollContainer?: HTMLElement;
|
|
393
391
|
enableComments?: boolean;
|
|
392
|
+
enableContextMenu?: boolean;
|
|
394
393
|
settingsProvider?: OnesEditorSettingsProvider;
|
|
395
394
|
}
|
|
396
395
|
export interface OnesEditorOptions {
|
|
@@ -399,6 +398,7 @@ export interface OnesEditorOptions {
|
|
|
399
398
|
[index: string]: unknown;
|
|
400
399
|
};
|
|
401
400
|
enableComments?: boolean;
|
|
401
|
+
enableContextMenu?: boolean;
|
|
402
402
|
scrollContainer?: HTMLElement;
|
|
403
403
|
}
|
|
404
404
|
export interface OnesEditorComponents {
|
|
@@ -567,10 +567,32 @@ export type RemoteChangeType = 'UpdateBlockText' | 'UpdateBlockData' | 'InsertBl
|
|
|
567
567
|
export type PasteOptions = {
|
|
568
568
|
toPlainText?: boolean;
|
|
569
569
|
};
|
|
570
|
+
export interface EditorInputCallbacks {
|
|
571
|
+
onInsertText: (event: Event, text: string) => void;
|
|
572
|
+
onCompositionStart: (event: Event) => void;
|
|
573
|
+
onUpdateCompositionText: (event: Event, text: string, end: boolean) => void;
|
|
574
|
+
onKeyDown: (event: KeyboardEvent) => boolean;
|
|
575
|
+
onChanged: (action: OnesEditorUndoAction) => void;
|
|
576
|
+
onRemoteChanged: (type: RemoteChangeType) => void;
|
|
577
|
+
onFocus: () => void;
|
|
578
|
+
onBlur: () => void;
|
|
579
|
+
onPaste: (event: ClipboardEvent) => void;
|
|
580
|
+
onPasteText: (text: string, options?: PasteOptions) => void;
|
|
581
|
+
onCopy: (event: ClipboardEvent) => void;
|
|
582
|
+
onCut: (event: ClipboardEvent) => void;
|
|
583
|
+
addHandler: (handler: OnesEditorInputHandler) => void;
|
|
584
|
+
removeHandler: (handler: OnesEditorInputHandler) => void;
|
|
585
|
+
defaultInsertText: (editor: OnesEditor, containerId: string, blockIndex: number, offset: number, text: string) => void;
|
|
586
|
+
defaultHandleKeydown: (editor: OnesEditor, event: KeyboardEvent) => boolean;
|
|
587
|
+
destroy: () => void;
|
|
588
|
+
pasteDoc: (doc: DocObject) => Promise<void>;
|
|
589
|
+
forEach: (callback: (handler: OnesEditorInputHandler) => void) => void;
|
|
590
|
+
}
|
|
570
591
|
export interface OnesEditorInput {
|
|
571
592
|
readonly inputElement: HTMLInputElement;
|
|
572
593
|
destroy: () => void;
|
|
573
594
|
focus: () => void;
|
|
595
|
+
callbacks: EditorInputCallbacks;
|
|
574
596
|
handleDocumentSelectionChange: () => void;
|
|
575
597
|
handleCompositionstart: (event: CompositionEvent) => void;
|
|
576
598
|
handleCompositionend: (event: CompositionEvent) => void;
|
|
@@ -24,6 +24,7 @@ export declare class LocalDoc extends EventCallbacks<OnesEditorDocCallbacks> imp
|
|
|
24
24
|
localDeleteChildContainers(containerIds: string[]): void;
|
|
25
25
|
uploadResource(file: File, options?: UploadResourceOptions): Promise<UploadResourceResult>;
|
|
26
26
|
addResources(resourceIds: string[]): Promise<string[]>;
|
|
27
|
+
patchSyncResources(resourceIds: string[]): Promise<string[]>;
|
|
27
28
|
buildResourceUrl(src: string): string;
|
|
28
29
|
request<T>(url: string, opt?: any): Promise<T>;
|
|
29
30
|
broadcastMessage(data: unknown): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function blob2String(blob: Blob): Promise<string>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const MERMAID_SCRIPTS = "https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js";
|
|
1
|
+
export declare const MERMAID_SCRIPTS = "https://cdn.jsdelivr.net/npm/mermaid@9.0.1/dist/mermaid.min.js";
|
|
2
2
|
export declare const FLOWCHART_SCRIPTS: string[];
|
|
3
3
|
export declare const PLANTUML_PRE = "https://www.plantuml.com/plantuml/svg";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { OnesEditor, ShortcutRecords } from '../../../../@ones-editor/core';
|
|
2
|
+
import { copyImage } from './copy-image';
|
|
2
3
|
declare function deleteImage(editor: OnesEditor): true | undefined;
|
|
3
4
|
declare const ImageShortcuts: ShortcutRecords;
|
|
4
|
-
export { ImageShortcuts, deleteImage, };
|
|
5
|
+
export { ImageShortcuts, deleteImage, copyImage, };
|
|
@@ -30,7 +30,11 @@ export default class ShareDBClient {
|
|
|
30
30
|
getFileUrlByHash(uploadFileUrl: string, hash: string, name: string, size: number, headers: {
|
|
31
31
|
[index: string]: string;
|
|
32
32
|
}): Promise<any>;
|
|
33
|
+
patchSyncResourceByHash(uploadFileUrl: string, hash: string[], headers: {
|
|
34
|
+
[index: string]: string;
|
|
35
|
+
}): Promise<any[]>;
|
|
33
36
|
getFileUrlsByHashes(resourceHashes: string[]): Promise<any[]>;
|
|
37
|
+
patchSyncResourceByHashes(resourceHashes: string[]): Promise<any[]>;
|
|
34
38
|
uploadFile(url: string, file: File, headers: {
|
|
35
39
|
[index: string]: string;
|
|
36
40
|
}, onProgress: OnProgress, options?: {
|
|
@@ -76,6 +76,7 @@ export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> impl
|
|
|
76
76
|
onUpdateComment(commentId: string, local: boolean): void;
|
|
77
77
|
onCustomMessage(msg: unknown): void;
|
|
78
78
|
addResources(resourceIds: string[]): Promise<string[]>;
|
|
79
|
+
patchSyncResources(resourceIds: string[]): Promise<any[]>;
|
|
79
80
|
uploadResource(file: File, options?: UploadResourceOptions): Promise<UploadResourceResult>;
|
|
80
81
|
buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
|
|
81
82
|
request<T = unknown>(url: string, options?: unknown): Promise<T>;
|