@ones-editor/editor 1.0.1 → 1.0.2-beta.2
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/context-menu/package.json +8 -0
- package/@ones-editor/context-menu/src/helper/actions.d.ts +2 -0
- package/@ones-editor/context-menu/src/helper/command-items.d.ts +17 -0
- package/@ones-editor/context-menu/src/helper/is-clipboard-empty.d.ts +1 -0
- package/@ones-editor/context-menu/src/helper/save-as.d.ts +2 -0
- package/@ones-editor/context-menu/src/helper/selection.d.ts +0 -0
- package/@ones-editor/context-menu/src/index.d.ts +3 -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/clipboard/copy.d.ts +3 -1
- package/@ones-editor/core/src/core/composition/index.d.ts +1 -1
- package/@ones-editor/core/src/core/doc/doc.d.ts +0 -1
- package/@ones-editor/core/src/core/editor-doc/editor-doc.d.ts +0 -1
- package/@ones-editor/core/src/core/index.d.ts +1 -0
- package/@ones-editor/core/src/core/input-handler/input-handler.d.ts +2 -2
- package/@ones-editor/core/src/core/types.d.ts +11 -0
- package/@ones-editor/core/src/local-doc/index.d.ts +0 -1
- package/@ones-editor/image-embed/src/shortcuts/index.d.ts +2 -1
- package/@ones-editor/mathjax/src/mathjax/convert.d.ts +0 -9
- package/@ones-editor/mathjax/src/mathjax-box/mathjax-editor.d.ts +3 -3
- package/@ones-editor/sharedb-doc/src/doc/sharedb-client.d.ts +0 -4
- package/@ones-editor/sharedb-doc/src/doc/sharedb-doc.d.ts +0 -1
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui-base/src/color-button/text-color-item.d.ts +1 -1
- package/@ones-editor/versions/src/history-doc/history-doc.d.ts +0 -1
- package/@ones-editor/versions/src/version-dialog/version-list.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +178 -178
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OnesEditor, CommandItem } from '../../../../@ones-editor/core';
|
|
2
|
+
export default class ContextMenuCommandItems {
|
|
3
|
+
private editor;
|
|
4
|
+
private t;
|
|
5
|
+
private isSecureContext;
|
|
6
|
+
constructor(editor: OnesEditor);
|
|
7
|
+
get isRangeCollapsed(): boolean;
|
|
8
|
+
get imageTypeCommandItems(): CommandItem[];
|
|
9
|
+
get copyTypeCommandItems(): CommandItem[];
|
|
10
|
+
get cutCommandItem(): CommandItem;
|
|
11
|
+
get stepItem(): CommandItem;
|
|
12
|
+
get selectionCommandItems(): CommandItem[];
|
|
13
|
+
getPasteCommandItem: () => Promise<CommandItem>;
|
|
14
|
+
getCommandItems: () => Promise<CommandItem[]>;
|
|
15
|
+
private secureEnvTips;
|
|
16
|
+
private isFocusImageBlock;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isClipboardEmpty(): Promise<boolean>;
|
|
File without changes
|
|
@@ -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, OnesEditorContextMenuInstance } from '../../../../@ones-editor/core';
|
|
2
|
+
import './context-menu.scss';
|
|
3
|
+
declare class RightContextMenu implements OnesEditorContextMenuInstance {
|
|
4
|
+
private editor;
|
|
5
|
+
private contextMenu;
|
|
6
|
+
private contextMenuCommandItems;
|
|
7
|
+
constructor(editor: OnesEditor);
|
|
8
|
+
show(event: MouseEvent): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
private handleContextMenu;
|
|
11
|
+
private isInMenu;
|
|
12
|
+
private isInEditor;
|
|
13
|
+
private handleContextMenuShown;
|
|
14
|
+
private handleContextMenuClick;
|
|
15
|
+
private handleImageEmbedAction;
|
|
16
|
+
}
|
|
17
|
+
export default RightContextMenu;
|
|
@@ -4,5 +4,7 @@ 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
|
-
export declare function editorCopyWithoutEvent(editor: OnesEditor
|
|
7
|
+
export declare function editorCopyWithoutEvent(editor: OnesEditor, options?: {
|
|
8
|
+
copyAsMarkdown: boolean;
|
|
9
|
+
}): void;
|
|
8
10
|
export declare function editorCopyBlock(editor: OnesEditor, block: BlockElement): Promise<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';
|
|
@@ -207,7 +207,6 @@ export interface OnesEditorDoc {
|
|
|
207
207
|
}[]) => void;
|
|
208
208
|
localDeleteChildContainers: (containerIds: string[]) => void;
|
|
209
209
|
addResources: (resourceIds: string[]) => Promise<string[]>;
|
|
210
|
-
patchSyncResources: (resourceIds: string[]) => Promise<string[]>;
|
|
211
210
|
uploadResource: (file: File, options?: UploadResourceOptions) => Promise<UploadResourceResult>;
|
|
212
211
|
buildResourceUrl: (resourceId: string, options?: BuildResourceUrlOptions) => string;
|
|
213
212
|
request: <T = unknown>(url: string, options?: unknown) => Promise<T>;
|
|
@@ -36,7 +36,6 @@ 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[]>;
|
|
40
39
|
buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
|
|
41
40
|
request<T = unknown>(url: string, options?: unknown): Promise<T>;
|
|
42
41
|
broadcastMessage(data: unknown): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorInputCallbacks } from '../composition/editor-input';
|
|
2
|
-
import { OnesEditor, OnesEditorInputHandler, OnesEditorUndoAction, RemoteChangeType, PasteOptions } from '../types';
|
|
2
|
+
import { OnesEditor, OnesEditorDocs, OnesEditorInputHandler, OnesEditorUndoAction, RemoteChangeType, PasteOptions } from '../types';
|
|
3
3
|
import { DocObject } from '../doc';
|
|
4
4
|
export declare class EditorInputHandlers implements EditorInputCallbacks {
|
|
5
5
|
editor: OnesEditor;
|
|
@@ -26,7 +26,7 @@ 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
32
|
}
|
|
@@ -389,6 +389,7 @@ export interface OnesEditorOptionalOptions {
|
|
|
389
389
|
colors?: string[];
|
|
390
390
|
scrollContainer?: HTMLElement;
|
|
391
391
|
enableComments?: boolean;
|
|
392
|
+
enableContextMenu?: boolean;
|
|
392
393
|
settingsProvider?: OnesEditorSettingsProvider;
|
|
393
394
|
}
|
|
394
395
|
export interface OnesEditorOptions {
|
|
@@ -397,8 +398,15 @@ export interface OnesEditorOptions {
|
|
|
397
398
|
[index: string]: unknown;
|
|
398
399
|
};
|
|
399
400
|
enableComments?: boolean;
|
|
401
|
+
enableContextMenu?: boolean;
|
|
400
402
|
scrollContainer?: HTMLElement;
|
|
401
403
|
}
|
|
404
|
+
export interface OnesEditorContextMenuInstance {
|
|
405
|
+
show: (event: MouseEvent) => void;
|
|
406
|
+
}
|
|
407
|
+
interface OnesEditorContextMenu {
|
|
408
|
+
new (editor: OnesEditor): OnesEditorContextMenuInstance;
|
|
409
|
+
}
|
|
402
410
|
export interface OnesEditorComponents {
|
|
403
411
|
blocks?: Block[];
|
|
404
412
|
boxes?: Box[];
|
|
@@ -409,6 +417,7 @@ export interface OnesEditorComponents {
|
|
|
409
417
|
commandProviders?: OnesEditorCommandProvider[];
|
|
410
418
|
textRenders?: OnesEditorBlockRenderer[];
|
|
411
419
|
blockHooks?: OnesEditorBlockHook[];
|
|
420
|
+
contextMenu?: OnesEditorContextMenu;
|
|
412
421
|
options?: {
|
|
413
422
|
[index: string]: unknown;
|
|
414
423
|
};
|
|
@@ -472,6 +481,7 @@ export interface OnesEditor extends TypedEmitter<OnesEditorEvents> {
|
|
|
472
481
|
readonly options: OnesEditorOptions;
|
|
473
482
|
readonly domEvents: OnesEditorDomEvents;
|
|
474
483
|
readonly settingsProvider: OnesEditorSettingsProvider;
|
|
484
|
+
readonly contextMenu: OnesEditorContextMenuInstance | null;
|
|
475
485
|
readonly: boolean;
|
|
476
486
|
addCustom: <T extends OnesEditorCustom>(name: string, creator: OnesEditorCustomCreator) => T;
|
|
477
487
|
getCustom: <T extends OnesEditorCustom>(name: string) => T;
|
|
@@ -682,3 +692,4 @@ export interface OnesEditorBlockHook {
|
|
|
682
692
|
writable?: (editor: OnesEditor, blockElement: BlockElement | BlockElement[]) => boolean | undefined;
|
|
683
693
|
commands?: (editor: OnesEditor, blockElement: BlockElement) => BlockCommands;
|
|
684
694
|
}
|
|
695
|
+
export {};
|
|
@@ -24,7 +24,6 @@ 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[]>;
|
|
28
27
|
buildResourceUrl(src: string): string;
|
|
29
28
|
request<T>(url: string, opt?: any): Promise<T>;
|
|
30
29
|
broadcastMessage(data: unknown): void;
|
|
@@ -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, };
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { OnesEditor } from '../../../../@ones-editor/core';
|
|
2
|
-
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
|
3
2
|
export interface MathjaxOptions {
|
|
4
3
|
cdn?: {
|
|
5
4
|
mathjax?: string;
|
|
6
5
|
};
|
|
7
6
|
}
|
|
8
7
|
export declare function mathjax2Svg(editor: OnesEditor, tex: string): Promise<string>;
|
|
9
|
-
export declare function analyzeMathjaxSvgWidth(svg: string): {
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
};
|
|
13
8
|
export declare function mathjax2DataUrl(editor: OnesEditor, tex: string): Promise<string>;
|
|
14
9
|
export declare function convertAndUploadMathjax(editor: OnesEditor, tex: string): Promise<string>;
|
|
15
|
-
export declare function convertAndUploadMathjaxForEmbed(editor: OnesEditor, tex: string): Promise<{
|
|
16
|
-
resourceId: string;
|
|
17
|
-
} & ReturnType<typeof analyzeMathjaxSvgWidth>>;
|
|
18
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
|
-
import { AbstractCommandBar, Popup
|
|
2
|
+
import { AbstractCommandBar, Popup } from '../../../../@ones-editor/ui-base';
|
|
3
3
|
import { OnesEditor } from '../../../../@ones-editor/core';
|
|
4
4
|
export type OnEditChange = (tex: string, end: boolean) => void;
|
|
5
5
|
export default class MathjaxEditor {
|
|
@@ -7,7 +7,7 @@ export default class MathjaxEditor {
|
|
|
7
7
|
onChange: OnEditChange | null;
|
|
8
8
|
tex: string;
|
|
9
9
|
private observer;
|
|
10
|
-
editMathjax(elem: HTMLElement, tex: string, onChange: OnEditChange
|
|
10
|
+
editMathjax(elem: HTMLElement, tex: string, onChange: OnEditChange): void;
|
|
11
11
|
handleClose: (commandBar: AbstractCommandBar) => void;
|
|
12
12
|
handleKeyup: (event: KeyboardEvent) => void;
|
|
13
13
|
handleChange: import("lodash").DebouncedFunc<(text: string) => void>;
|
|
@@ -16,4 +16,4 @@ export default class MathjaxEditor {
|
|
|
16
16
|
getTextarea(): HTMLTextAreaElement;
|
|
17
17
|
destroy(): void;
|
|
18
18
|
}
|
|
19
|
-
export declare function editMathjax(editor: OnesEditor, elem: HTMLElement, tex: string, onChange: OnEditChange
|
|
19
|
+
export declare function editMathjax(editor: OnesEditor, elem: HTMLElement, tex: string, onChange: OnEditChange): void;
|
|
@@ -30,11 +30,7 @@ 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[]>;
|
|
36
33
|
getFileUrlsByHashes(resourceHashes: string[]): Promise<any[]>;
|
|
37
|
-
patchSyncResourceByHashes(resourceHashes: string[]): Promise<any[]>;
|
|
38
34
|
uploadFile(url: string, file: File, headers: {
|
|
39
35
|
[index: string]: string;
|
|
40
36
|
}, onProgress: OnProgress, options?: {
|
|
@@ -76,7 +76,6 @@ 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[]>;
|
|
80
79
|
uploadResource(file: File, options?: UploadResourceOptions): Promise<UploadResourceResult>;
|
|
81
80
|
buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
|
|
82
81
|
request<T = unknown>(url: string, options?: unknown): Promise<T>;
|