@ones-editor/editor 2.0.3 → 2.0.4-beta.1
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/items/insert-block-items/index.d.ts +1 -1
- package/@ones-editor/block-menu/src/block-menu-button/drag-preview/element-to-data-url.d.ts +1 -1
- package/@ones-editor/block-menu/src/block-menu-button/index.d.ts +5 -15
- package/@ones-editor/block-menu/src/block-menu-button/menu-button/index.d.ts +32 -0
- package/@ones-editor/core/src/core/blocks/common/block-wrapper.d.ts +2 -1
- package/@ones-editor/core/src/core/blocks/common/insert-empty-block.d.ts +2 -1
- package/@ones-editor/core/src/core/types.d.ts +43 -2
- package/@ones-editor/core/src/helper/hovering-block.d.ts +1 -1
- package/@ones-editor/drop-target/src/drop-indicator.d.ts +3 -2
- package/@ones-editor/drop-target/src/drop-target.d.ts +2 -1
- package/@ones-editor/drop-target/src/find-drop-target.d.ts +1 -1
- package/@ones-editor/drop-target/src/index.d.ts +2 -1
- package/@ones-editor/image-embed/src/drag-drop/handle-drop-over.d.ts +1 -4
- package/@ones-editor/image-embed/src/drag-drop/handle-drop.d.ts +1 -0
- package/@ones-editor/image-embed/src/hovering-toolbar/index.d.ts +22 -0
- package/@ones-editor/image-embed/src/image-object.d.ts +1 -0
- package/@ones-editor/image-embed/src/index.d.ts +5 -1
- package/@ones-editor/image-embed/src/types.d.ts +1 -0
- package/@ones-editor/layout-block/package.json +8 -0
- package/@ones-editor/layout-block/src/block-drop.d.ts +3 -0
- package/@ones-editor/layout-block/src/caption.d.ts +8 -0
- package/@ones-editor/layout-block/src/child-containers.d.ts +3 -0
- package/@ones-editor/layout-block/src/column-resizer/index.d.ts +2 -0
- package/@ones-editor/layout-block/src/constants.d.ts +32 -0
- package/@ones-editor/layout-block/src/index.d.ts +5 -0
- package/@ones-editor/layout-block/src/layout-creator/index.d.ts +27 -0
- package/@ones-editor/layout-block/src/layout-operations.d.ts +11 -0
- package/@ones-editor/layout-block/src/locale/en-us.d.ts +10 -0
- package/@ones-editor/layout-block/src/locale/index.d.ts +1 -0
- package/@ones-editor/layout-block/src/locale/ja-jp.d.ts +10 -0
- package/@ones-editor/layout-block/src/locale/zh-cn.d.ts +10 -0
- package/@ones-editor/layout-block/src/options.d.ts +2 -0
- package/@ones-editor/layout-block/src/paste.d.ts +7 -0
- package/@ones-editor/layout-block/src/percent-bar.d.ts +3 -0
- package/@ones-editor/layout-block/src/selection.d.ts +5 -0
- package/@ones-editor/layout-block/src/toolbar.d.ts +26 -0
- package/@ones-editor/layout-block/src/types.d.ts +13 -0
- package/@ones-editor/layout-block/src/utils.d.ts +2 -0
- package/@ones-editor/media-embed/src/core/hovering-toolbar/index.d.ts +22 -0
- package/@ones-editor/table-block/src/index.d.ts +1 -0
- package/@ones-editor/table-block/src/table-block/table-creator/index.d.ts +1 -1
- package/@ones-editor/to-docx/src/doc2other/core.d.ts +2 -0
- package/@ones-editor/to-docx/src/doc2other/layout.d.ts +10 -0
- package/@ones-editor/toc/src/build-toc.d.ts +1 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/ui/src/quick-menu/basic-menu-items.d.ts +1 -1
- package/@ones-editor/ui/src/quick-menu/index.d.ts +6 -1
- package/@ones-editor/ui/src/quick-menu/quick-menu-items.d.ts +4 -2
- package/@ones-editor/ui/src/quick-menu/types.d.ts +1 -0
- package/@ones-editor/ui-base/src/icons/index.d.ts +3 -1
- package/dist/index.js +214 -203
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockElement, OnesEditor } from '../../../../../../@ones-editor/core';
|
|
2
2
|
import type { GetAllQuickMenuItemsOptions } from '../../../../../../@ones-editor/ui';
|
|
3
3
|
import type { BlockMenuItem } from '../types';
|
|
4
|
-
export declare function getAllInsertBlockItems(editor: OnesEditor, source: 'insert-block' | 'insert-block-before', options: GetAllQuickMenuItemsOptions): BlockMenuItem[];
|
|
4
|
+
export declare function getAllInsertBlockItems(editor: OnesEditor, block: BlockElement, source: 'insert-block' | 'insert-block-before', options: GetAllQuickMenuItemsOptions): BlockMenuItem[];
|
|
5
5
|
export declare function executeInsertBlockCommand(editor: OnesEditor, block: BlockElement, item: BlockMenuItem, insertAbove?: boolean): Promise<BlockElement | null> | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { OnesEditor } from '../../../../../@ones-editor/core';
|
|
2
|
-
export declare function elementToDataUrl(editor: OnesEditor, element: HTMLElement): Promise<string>;
|
|
2
|
+
export declare function elementToDataUrl(editor: OnesEditor, element: HTMLElement, marginIncluded?: boolean): Promise<string>;
|
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export default class OnesEditorBlockMenuButton {
|
|
1
|
+
import { OnesEditor } from '../../../../@ones-editor/core';
|
|
2
|
+
import OnesEditorBlockMenuButton from './menu-button';
|
|
3
|
+
export default class OnesEditorBlockMenuButtons {
|
|
5
4
|
private editor;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
blockMenu: BlockMenu;
|
|
9
|
-
private dragHandler;
|
|
5
|
+
rootButton: OnesEditorBlockMenuButton;
|
|
6
|
+
private parentButton;
|
|
10
7
|
constructor(editor: OnesEditor);
|
|
11
8
|
destroy(): void;
|
|
12
|
-
handleHoverBlock: (hoverBlock: BlockElement | null, oldBlock: BlockElement | null, event: MouseEvent) => void;
|
|
13
|
-
handleButtonClick: () => void;
|
|
14
|
-
updatePlaceholder: (block: BlockElement) => void;
|
|
15
|
-
handleChanged: () => void;
|
|
16
|
-
createButton(): HTMLButtonElement;
|
|
17
|
-
setButtonType(type: 'move' | 'insert'): void;
|
|
18
|
-
updateButton(block: BlockElement): void;
|
|
19
9
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BlockElement, OnesEditor } from '../../../../../@ones-editor/core';
|
|
2
|
+
import EmptyBlockMenu from '../../empty-block-menu';
|
|
3
|
+
import BlockMenu from '../../block-menu';
|
|
4
|
+
export declare enum MenuButtonType {
|
|
5
|
+
ROOT = "root",
|
|
6
|
+
PARENT = "parent"
|
|
7
|
+
}
|
|
8
|
+
export default class OnesEditorBlockMenuButton {
|
|
9
|
+
private editor;
|
|
10
|
+
private menuType;
|
|
11
|
+
buttonElement: HTMLButtonElement;
|
|
12
|
+
emptyBlockMenu: EmptyBlockMenu;
|
|
13
|
+
blockMenu: BlockMenu;
|
|
14
|
+
private dragHandler;
|
|
15
|
+
private menuButtonType;
|
|
16
|
+
private removeButtonDelay;
|
|
17
|
+
private shouldRemoveParentButton;
|
|
18
|
+
private removeTimer;
|
|
19
|
+
constructor(editor: OnesEditor, menuType: MenuButtonType);
|
|
20
|
+
destroy(): void;
|
|
21
|
+
handleHoverBlock: (hoverBlock: BlockElement | null, oldBlock: BlockElement | null, event: MouseEvent) => void;
|
|
22
|
+
showRootButton(hoverBlock: BlockElement): void;
|
|
23
|
+
showParentButton(hoverBlock: BlockElement): void;
|
|
24
|
+
removeParentButton: () => void;
|
|
25
|
+
addButtonToView(block: BlockElement): void;
|
|
26
|
+
handleButtonClick: () => void;
|
|
27
|
+
updatePlaceholder: (block: BlockElement) => void;
|
|
28
|
+
handleChanged: () => void;
|
|
29
|
+
createButton(): HTMLButtonElement;
|
|
30
|
+
setButtonType(type: 'move' | 'insert'): void;
|
|
31
|
+
updateButton(block: BlockElement): void;
|
|
32
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { OnesEditor, BlockElement, BlockPosition, ConvertBlockResult, SelectionRange, BlockStyles } from '../../types';
|
|
1
|
+
import { OnesEditor, BlockElement, BlockPosition, ConvertBlockResult, SelectionRange, BlockStyles, ContainerElement } from '../../types';
|
|
2
2
|
import { DocBlock, DocBlockAttributes } from '../../doc';
|
|
3
3
|
export declare function getBlockTextLength(editor: OnesEditor, block: BlockElement): number;
|
|
4
4
|
export declare function clearAllSelection(editor: OnesEditor): void;
|
|
5
5
|
export declare function updateBlockSelection(editor: OnesEditor, block: BlockElement, from: BlockPosition, to: BlockPosition): void;
|
|
6
6
|
export declare function getRootBlock(block: BlockElement): BlockElement;
|
|
7
|
+
export declare function getClosestContainerByCondition(_block: BlockElement, condition: (container: ContainerElement) => boolean): BlockElement | undefined;
|
|
7
8
|
export declare function getBlockMinWidth(editor: OnesEditor, block: BlockElement): number | undefined;
|
|
8
9
|
export declare function handleBlockElementUpdated(editor: OnesEditor, block: BlockElement, data: DocBlock): void;
|
|
9
10
|
export declare function convertBlockFrom(editor: OnesEditor, block: BlockElement, type: string, options: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { OnesEditor } from '../../types';
|
|
1
|
+
import { ContainerBlockOverrideInsertEmptyBlockInsideOptions, OnesEditor } from '../../types';
|
|
2
|
+
export declare function getContainerBlockOverrideOptions(editor: OnesEditor, containerID: string, blockType?: string): ContainerBlockOverrideInsertEmptyBlockInsideOptions | undefined;
|
|
2
3
|
export declare function insertEmptyEmbedBlock(editor: OnesEditor, embedType: string, containerId: string, blockIndex: number, data?: Record<string, unknown>): Promise<import("../../types").BlockElement | null>;
|
|
3
4
|
export declare function insertEmptyBlock(editor: OnesEditor, type: string, containerId: string, blockIndex: number, data?: Record<string, unknown>): Promise<import("../../types").BlockElement | null> | null;
|
|
@@ -118,6 +118,7 @@ export interface Closeable {
|
|
|
118
118
|
click: (item: CommandItem, target: HTMLElement) => void;
|
|
119
119
|
}
|
|
120
120
|
export type CommandItemChildrenPlacement = 'auto' | 'top' | 'left' | 'right' | 'bottom' | 'auto-start' | 'auto-end' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'right-start' | 'right-end' | 'left-start' | 'left-end';
|
|
121
|
+
export type CommandItemMenuType = 'inline' | 'sibling';
|
|
121
122
|
export interface CommandItem {
|
|
122
123
|
id: string;
|
|
123
124
|
name: string;
|
|
@@ -147,6 +148,10 @@ export interface CommandItem {
|
|
|
147
148
|
hideGroupItem?: boolean;
|
|
148
149
|
setCloseable?: (closeable: Closeable) => void;
|
|
149
150
|
beforePopup?: (parent: unknown) => void;
|
|
151
|
+
/**
|
|
152
|
+
* defaults to true
|
|
153
|
+
*/
|
|
154
|
+
shouldShown?: (currentBlock: BlockElement | undefined, menuType: CommandItemMenuType) => boolean;
|
|
150
155
|
}
|
|
151
156
|
export interface BlockCommandItem extends CommandItem {
|
|
152
157
|
blockId: string;
|
|
@@ -172,10 +177,39 @@ export interface BlockProperties {
|
|
|
172
177
|
blockCommands?: Record<string, BlockCommands>;
|
|
173
178
|
abstract?: string;
|
|
174
179
|
}
|
|
180
|
+
export interface CombineToCreateOptions {
|
|
181
|
+
/**
|
|
182
|
+
* @returns sideway: 两侧合并(左右 indicator)
|
|
183
|
+
*
|
|
184
|
+
* body: 中间合并(target block 激活)(暂未实现)
|
|
185
|
+
*/
|
|
186
|
+
combinable: (editor: OnesEditor, source: BlockElement, target: BlockElement) => undefined | 'sideway' | 'body';
|
|
187
|
+
onCombine: (editor: OnesEditor, source: BlockElement, target: BlockElement, position: CombineDropInsertPos['pos'], dragObject: DragObject | null) => BlockElement | undefined;
|
|
188
|
+
}
|
|
189
|
+
export type ContainerBlockOverrideInsertEmptyBlockInsideOptionsDict = Record<string, ContainerBlockOverrideInsertEmptyBlockInsideOptions>;
|
|
190
|
+
export type ContainerBlockOverrideInsertEmptyBlockInsideOptions = {
|
|
191
|
+
item?: CommandItem;
|
|
192
|
+
data?: Record<string, unknown>;
|
|
193
|
+
};
|
|
175
194
|
export interface BlockOptions {
|
|
176
195
|
name: string;
|
|
177
196
|
insertBlockCommandItems?: CommandItem[];
|
|
197
|
+
overrideInertEmptyBlockInsideOptions?: ContainerBlockOverrideInsertEmptyBlockInsideOptionsDict;
|
|
178
198
|
handleInsertEmptyBlock?: (editor: OnesEditor, options: InsertEmptyBlockOptions) => Promise<BlockElement | null>;
|
|
199
|
+
isMenuButtonBaseContainer?: (container: ContainerElement) => boolean;
|
|
200
|
+
combineToCreate?: CombineToCreateOptions;
|
|
201
|
+
/**
|
|
202
|
+
* defaults to true.
|
|
203
|
+
*
|
|
204
|
+
* 'without-margin': include margin for dragging preview computing.
|
|
205
|
+
*/
|
|
206
|
+
draggingPreview?: boolean | 'margin-included';
|
|
207
|
+
innerToc?: boolean;
|
|
208
|
+
blockMenu?: {
|
|
209
|
+
showComment?: boolean;
|
|
210
|
+
showLocker?: boolean;
|
|
211
|
+
};
|
|
212
|
+
findPreviewElement?: (editor: OnesEditor, complexBlock: BlockElement) => HTMLElement;
|
|
179
213
|
}
|
|
180
214
|
export interface StandardDragObject {
|
|
181
215
|
type: 'block';
|
|
@@ -193,10 +227,17 @@ export interface CustomDragObject {
|
|
|
193
227
|
}
|
|
194
228
|
export type DragObject = StandardDragObject | CustomDragObject;
|
|
195
229
|
export interface CustomDropInsertPos {
|
|
230
|
+
type: 'custom';
|
|
196
231
|
rect: DOMRect;
|
|
197
232
|
data: unknown;
|
|
233
|
+
targetBlock?: BlockElement;
|
|
198
234
|
}
|
|
199
|
-
export type
|
|
235
|
+
export type CombineDropInsertPos = {
|
|
236
|
+
type: 'combine';
|
|
237
|
+
pos: 'left' | 'right';
|
|
238
|
+
onCombine: CombineToCreateOptions['onCombine'];
|
|
239
|
+
};
|
|
240
|
+
export type DropInsertPos = 'before' | 'after' | CombineDropInsertPos | CustomDropInsertPos;
|
|
200
241
|
export interface DropOptions {
|
|
201
242
|
isSourceBlock: boolean;
|
|
202
243
|
targetBlock: BlockElement;
|
|
@@ -219,7 +260,7 @@ export interface Block {
|
|
|
219
260
|
handleDeleteBlock?: (editor: OnesEditor, block: BlockElement, local: boolean, options: DeleteBlockEventOptions) => void;
|
|
220
261
|
handleUpdateBlock?: (editor: OnesEditor, block: BlockElement, blockData: DocBlock) => boolean;
|
|
221
262
|
handleDropOver?: (editor: OnesEditor, block: BlockElement, dragData: DragObject | DataTransferItemList | null, x: number, y: number) => DropInsertPos | false | undefined;
|
|
222
|
-
handleDrop?: (editor: OnesEditor, block: BlockElement, dragData: DragObject | File[], insertPos: DropInsertPos, options: DropOptions) => boolean | undefined;
|
|
263
|
+
handleDrop?: (editor: OnesEditor, block: BlockElement, dragData: DragObject | File[], insertPos: DropInsertPos, options: DropOptions) => boolean | ContainerElement | undefined;
|
|
223
264
|
getClientRects?: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => DOMRect[];
|
|
224
265
|
getMinWidth?: (editor: OnesEditor, block: BlockElement) => number | undefined;
|
|
225
266
|
convertFrom?: (editor: OnesEditor, srcBlock: BlockElement, options: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
2
|
-
import { TextBlockContentChild } from '../core/blocks/text-blocks/base/child';
|
|
2
|
+
import type { TextBlockContentChild } from '../core/blocks/text-blocks/base/child';
|
|
3
3
|
import { BlockElement, OnesEditor, OnesEditorCustom } from '../core/types';
|
|
4
4
|
export interface OnesEditorHoveringBlockEvents {
|
|
5
5
|
change: (block: BlockElement | null, old: BlockElement | null, event: MouseEvent) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockElement, DropInsertPos, OnesEditor } from '../../../@ones-editor/core';
|
|
1
|
+
import { BlockContentElement, BlockElement, DropInsertPos, OnesEditor } from '../../../@ones-editor/core';
|
|
2
2
|
export declare const INDICATOR_SIZE = 2;
|
|
3
3
|
interface DropTarget {
|
|
4
4
|
block: BlockElement;
|
|
@@ -9,9 +9,10 @@ export default class DropIndicator {
|
|
|
9
9
|
private indicator;
|
|
10
10
|
target: DropTarget | null;
|
|
11
11
|
constructor(editor: OnesEditor);
|
|
12
|
+
createIndicator(): void;
|
|
12
13
|
show(block: BlockElement, insertPos: DropInsertPos): void;
|
|
13
14
|
hide(): void;
|
|
14
15
|
private getIndicatorRect;
|
|
15
|
-
getViewRect(block: BlockElement): DOMRect;
|
|
16
|
+
getViewRect(block: BlockElement | BlockContentElement): DOMRect;
|
|
16
17
|
}
|
|
17
18
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockElement, ContainerElement, OnesEditor } from '../../../@ones-editor/core';
|
|
1
|
+
import { BlockElement, CombineToCreateOptions, ContainerElement, OnesEditor } from '../../../@ones-editor/core';
|
|
2
2
|
import DropIndicator from './drop-indicator';
|
|
3
3
|
export interface DropHandler {
|
|
4
4
|
handleDrop: (editor: OnesEditor, dragData: BlockElement | File[], targetContainer: ContainerElement, blockIndex: number) => boolean | undefined;
|
|
@@ -12,6 +12,7 @@ export default class OnesEditorDropTarget {
|
|
|
12
12
|
dropEffect: 'move' | 'none';
|
|
13
13
|
} | undefined;
|
|
14
14
|
handlers: DropHandler[];
|
|
15
|
+
combineToCreate: CombineToCreateOptions[];
|
|
15
16
|
constructor(editor: OnesEditor);
|
|
16
17
|
destroy(): void;
|
|
17
18
|
addHandler(handler: DropHandler): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BlockElement, OnesEditor } from '../../../@ones-editor/core';
|
|
2
|
-
export declare function findTargetBlock(editor: OnesEditor, x
|
|
2
|
+
export declare function findTargetBlock(editor: OnesEditor, x?: number, y?: number): BlockElement | null;
|
|
3
3
|
export declare function canInsertAsSibling(editor: OnesEditor, block: BlockElement): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { INDICATOR_SIZE } from './drop-indicator';
|
|
1
2
|
import OnesEditorDropTarget from './drop-target';
|
|
2
3
|
import type { DropHandler } from './drop-target';
|
|
3
4
|
import { patchInsertFile } from './handlers/patch-insert-file';
|
|
4
5
|
export * from './drag-object';
|
|
5
|
-
export { OnesEditorDropTarget, DropHandler, patchInsertFile };
|
|
6
|
+
export { OnesEditorDropTarget, DropHandler, patchInsertFile, INDICATOR_SIZE };
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { BlockElement, DragObject, OnesEditor } from '../../../../@ones-editor/core';
|
|
2
2
|
import { ImageDragInsertPos } from './types';
|
|
3
|
-
export declare function getDragInsertPos(editor: OnesEditor, block: BlockElement, images: HTMLElement[], x: number, y?: number):
|
|
4
|
-
rect: DOMRect;
|
|
5
|
-
data: number;
|
|
6
|
-
};
|
|
3
|
+
export declare function getDragInsertPos(editor: OnesEditor, block: BlockElement, images: HTMLElement[], x: number, y?: number): ImageDragInsertPos;
|
|
7
4
|
export declare function handleDropOver(editor: OnesEditor, block: BlockElement, dragObject: DragObject | DataTransferItemList | null, x: number, y: number): ImageDragInsertPos | undefined;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { BlockElement, DragObject, DropInsertPos, DropOptions, OnesEditor } from '../../../../@ones-editor/core';
|
|
2
|
+
export declare function deleteImageFromBlock(editor: OnesEditor, block: BlockElement, index: number): void;
|
|
2
3
|
export declare function handleDrop(editor: OnesEditor, block: BlockElement, dragData: DragObject | File[], insertPos: DropInsertPos, options: DropOptions): boolean | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BlockCommands, BlockElement, CommandItem, OnesEditor } from '../../../../@ones-editor/core';
|
|
2
|
+
import type { CommandItemType } from '../../../../@ones-editor/core';
|
|
3
|
+
export default class ImageHoveringToolbarCommands implements BlockCommands {
|
|
4
|
+
protected editor: OnesEditor;
|
|
5
|
+
protected block: BlockElement;
|
|
6
|
+
group: string;
|
|
7
|
+
constructor(editor: OnesEditor, block: BlockElement);
|
|
8
|
+
_commands: ({
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
icon: string;
|
|
12
|
+
type?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: CommandItemType;
|
|
17
|
+
icon?: undefined;
|
|
18
|
+
})[];
|
|
19
|
+
private createIconItem;
|
|
20
|
+
get commands(): CommandItem[];
|
|
21
|
+
executeCommand(editor: OnesEditor, block: BlockElement, item: CommandItem): void;
|
|
22
|
+
}
|
|
@@ -10,6 +10,7 @@ export declare class ImageObject implements ImageObjectBase {
|
|
|
10
10
|
private resizing;
|
|
11
11
|
private parentContainerResizerObserver;
|
|
12
12
|
private autoFix;
|
|
13
|
+
focusTimes: number;
|
|
13
14
|
constructor(editor: OnesEditor, blockData: DocEmbedBlock);
|
|
14
15
|
destroy(): void;
|
|
15
16
|
setAutoFix(autoFix: boolean): void;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Embed } from '../../../@ones-editor/core';
|
|
2
|
+
import { toImageEmbedData } from './image-data';
|
|
2
3
|
import { ImageObject } from './image-object';
|
|
3
4
|
import './image-embed-style.scss';
|
|
5
|
+
import { deleteImageFromBlock } from './drag-drop/handle-drop';
|
|
4
6
|
import './locale';
|
|
5
7
|
import { getImageContainersByBlock } from './image-dom/helper';
|
|
6
8
|
import EmptyImageConverterInputHandler from './empty-image-converter';
|
|
7
9
|
import { ImagePasteHandler } from './paste-handler';
|
|
10
|
+
import type { ImageDragObject } from './drag-drop/types';
|
|
11
|
+
import { updateImageBlockSize } from './image-size';
|
|
8
12
|
export * from './shortcuts';
|
|
9
13
|
export * from './types';
|
|
10
|
-
export { ImageObject, ImagePasteHandler, getImageContainersByBlock };
|
|
14
|
+
export { ImageObject, ImagePasteHandler, getImageContainersByBlock, toImageEmbedData, deleteImageFromBlock, ImageDragObject, updateImageBlockSize };
|
|
11
15
|
declare const ImageEmbed: Embed;
|
|
12
16
|
export { ImageEmbed, EmptyImageConverterInputHandler };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OnesEditorInputHandler, OnesEditorCustom, OnesEditor, OnesEditorDocs } from '../../../@ones-editor/core';
|
|
2
|
+
export default class LayoutBlockCaptionInputHandler implements OnesEditorInputHandler, OnesEditorCustom {
|
|
3
|
+
private editor;
|
|
4
|
+
constructor(editor: OnesEditor);
|
|
5
|
+
destroy(): void;
|
|
6
|
+
handleBeforePaste(editor: OnesEditor, event: ClipboardEvent | null, docs: OnesEditorDocs): Promise<boolean>;
|
|
7
|
+
static init(editor: OnesEditor): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 名称
|
|
3
|
+
*/
|
|
4
|
+
export declare const LAYOUT_NAME = "LayoutBlock";
|
|
5
|
+
/**
|
|
6
|
+
* 快捷键
|
|
7
|
+
*/
|
|
8
|
+
export declare const LAYOUT_SHORTCUT_ID = "insert-layout";
|
|
9
|
+
/**
|
|
10
|
+
* 快捷键提示
|
|
11
|
+
*/
|
|
12
|
+
export declare const LAYOUT_SHORTCUT_SUBTEXT = "/layout";
|
|
13
|
+
export declare const LAYOUT_BLOCK_TYPE = "layout";
|
|
14
|
+
/**
|
|
15
|
+
* 最大分栏数
|
|
16
|
+
*/
|
|
17
|
+
export declare const MAX_LAYOUT_COLUMNS = 6;
|
|
18
|
+
/**
|
|
19
|
+
* 最小分栏数
|
|
20
|
+
*/
|
|
21
|
+
export declare const MIN_LAYOUT_COLUMNS = 2;
|
|
22
|
+
/**
|
|
23
|
+
* 分栏最小宽度,百分比
|
|
24
|
+
*/
|
|
25
|
+
export declare const MIN_LAYOUT_WIDTH_PERCENT = 0.08;
|
|
26
|
+
export declare const DROP_BLOCK_TYPE_BLACK_LIST: string[];
|
|
27
|
+
/**
|
|
28
|
+
* custom dom
|
|
29
|
+
*/
|
|
30
|
+
export declare const LAYOUT_SEPARATOR_CLASS_NAME = "layout-separator";
|
|
31
|
+
export declare const LAYOUT_COLUMN_CONTAINER_CLASS_NAME = "layout-column-container";
|
|
32
|
+
export declare const LAYOUT_SEPARATOR_INDEX_ATTRIBUTE_KEY = "layoutSeparatorIndex";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Closeable, CommandItem } from '../../../../@ones-editor/core';
|
|
2
|
+
import { CreateLayoutData } from '../types';
|
|
3
|
+
declare class LayoutCreatorItem implements CommandItem, CreateLayoutData {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
colCount?: number | undefined;
|
|
7
|
+
classPrefix: {
|
|
8
|
+
container: string;
|
|
9
|
+
title: string;
|
|
10
|
+
column: string;
|
|
11
|
+
};
|
|
12
|
+
element: HTMLElement;
|
|
13
|
+
closeable: Closeable | null;
|
|
14
|
+
columnsArray: number[];
|
|
15
|
+
constructor();
|
|
16
|
+
setCloseable: (closeable: Closeable) => void;
|
|
17
|
+
destroy: () => void;
|
|
18
|
+
createLayoutCreatorElement(): HTMLDivElement;
|
|
19
|
+
handleCreatorClick: (event: MouseEvent) => void;
|
|
20
|
+
handleCreatorLeave: () => void;
|
|
21
|
+
handleLayoutCreatorColumnEnter: (event: MouseEvent) => void;
|
|
22
|
+
highlightLayoutCreatorColumn: (colIndex: number) => void;
|
|
23
|
+
setColumnClassByIndex: (column: HTMLElement | null, index: number, targetIndex: number) => void;
|
|
24
|
+
showCreateLayoutCount: (colIndex: number) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function getLayoutCreatorItem(): LayoutCreatorItem;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BlockElement, OnesEditor, InsertEmptyBlockOptions, BlockPathComponent, DocBlock } from '../../../@ones-editor/core';
|
|
2
|
+
export declare function handleInsertEmptyBlock(editor: OnesEditor, options: InsertEmptyBlockOptions): Promise<BlockElement>;
|
|
3
|
+
export declare function createLayout(editor: OnesEditor, col: number | (BlockElement | DocBlock)[], path: BlockPathComponent, dataOverriding?: (DocBlock | undefined)[]): BlockElement;
|
|
4
|
+
export declare function selectContainer(editor: OnesEditor, layoutBlockElement: BlockElement, startContainerID: string, endContainerID?: string): void;
|
|
5
|
+
export declare function reorderColumns(editor: OnesEditor, layoutBlock: BlockElement, sourceContainerID: string, position: number): void;
|
|
6
|
+
export declare function combineLayoutBlock(editor: OnesEditor, from: BlockElement, to: BlockElement, position?: number): void;
|
|
7
|
+
export declare function addColumn(editor: OnesEditor, targetBlock: BlockElement, options?: {
|
|
8
|
+
sourceBlock?: BlockElement;
|
|
9
|
+
position?: number;
|
|
10
|
+
}): import("@ones-editor/core").ContainerElement | undefined;
|
|
11
|
+
export declare function deleteColumn(editor: OnesEditor, columnContainerID: string, layoutBlock: BlockElement): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OnesEditor, OnesEditorCustom, OnesEditorDocs, OnesEditorInputHandler } from '../../../@ones-editor/core';
|
|
2
|
+
export declare class LayoutFlattenPasteHandler implements OnesEditorInputHandler, OnesEditorCustom {
|
|
3
|
+
private editor;
|
|
4
|
+
constructor(editor: OnesEditor);
|
|
5
|
+
handleBeforePaste(editor: OnesEditor, event: ClipboardEvent | null, docs: OnesEditorDocs, files: File[]): Promise<boolean>;
|
|
6
|
+
destroy(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LayoutKindBlock } from './types';
|
|
2
|
+
export declare const updateSelection: LayoutKindBlock['updateSelection'];
|
|
3
|
+
export declare const clearSelection: LayoutKindBlock['clearSelection'];
|
|
4
|
+
export declare const getSelectedContainers: LayoutKindBlock['getSelectedContainers'];
|
|
5
|
+
export declare const getTextToolbarReferenceClient: LayoutKindBlock['getTextToolbarReferenceClient'];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OnesEditor, BlockElement, AutoScroll, OnesEditorCustom, ContainerElement } from '../../../@ones-editor/core';
|
|
2
|
+
export declare function createSeparatorContainer(editor: OnesEditor, childContainerId: string, index: number): HTMLDivElement;
|
|
3
|
+
export declare function createActionBar(editor: OnesEditor, containerID: string, _blockElement: BlockElement, columnRemovable?: boolean): HTMLDivElement;
|
|
4
|
+
export declare function elementToDataUrl(editor: OnesEditor, element: HTMLElement): Promise<string>;
|
|
5
|
+
export declare class OnesEditorCustomLayoutDragHandler implements OnesEditorCustom {
|
|
6
|
+
private editor;
|
|
7
|
+
activeLayoutBlock?: BlockElement;
|
|
8
|
+
columnContainer?: ContainerElement;
|
|
9
|
+
draggingContainer?: HTMLElement;
|
|
10
|
+
autoScroll?: AutoScroll;
|
|
11
|
+
startPosition?: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
get separators(): HTMLElement[] | undefined;
|
|
16
|
+
get draggingContainerIndex(): number | undefined;
|
|
17
|
+
constructor(editor: OnesEditor);
|
|
18
|
+
destroy(): void;
|
|
19
|
+
private handleMouseDown;
|
|
20
|
+
private previewShouldScale;
|
|
21
|
+
private initContainerPreview;
|
|
22
|
+
private handleDragStart;
|
|
23
|
+
private handleDrag;
|
|
24
|
+
private handleDragEnd;
|
|
25
|
+
private getClosetSeparator;
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComplexKindBlock, DocBlock } from '../../../@ones-editor/core';
|
|
2
|
+
export interface LayoutDocBlock extends DocBlock {
|
|
3
|
+
children: string[];
|
|
4
|
+
colsWidth: number[];
|
|
5
|
+
}
|
|
6
|
+
export type LayoutKindBlock = ComplexKindBlock;
|
|
7
|
+
export type LayoutDropData = {
|
|
8
|
+
isValidColumnDragging: boolean;
|
|
9
|
+
position: number;
|
|
10
|
+
};
|
|
11
|
+
export interface CreateLayoutData {
|
|
12
|
+
colCount?: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BlockCommands, BlockElement, CommandItem, OnesEditor } from '../../../../../@ones-editor/core';
|
|
2
|
+
import type { CommandItemType } from '../../../../../@ones-editor/core';
|
|
3
|
+
export default class ImageHoveringToolbarCommands implements BlockCommands {
|
|
4
|
+
protected editor: OnesEditor;
|
|
5
|
+
protected block: BlockElement;
|
|
6
|
+
group: string;
|
|
7
|
+
constructor(editor: OnesEditor, block: BlockElement);
|
|
8
|
+
_commands: ({
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
icon: string;
|
|
12
|
+
type?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: CommandItemType;
|
|
17
|
+
icon?: undefined;
|
|
18
|
+
})[];
|
|
19
|
+
private createIconItem;
|
|
20
|
+
get commands(): CommandItem[];
|
|
21
|
+
executeCommand(editor: OnesEditor, block: BlockElement, item: CommandItem): void;
|
|
22
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DocBlock, DocObject } from '../../../../@ones-editor/core';
|
|
2
2
|
import { CalcCell } from './table';
|
|
3
|
+
import { CalcCol } from './layout';
|
|
3
4
|
import { BlockObject, CodeObject, ExportState, GetDocByBlockFunc, GetTextsByBoxFunc, MD5Func } from './types';
|
|
4
5
|
/**
|
|
5
6
|
* 生成docx/html blocks的接口
|
|
@@ -20,6 +21,7 @@ export interface BlocksGenerator {
|
|
|
20
21
|
addTableMatrix(colsWidth: number[], matrix: CalcCell[][], data: DocObject): Promise<void>;
|
|
21
22
|
addVirtualBlock(blockId: string, data: DocObject, maxWidth: number): Promise<void>;
|
|
22
23
|
addEmptyParagraph(): void;
|
|
24
|
+
addLayoutMatrix(colsWidth: number[], matrix: CalcCol[], data: DocObject): Promise<void>;
|
|
23
25
|
}
|
|
24
26
|
export declare function convertBlocksOfDoc(parent: string, // 父节点,暂时只有list block需要这个
|
|
25
27
|
blocks: DocBlock[], data: DocObject, // 协作笔记里的block数组
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DocBlock } from '../../../../@ones-editor/core';
|
|
2
|
+
export interface CalcCol {
|
|
3
|
+
cellId: string | undefined;
|
|
4
|
+
originalWidth: number;
|
|
5
|
+
width: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 处理分栏数据结构:实际就是一行多列的表格数据
|
|
9
|
+
*/
|
|
10
|
+
export declare function buildLayoutMatrix(block: DocBlock, maxWidth: number): CalcCol[];
|