@ones-editor/editor 1.0.2-beta.6 → 1.0.2-beta.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/block-menu/src/block-menu/index.d.ts +1 -0
- package/@ones-editor/code-block/src/index.d.ts +2 -2
- package/@ones-editor/context-menu/src/helper/actions.d.ts +3 -1
- package/@ones-editor/context-menu/src/helper/command-items.d.ts +6 -0
- package/@ones-editor/context-menu/src/helper/utils.d.ts +4 -0
- package/@ones-editor/context-menu/src/menu/index.d.ts +5 -0
- package/@ones-editor/core/src/core/composition/clipboard/copy.d.ts +6 -3
- package/@ones-editor/core/src/core/composition/editor-input.d.ts +1 -22
- package/@ones-editor/core/src/core/input-handler/input-handler.d.ts +1 -1
- package/@ones-editor/core/src/core/types.d.ts +32 -0
- package/@ones-editor/graph-embed/src/helper/graph-base.d.ts +2 -1
- 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/ui-base/src/auto-suggest/auto-suggest.d.ts +1 -0
- package/dist/index.js +176 -175
- package/package.json +1 -1
- package/@ones-editor/context-menu/src/helper/is-clipboard-empty.d.ts +0 -1
- package/@ones-editor/context-menu/src/helper/save-as.d.ts +0 -2
- package/@ones-editor/context-menu/src/helper/selection.d.ts +0 -0
|
@@ -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';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import type { OnesEditor } from '../../../../@ones-editor/core';
|
|
1
|
+
import type { OnesEditor, EditorInputHandlers } from '../../../../@ones-editor/core';
|
|
2
|
+
export declare function handleCopyAction(editor: OnesEditor, inputHandlers: EditorInputHandlers | null, id: 'copy' | 'copy-markdown'): Promise<void>;
|
|
3
|
+
export declare function handleCutAction(editor: OnesEditor, inputHandlers: EditorInputHandlers | null): Promise<void>;
|
|
2
4
|
export declare function handlePasteAction(editor: OnesEditor): Promise<void>;
|
|
@@ -2,16 +2,22 @@ import type { OnesEditor, CommandItem } from '../../../../@ones-editor/core';
|
|
|
2
2
|
export default class ContextMenuCommandItems {
|
|
3
3
|
private editor;
|
|
4
4
|
private t;
|
|
5
|
+
private supportClipboard;
|
|
5
6
|
private isSecureContext;
|
|
7
|
+
private externalActionHandleMap;
|
|
6
8
|
constructor(editor: OnesEditor);
|
|
9
|
+
clipboardSupport(): void;
|
|
7
10
|
get isRangeCollapsed(): boolean;
|
|
8
11
|
get imageTypeCommandItems(): CommandItem[];
|
|
9
12
|
get copyTypeCommandItems(): CommandItem[];
|
|
10
13
|
get cutCommandItem(): CommandItem;
|
|
11
14
|
get stepItem(): CommandItem;
|
|
12
15
|
get selectionCommandItems(): CommandItem[];
|
|
16
|
+
destroy(): void;
|
|
17
|
+
handleActionByExternal: (item: CommandItem) => boolean;
|
|
13
18
|
getPasteCommandItem: () => Promise<CommandItem>;
|
|
14
19
|
getCommandItems: () => Promise<CommandItem[]>;
|
|
20
|
+
private getExternalContextMenuOptions;
|
|
15
21
|
private secureEnvTips;
|
|
16
22
|
private isFocusImageBlock;
|
|
17
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;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { EditorInputHandlers } from '../../../../@ones-editor/core';
|
|
1
2
|
import type { OnesEditor, OnesEditorContextMenuInstance } from '../../../../@ones-editor/core';
|
|
2
3
|
import './context-menu.scss';
|
|
3
4
|
declare class RightContextMenu implements OnesEditorContextMenuInstance {
|
|
4
5
|
private editor;
|
|
5
6
|
private contextMenu;
|
|
6
7
|
private contextMenuCommandItems;
|
|
8
|
+
contextMenuInputHandlers: EditorInputHandlers | null;
|
|
7
9
|
constructor(editor: OnesEditor);
|
|
10
|
+
destroy(): void;
|
|
8
11
|
show(event: MouseEvent): void;
|
|
12
|
+
private updateEditorCaret;
|
|
13
|
+
private initInputHandlers;
|
|
9
14
|
private handleContextMenu;
|
|
10
15
|
private isInMenu;
|
|
11
16
|
private isInEditor;
|
|
@@ -4,7 +4,10 @@ export declare function injectDocToHtmlFragment(htmlFragment: string, doc: DocOb
|
|
|
4
4
|
export declare function addMetaToDoc(editor: OnesEditor, doc: DocObject): void;
|
|
5
5
|
export type BeforeCopyCallback = (editor: OnesEditor, event: ClipboardEvent, doc: DocObject) => DocObject | boolean | undefined;
|
|
6
6
|
export declare function editorCopy(editor: OnesEditor, event: ClipboardEvent, beforeCopy?: BeforeCopyCallback): void;
|
|
7
|
-
|
|
8
|
-
copyAsMarkdown
|
|
9
|
-
|
|
7
|
+
type EditorCopyWithoutEventOptions = {
|
|
8
|
+
copyAsMarkdown?: boolean;
|
|
9
|
+
beforeCopy?: BeforeCopyCallback;
|
|
10
|
+
};
|
|
11
|
+
export declare function editorCopyWithoutEvent(editor: OnesEditor, options?: EditorCopyWithoutEventOptions): void;
|
|
10
12
|
export declare function editorCopyBlock(editor: OnesEditor, block: BlockElement): Promise<boolean>;
|
|
13
|
+
export {};
|
|
@@ -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,6 +1,6 @@
|
|
|
1
|
-
import { EditorInputCallbacks } from '../composition/editor-input';
|
|
2
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[];
|
|
@@ -82,6 +82,14 @@ export interface EmbedOptions {
|
|
|
82
82
|
insertEmbedCommandItems?: CommandItem[];
|
|
83
83
|
handleInsertEmptyEmbed?: (editor: OnesEditor, options: InsertEmptyBlockOptions) => Promise<BlockElement | null>;
|
|
84
84
|
}
|
|
85
|
+
export interface OnesContextMenuOptions {
|
|
86
|
+
id: string;
|
|
87
|
+
inserts: {
|
|
88
|
+
insertBefore?: string;
|
|
89
|
+
commands: CommandItem[];
|
|
90
|
+
};
|
|
91
|
+
handleContextMenuAction?: (editor: OnesEditor, srcBlock: BlockElement, item: CommandItem) => boolean;
|
|
92
|
+
}
|
|
85
93
|
export interface Embed {
|
|
86
94
|
embedType: string;
|
|
87
95
|
createEmbedContent: (editor: OnesEditor, content: BlockContentElement, block: DocEmbedBlock, path: BlockPath, container: ContainerElement, blockElement: BlockElement) => void;
|
|
@@ -97,6 +105,7 @@ export interface Embed {
|
|
|
97
105
|
data?: DocBlockAttributes;
|
|
98
106
|
}) => ConvertBlockResult | null;
|
|
99
107
|
toStandardDoc?: (editor: OnesEditor, blockData: DocBlock, doc: DocObject, path: BlockPath) => Promise<DocObject | undefined>;
|
|
108
|
+
getContextMenu?: (editor: OnesEditor, srcBlock: BlockElement, isSecureContext: boolean) => OnesContextMenuOptions;
|
|
100
109
|
}
|
|
101
110
|
export interface ConvertBlockResult {
|
|
102
111
|
blockData: DocBlock;
|
|
@@ -228,6 +237,7 @@ export interface Block {
|
|
|
228
237
|
blockToDoc?: (srcDoc: DocObject, srcBlockData: DocBlock, childBlockConverter: (srcDoc: DocObject, srcBlockData: DocBlock) => DocObject) => DocObject;
|
|
229
238
|
getResources?: (data: DocBlock) => string[];
|
|
230
239
|
replaceResources?: (data: DocBlock, resources: Map<string, string>) => void;
|
|
240
|
+
getContextMenu?: (editor: OnesEditor, srcBlock: BlockElement, isSecureContext: boolean) => OnesContextMenuOptions | undefined;
|
|
231
241
|
}
|
|
232
242
|
export type TextStyles = {
|
|
233
243
|
[index: string]: StyleType;
|
|
@@ -575,10 +585,32 @@ export type RemoteChangeType = 'UpdateBlockText' | 'UpdateBlockData' | 'InsertBl
|
|
|
575
585
|
export type PasteOptions = {
|
|
576
586
|
toPlainText?: boolean;
|
|
577
587
|
};
|
|
588
|
+
export interface EditorInputCallbacks {
|
|
589
|
+
onInsertText: (event: Event, text: string) => void;
|
|
590
|
+
onCompositionStart: (event: Event) => void;
|
|
591
|
+
onUpdateCompositionText: (event: Event, text: string, end: boolean) => void;
|
|
592
|
+
onKeyDown: (event: KeyboardEvent) => boolean;
|
|
593
|
+
onChanged: (action: OnesEditorUndoAction) => void;
|
|
594
|
+
onRemoteChanged: (type: RemoteChangeType) => void;
|
|
595
|
+
onFocus: () => void;
|
|
596
|
+
onBlur: () => void;
|
|
597
|
+
onPaste: (event: ClipboardEvent) => void;
|
|
598
|
+
onPasteText: (text: string, options?: PasteOptions) => void;
|
|
599
|
+
onCopy: (event: ClipboardEvent) => void;
|
|
600
|
+
onCut: (event: ClipboardEvent) => void;
|
|
601
|
+
addHandler: (handler: OnesEditorInputHandler) => void;
|
|
602
|
+
removeHandler: (handler: OnesEditorInputHandler) => void;
|
|
603
|
+
defaultInsertText: (editor: OnesEditor, containerId: string, blockIndex: number, offset: number, text: string) => void;
|
|
604
|
+
defaultHandleKeydown: (editor: OnesEditor, event: KeyboardEvent) => boolean;
|
|
605
|
+
destroy: () => void;
|
|
606
|
+
pasteDoc: (doc: DocObject) => Promise<void>;
|
|
607
|
+
forEach: (callback: (handler: OnesEditorInputHandler) => void) => void;
|
|
608
|
+
}
|
|
578
609
|
export interface OnesEditorInput {
|
|
579
610
|
readonly inputElement: HTMLInputElement;
|
|
580
611
|
destroy: () => void;
|
|
581
612
|
focus: () => void;
|
|
613
|
+
callbacks: EditorInputCallbacks;
|
|
582
614
|
handleDocumentSelectionChange: () => void;
|
|
583
615
|
handleCompositionstart: (event: CompositionEvent) => void;
|
|
584
616
|
handleCompositionend: (event: CompositionEvent) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockProperties } from '../../../../@ones-editor/core';
|
|
2
|
-
import type { OnesEditor, BlockContentElement, DocEmbedBlock, BlockElement, Logger } from '../../../../@ones-editor/core';
|
|
2
|
+
import type { OnesEditor, BlockContentElement, DocEmbedBlock, BlockElement, Logger, OnesContextMenuOptions } from '../../../../@ones-editor/core';
|
|
3
3
|
import type { GraphType, GraphEmbedBlockProperties } from './graph-block-commands';
|
|
4
4
|
export default abstract class GraphBase {
|
|
5
5
|
private graphType;
|
|
@@ -23,6 +23,7 @@ export default abstract class GraphBase {
|
|
|
23
23
|
protected emptyContent(): void;
|
|
24
24
|
protected updateSpecialClasses(embed: HTMLDivElement, code: string | undefined, err: Error | null): void;
|
|
25
25
|
editGraph(content: BlockContentElement): void;
|
|
26
|
+
getContextMenu(): OnesContextMenuOptions;
|
|
26
27
|
getBlockProperties(block: BlockElement, properties?: GraphEmbedBlockProperties): BlockProperties;
|
|
27
28
|
private hasChanged;
|
|
28
29
|
private removeStatusContent;
|