@ones-editor/editor 0.0.3-beta.6 → 0.0.3-beta.8
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/core/src/core/doc/rich-text/insert-text.d.ts +2 -1
- package/@ones-editor/core/src/core/editor/editor-dom/dom-events.d.ts +2 -2
- package/@ones-editor/core/src/core/types.d.ts +11 -1
- package/@ones-editor/core/src/utils/file.d.ts +2 -0
- package/@ones-editor/e2e/cypress/support/commands.d.ts +19 -0
- package/@ones-editor/e2e/cypress/support/e2e.d.ts +1 -0
- package/@ones-editor/e2e/cypress.config.d.ts +3 -0
- package/@ones-editor/e2e/package.json +13 -0
- package/@ones-editor/e2e/src/block-menu/menu-list.cy.d.ts +0 -0
- package/@ones-editor/e2e/src/data.d.ts +106 -0
- package/@ones-editor/e2e/src/input-handlers/case.d.ts +10 -0
- package/@ones-editor/e2e/src/input-handlers/shortcut.cy.d.ts +1 -0
- package/@ones-editor/e2e/src/list-block/case.d.ts +8 -0
- package/@ones-editor/e2e/src/list-block/list.cy.d.ts +1 -0
- package/@ones-editor/e2e/src/toc/case.d.ts +5 -0
- package/@ones-editor/e2e/src/toc/toc.cy.d.ts +1 -0
- package/@ones-editor/embed-block-helper/src/block-properties/embed-block-properties.d.ts +1 -0
- package/@ones-editor/file/package.json +8 -0
- package/@ones-editor/file/src/file-box/index.d.ts +4 -0
- package/@ones-editor/file/src/file-embed/card/file-icon.d.ts +1 -0
- package/@ones-editor/file/src/file-embed/card/index.d.ts +6 -0
- package/@ones-editor/file/src/file-embed/download-file.d.ts +2 -0
- package/@ones-editor/file/src/file-embed/index.d.ts +4 -0
- package/@ones-editor/file/src/index.d.ts +3 -0
- package/@ones-editor/file/src/types.d.ts +22 -0
- package/@ones-editor/find-dialog/src/find-dialog.d.ts +0 -1
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/index.d.ts +2 -1
- package/@ones-editor/ui/src/quick-menu/basic-menu-items.d.ts +2 -4
- package/@ones-editor/ui/src/quick-menu/index.d.ts +1 -6
- package/@ones-editor/ui/src/quick-menu/insert-empty-block.d.ts +4 -2
- package/@ones-editor/ui/src/quick-menu/types.d.ts +24 -1
- package/@ones-editor/ui/src/toolbar/toolbar-handler.d.ts +0 -1
- package/@ones-editor/ui-base/src/auto-suggest/auto-suggest-menu.d.ts +1 -0
- package/dist/index.js +213 -145
- package/dist/types.d.ts +5 -2
- package/package.json +4 -1
|
@@ -8,6 +8,7 @@ export default class BlockMenu {
|
|
|
8
8
|
show(target: HTMLElement): void;
|
|
9
9
|
isInMenu(eventTarget: EventTarget | null): boolean;
|
|
10
10
|
handleShow: () => void;
|
|
11
|
+
handleClose: () => void;
|
|
11
12
|
handleItemClick: (bar: unknown, item: CommandItem) => void;
|
|
12
13
|
setBlock(block: BlockElement): void;
|
|
13
14
|
close: () => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { DocBlockText, DocBlockTextActions, DocBlockTextAttributes } from '../doc';
|
|
1
|
+
import { DocBlockText, DocBlockTextActions, DocBlockTextAttributes, DocBox, DocBlockTextOp } from '../doc';
|
|
2
2
|
export declare function insertText(richText: DocBlockText, offset: number, text: string | DocBlockText, attributes: DocBlockTextAttributes | null): DocBlockText;
|
|
3
|
+
export declare function createBoxOp(boxData: DocBox): DocBlockTextOp;
|
|
3
4
|
export declare function createInsertOps(offset: number, text: string | DocBlockText, attributes: DocBlockTextAttributes | null): DocBlockTextActions;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OnesEditor } from '../../types';
|
|
2
|
-
export type DomEventCallback = (editor: OnesEditor, event:
|
|
2
|
+
export type DomEventCallback<T = Event> = (editor: OnesEditor, event: T, data: unknown) => void;
|
|
3
3
|
declare class DomEventHandler {
|
|
4
4
|
editor: OnesEditor;
|
|
5
5
|
dom: Element | Document | Window;
|
|
@@ -15,7 +15,7 @@ export declare class EditorDomEvents {
|
|
|
15
15
|
handlers: Map<Element | Document | Window, DomEventHandler[]>;
|
|
16
16
|
constructor(editor: OnesEditor);
|
|
17
17
|
destroy(): void;
|
|
18
|
-
addEventListener(element: Element | Document | Window, eventName: string, eventHandler: DomEventCallback
|
|
18
|
+
addEventListener<T = Event>(element: Element | Document | Window, eventName: string, eventHandler: DomEventCallback<T>, data?: unknown): void;
|
|
19
19
|
removeEventListener(element: Element | Document | Window | null, eventName: string | null, eventHandler: DomEventCallback): void;
|
|
20
20
|
removeAllListeners(element: Element | Document | Window, eventName?: string): void;
|
|
21
21
|
}
|
|
@@ -49,12 +49,21 @@ export interface ComplexBlockPosition {
|
|
|
49
49
|
isSimple: () => false;
|
|
50
50
|
}
|
|
51
51
|
export type BlockPosition = SimpleBlockPosition | ComplexBlockPosition;
|
|
52
|
+
export interface BoxCommands {
|
|
53
|
+
group: string;
|
|
54
|
+
commands: CommandItem[];
|
|
55
|
+
executeCommand: (editor: OnesEditor, block: BlockElement, box: BoxElement, item: CommandItem) => unknown;
|
|
56
|
+
}
|
|
57
|
+
export interface BoxProperties {
|
|
58
|
+
boxCommands?: Record<string, BoxCommands>;
|
|
59
|
+
}
|
|
52
60
|
export interface Box {
|
|
53
61
|
boxType: string;
|
|
54
62
|
updateBoxContent: (editor: OnesEditor, boxElement: BoxElement, boxContent: BoxContentElement, boxData: DocBox) => void;
|
|
55
63
|
convertFrom?: (editor: OnesEditor, text: string) => DocBox | null;
|
|
56
64
|
handleClickBox?: (editor: OnesEditor, box: BoxElement, event: MouseEvent) => void;
|
|
57
65
|
toStandardText?: (editor: OnesEditor, box: DocBox) => Promise<DocBlockText | undefined>;
|
|
66
|
+
getBoxProperties?: (editor: OnesEditor, boxElement: BoxElement) => BoxProperties;
|
|
58
67
|
}
|
|
59
68
|
export interface Insertion {
|
|
60
69
|
insertionType: string;
|
|
@@ -121,6 +130,7 @@ export interface CommandItem {
|
|
|
121
130
|
manualShowChildren?: boolean;
|
|
122
131
|
childrenPlacement?: CommandItemChildrenPlacement;
|
|
123
132
|
childrenOffset?: [number, number];
|
|
133
|
+
shortcut?: string;
|
|
124
134
|
setCloseable?: (closeable: Closeable) => void;
|
|
125
135
|
beforePopup?: (parent: unknown) => void;
|
|
126
136
|
}
|
|
@@ -411,7 +421,7 @@ export interface CloneBlockResultInfo {
|
|
|
411
421
|
blockIdMap: Map<string, string>;
|
|
412
422
|
}
|
|
413
423
|
export interface OnesEditorDomEvents extends OnesEditorCustom {
|
|
414
|
-
addEventListener: (element: Element | Document | Window, eventName: string, eventHandler: (editor: OnesEditor, event:
|
|
424
|
+
addEventListener: <T = Event>(element: Element | Document | Window, eventName: string, eventHandler: (editor: OnesEditor, event: T) => void) => void;
|
|
415
425
|
removeEventListener: (element: Element | Document | Window | null, eventName: string | null, eventHandler: (editor: OnesEditor, event: Event) => void) => void;
|
|
416
426
|
removeAllListeners: (element: Element | Document | Window, eventName?: string) => void;
|
|
417
427
|
}
|
|
@@ -4,4 +4,6 @@ interface SelectFileOptions {
|
|
|
4
4
|
export declare function selectFile<T extends SelectFileOptions = SelectFileOptions>(accept: string, options?: T): Promise<T extends {
|
|
5
5
|
multiple: true;
|
|
6
6
|
} ? File[] : File>;
|
|
7
|
+
export declare function getFileExt(file: string): string;
|
|
8
|
+
export declare function requestDownload(downloadUrl: string, fileName?: string): void;
|
|
7
9
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="cypress" />
|
|
3
|
+
declare namespace Cypress {
|
|
4
|
+
interface Chainable {
|
|
5
|
+
getBlocksByType: (blockType: string) => Chainable<Element>;
|
|
6
|
+
clearAllNoteByKeyboard: () => void;
|
|
7
|
+
getBlockContent: () => Chainable<Element>;
|
|
8
|
+
getBlockContentByBlockId: (blockId: string) => Chainable<Element>;
|
|
9
|
+
cacheBlock: (blockType: string, block: BlockCache) => Chainable<JQuery>;
|
|
10
|
+
createHeadingByShortcut: (blockId: string, level: number, title: string) => Chainable<Element>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
interface BlockCache {
|
|
14
|
+
TitleBlockId: string;
|
|
15
|
+
BlockCacheMap: Map<string, string[]>;
|
|
16
|
+
setBlock(blockType: string, blockId: string): void;
|
|
17
|
+
getLastBlockId(blockType: string): string;
|
|
18
|
+
setTitleBlockId(blockId: string): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './commands';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ones-editor/e2e",
|
|
3
|
+
"private": "true",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "cypress open",
|
|
9
|
+
"e2e-headless": "node ./scripts/e2e-run-tests.js",
|
|
10
|
+
"test-mobile": "cypress open --config viewportWidth=390,viewportHeight=844"
|
|
11
|
+
},
|
|
12
|
+
"types": "src/index.d.ts"
|
|
13
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export declare class BlockCache {
|
|
2
|
+
TitleBlockId: string;
|
|
3
|
+
BlockCacheMap: Map<string, string[]>;
|
|
4
|
+
constructor();
|
|
5
|
+
setBlock(blockType: string, blockId: string): Map<string, string[]>;
|
|
6
|
+
getLastBlockId(blockType: string): string;
|
|
7
|
+
setTitleBlockId(blockId: string): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class TestTextStyleData {
|
|
10
|
+
inputStr: string;
|
|
11
|
+
checkSpanIndex: number;
|
|
12
|
+
expectedClassValue: string;
|
|
13
|
+
expectedTextValue: string;
|
|
14
|
+
constructor(inputStr: string, checkSpanIndex: number, expectedClassValue: string, expectedTextValue: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class TestHeadingStyleData {
|
|
17
|
+
key: string;
|
|
18
|
+
inputStr: string;
|
|
19
|
+
expected: string;
|
|
20
|
+
expectedPlaceholder: string;
|
|
21
|
+
constructor(key: string, inputStr: string, expected: string, expectedPlaceholder: string);
|
|
22
|
+
}
|
|
23
|
+
export declare const docTestBlockStyle = "block-style";
|
|
24
|
+
export declare const blockCache: BlockCache;
|
|
25
|
+
export declare const TEXT_BLOCK_ATTRIBUTE: {
|
|
26
|
+
PLACE_HOLDER: {
|
|
27
|
+
KEY: string;
|
|
28
|
+
DEFAULT: string;
|
|
29
|
+
HEADING1: string;
|
|
30
|
+
HEADING2: string;
|
|
31
|
+
HEADING3: string;
|
|
32
|
+
HEADING4: string;
|
|
33
|
+
HEADING5: string;
|
|
34
|
+
HEADING6: string;
|
|
35
|
+
HEADING7: string;
|
|
36
|
+
HEADING8: string;
|
|
37
|
+
};
|
|
38
|
+
STYLE_HEADING: {
|
|
39
|
+
KEY: string;
|
|
40
|
+
};
|
|
41
|
+
STYLE_QUOTE: {
|
|
42
|
+
QUOTECLASSNAME: string;
|
|
43
|
+
};
|
|
44
|
+
STYLE_TEXT: {
|
|
45
|
+
BoldStyleClass: string;
|
|
46
|
+
ItalicStyleClass: string;
|
|
47
|
+
CodeStyleClass: string;
|
|
48
|
+
StrikeThrough: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare const LIST_BLOCK_ATTRIBUTE: {
|
|
52
|
+
PLACE_HOLDER: {
|
|
53
|
+
KEY: string;
|
|
54
|
+
LIST: string;
|
|
55
|
+
};
|
|
56
|
+
LEVEL: string;
|
|
57
|
+
START: string;
|
|
58
|
+
GROUP_ID: string;
|
|
59
|
+
LISTTYPE: string;
|
|
60
|
+
VALUE: {
|
|
61
|
+
LISTTYPE_ORDERED: string;
|
|
62
|
+
LISTTYPE_UNORDERED: string;
|
|
63
|
+
LISTTYPE_CHECKED: string;
|
|
64
|
+
LISTTYPE_UNCHECKED: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export declare const CODE_BLOCK_ATTRIBUTE: {
|
|
68
|
+
DATA_LANGUAGE: string;
|
|
69
|
+
LANGUAGE_PLAIN: string;
|
|
70
|
+
LANGUAGE_GOLANG: string;
|
|
71
|
+
LANGUAGE_JAVA: string;
|
|
72
|
+
LANGUAGE_JAVASCRIPT: string;
|
|
73
|
+
LANGUAGE_HTML_XML: string;
|
|
74
|
+
};
|
|
75
|
+
export declare const EMBED_BLOCK_ATTRIBUTE: {
|
|
76
|
+
HR: {
|
|
77
|
+
TYPE: string;
|
|
78
|
+
CLASS: string;
|
|
79
|
+
};
|
|
80
|
+
MERMAID: {
|
|
81
|
+
TYPE: string;
|
|
82
|
+
EMPTY_TIPS: string;
|
|
83
|
+
EMPTY_REPLACE: string;
|
|
84
|
+
ARIA_EXPANDED: string;
|
|
85
|
+
IMAGE_CLASS: string;
|
|
86
|
+
};
|
|
87
|
+
PLANTUML: {
|
|
88
|
+
TYPE: string;
|
|
89
|
+
EMPTY_TIPS: string;
|
|
90
|
+
EMPTY_REPLACE: string;
|
|
91
|
+
ARIA_EXPANDED: string;
|
|
92
|
+
IMAGE_CLASS: string;
|
|
93
|
+
};
|
|
94
|
+
TOC: {
|
|
95
|
+
TYPE: string;
|
|
96
|
+
CONTAINER_CLASS: string;
|
|
97
|
+
EMPTY_REPLACE: string;
|
|
98
|
+
EMPTY_CLASS: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export declare class TocNode {
|
|
102
|
+
children: TocNode[];
|
|
103
|
+
title: string;
|
|
104
|
+
level: number;
|
|
105
|
+
block: string;
|
|
106
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TestHeadingStyleData, TestTextStyleData } from '../data';
|
|
2
|
+
export declare class ShortcutCase {
|
|
3
|
+
testHeadingStyleShortcut: (data: TestHeadingStyleData) => () => void;
|
|
4
|
+
testShortcutMethod: (data: TestTextStyleData) => () => void;
|
|
5
|
+
testQuoteBlockStyleShortcut: () => () => void;
|
|
6
|
+
testEmberStyleBrShortcut: () => () => void;
|
|
7
|
+
testEmberStyleMermaidPlantumlShortcut: (input: string, embedType: string, emptyReplace: string) => () => void;
|
|
8
|
+
testListBlockStyleShortcut: (input: string, expected: string, start: number, level: number) => () => void;
|
|
9
|
+
testCodeBlockShortcut: (input: string, expected: string) => () => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'cypress-real-events';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import 'cypress-real-events';
|
|
2
|
+
export declare class ListCase {
|
|
3
|
+
OrderListCreate: () => () => void;
|
|
4
|
+
OrderListAddLevel: () => () => void;
|
|
5
|
+
OrderListFirstNodeAddLevel: () => () => void;
|
|
6
|
+
OrderListSoluction4: () => () => void;
|
|
7
|
+
OrderListPalceholder: () => () => void;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'cypress-real-events';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import 'cypress-real-events';
|
|
@@ -5,6 +5,7 @@ export interface StandardEmbedBlockProperties<T = PresetCommandId> {
|
|
|
5
5
|
extCommands?: CommandItem[];
|
|
6
6
|
handleExecuteCommand?: (editor: OnesEditor, block: BlockElement, item: CommandItem) => boolean;
|
|
7
7
|
}
|
|
8
|
+
export declare function addCommentToBlock(editor: OnesEditor, block: BlockElement): boolean;
|
|
8
9
|
export declare class StandardEmbedBlockCommands<T = PresetCommandId> implements BlockCommands {
|
|
9
10
|
protected editor: OnesEditor;
|
|
10
11
|
protected properties?: StandardEmbedBlockProperties<T> | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFileIcon(fileName: string, fileType: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BlockContentElement } from '../../../../../@ones-editor/core';
|
|
2
|
+
import { FileEmbedData } from '../../types';
|
|
3
|
+
export declare function renderFileCard(content: BlockContentElement, data: FileEmbedData): {
|
|
4
|
+
card: HTMLDivElement;
|
|
5
|
+
downloadButton: HTMLButtonElement;
|
|
6
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BlockElement, BoxElement, DocBox, DocEmbedData, OnesEditor } from '../../../@ones-editor/core';
|
|
2
|
+
export interface FileData {
|
|
3
|
+
src: string;
|
|
4
|
+
fileName: string;
|
|
5
|
+
fileSize: number;
|
|
6
|
+
fileType: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FileBoxData extends DocBox, FileData {
|
|
9
|
+
}
|
|
10
|
+
export declare enum FilePreviewType {
|
|
11
|
+
Card = "card",
|
|
12
|
+
Preview = "preview"
|
|
13
|
+
}
|
|
14
|
+
export interface FileEmbedData extends DocEmbedData, FileData {
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
previewType?: FilePreviewType;
|
|
18
|
+
}
|
|
19
|
+
export interface FileOptions {
|
|
20
|
+
onClick?: (editor: OnesEditor, elem: BlockElement | BoxElement, event: MouseEvent) => void;
|
|
21
|
+
onDownloadFile?: (editor: OnesEditor, data: FileData) => void;
|
|
22
|
+
}
|