@ones-editor/editor 2.0.4-beta.2 → 2.0.4-beta.20
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-button/index.d.ts +0 -1
- package/@ones-editor/block-menu/src/block-menu-button/menu-button/index.d.ts +3 -12
- package/@ones-editor/core/src/core/blocks/common/insert-empty-block.d.ts +1 -1
- package/@ones-editor/core/src/core/blocks/embed-blocks/embed-block/common.d.ts +1 -0
- package/@ones-editor/core/src/core/containers/children.d.ts +5 -2
- package/@ones-editor/core/src/core/doc/container.d.ts +2 -2
- package/@ones-editor/core/src/core/editor/actions/insert-doc/insert-doc.d.ts +1 -1
- package/@ones-editor/core/src/core/editor-doc/handle-block-data-changed.d.ts +2 -1
- package/@ones-editor/core/src/core/types.d.ts +12 -3
- package/@ones-editor/core/src/helper/hovering-block.d.ts +2 -0
- package/@ones-editor/heading-collapse/src/heading-collapse-button/heading-utils.d.ts +2 -1
- package/@ones-editor/heading-collapse/src/index.d.ts +1 -0
- package/@ones-editor/image-embed/src/image-object.d.ts +2 -0
- package/@ones-editor/layout-block/src/caption.d.ts +3 -3
- package/@ones-editor/layout-block/src/child-containers.d.ts +2 -2
- package/@ones-editor/layout-block/src/constants.d.ts +1 -1
- package/@ones-editor/layout-block/src/index.d.ts +2 -1
- package/@ones-editor/layout-block/src/toolbar.d.ts +9 -2
- package/@ones-editor/layout-block/src/types.d.ts +5 -1
- package/@ones-editor/layout-block/src/utils.d.ts +5 -1
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +189 -189
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
- package/@ones-editor/column-block/package.json +0 -8
- package/@ones-editor/column-block/src/child-containers.d.ts +0 -2
- package/@ones-editor/column-block/src/columns-options.d.ts +0 -2
- package/@ones-editor/column-block/src/columns-properties.d.ts +0 -15
- package/@ones-editor/column-block/src/index.d.ts +0 -4
- package/@ones-editor/column-block/src/types.d.ts +0 -11
- package/@ones-editor/layout-block/src/paste.d.ts +0 -7
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import { BlockElement, OnesEditor } from '../../../../../@ones-editor/core';
|
|
2
2
|
import EmptyBlockMenu from '../../empty-block-menu';
|
|
3
3
|
import BlockMenu from '../../block-menu';
|
|
4
|
-
export declare enum MenuButtonType {
|
|
5
|
-
ROOT = "root",
|
|
6
|
-
PARENT = "parent"
|
|
7
|
-
}
|
|
8
4
|
export default class OnesEditorBlockMenuButton {
|
|
9
5
|
private editor;
|
|
10
|
-
private menuType;
|
|
11
6
|
buttonElement: HTMLButtonElement;
|
|
12
7
|
emptyBlockMenu: EmptyBlockMenu;
|
|
13
8
|
blockMenu: BlockMenu;
|
|
14
9
|
private dragHandler;
|
|
15
|
-
|
|
16
|
-
private removeButtonDelay;
|
|
17
|
-
private shouldRemoveParentButton;
|
|
18
|
-
private removeTimer;
|
|
19
|
-
constructor(editor: OnesEditor, menuType: MenuButtonType);
|
|
10
|
+
constructor(editor: OnesEditor);
|
|
20
11
|
destroy(): void;
|
|
21
|
-
handleHoverBlock: (hoverBlock: BlockElement | null, oldBlock: BlockElement | null,
|
|
12
|
+
handleHoverBlock: (hoverBlock: BlockElement | null, oldBlock: BlockElement | null, target: EventTarget | null, oldTarget: EventTarget | null) => void;
|
|
22
13
|
showRootButton(hoverBlock: BlockElement): void;
|
|
23
|
-
showParentButton(hoverBlock: BlockElement):
|
|
14
|
+
showParentButton(hoverBlock: BlockElement): boolean;
|
|
24
15
|
removeParentButton: () => void;
|
|
25
16
|
addButtonToView(block: BlockElement): void;
|
|
26
17
|
handleButtonClick: () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ContainerBlockOverrideInsertEmptyBlockInsideOptions, OnesEditor } from '../../types';
|
|
2
2
|
export declare function getContainerBlockOverrideOptions(editor: OnesEditor, containerID: string, blockType?: string): ContainerBlockOverrideInsertEmptyBlockInsideOptions | undefined;
|
|
3
3
|
export declare function insertEmptyEmbedBlock(editor: OnesEditor, embedType: string, containerId: string, blockIndex: number, data?: Record<string, unknown>): Promise<import("../../types").BlockElement | null>;
|
|
4
|
-
export declare function insertEmptyBlock(editor: OnesEditor, type: string, containerId: string, blockIndex: number, data?: Record<string, unknown>): Promise<import("../../types").BlockElement | null> | null;
|
|
4
|
+
export declare function insertEmptyBlock(editor: OnesEditor, type: string, containerId: string, blockIndex: number, data?: Record<string, unknown>, item?: Record<string, unknown>): Promise<import("../../types").BlockElement | null> | null;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { BlockElement, ContainerElement } from '../types';
|
|
2
|
-
export declare function getChildBlocks(container: ContainerElement
|
|
1
|
+
import { BlockElement, ContainerElement, OnesEditor } from '../types';
|
|
2
|
+
export declare function getChildBlocks(container: ContainerElement, traverseChild?: {
|
|
3
|
+
condition: (block: BlockElement) => boolean;
|
|
4
|
+
editor: OnesEditor;
|
|
5
|
+
}): BlockElement[];
|
|
3
6
|
export declare function getFirstChildBlock(container: ContainerElement): BlockElement;
|
|
4
7
|
export declare function getLastChildBlock(container: ContainerElement): BlockElement;
|
|
5
8
|
export declare function getChildBlockCount(container: ContainerElement): number;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DocBlock, OnesEditorDoc } from './doc';
|
|
2
|
-
export declare function createContainer(doc: OnesEditorDoc,
|
|
1
|
+
import { DocBlock, DocObject, OnesEditorDoc } from './doc';
|
|
2
|
+
export declare function createContainer(doc: OnesEditorDoc, docsOrDocObject: DocBlock[] | DocObject): string;
|
|
3
3
|
export declare function createEmptyContainer(doc: OnesEditorDoc, text?: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DocObject } from '../../../doc';
|
|
2
2
|
import { BlockElement, CloneBlockResultInfo, ContainerElement, OnesEditor } from '../../../types';
|
|
3
3
|
export declare function editorInsertDoc(editor: OnesEditor, block: BlockElement, offset: number, insertedDoc: DocObject, cloneDocResult?: CloneBlockResultInfo): void;
|
|
4
|
-
export declare function editorInsertDocAt(editor: OnesEditor, container: ContainerElement, blockIndex: number,
|
|
4
|
+
export declare function editorInsertDocAt(editor: OnesEditor, container: ContainerElement, blockIndex: number, _docToInsert: DocObject, cloneDocResult?: CloneBlockResultInfo): BlockElement[];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { DocBlockDelta } from '../doc';
|
|
1
2
|
import { OnesEditor } from '../types';
|
|
2
|
-
export declare function onBlockDataChanged(editor: OnesEditor, containerId: string, blockIndex: number): void;
|
|
3
|
+
export declare function onBlockDataChanged(editor: OnesEditor, containerId: string, blockIndex: number, delta?: DocBlockDelta): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
2
|
-
import { DocBlock, DocBlockAttributes, DocBlocks, DocBlockText, DocBlockTextAttributes, DocBox, DocEmbedBlock, DocEmbedData, DocInsertion, DocObject, InsertBlockOptions, OnesEditorDoc, OnesEditorDocRange } from './doc';
|
|
2
|
+
import { DocBlock, DocBlockAttributes, DocBlockDelta, DocBlocks, DocBlockText, DocBlockTextAttributes, DocBox, DocEmbedBlock, DocEmbedData, DocInsertion, DocObject, InsertBlockOptions, OnesEditorDoc, OnesEditorDocRange } from './doc';
|
|
3
3
|
export type ContainerElement = HTMLDivElement & {
|
|
4
4
|
__neverUse: 'ContainerElement';
|
|
5
5
|
};
|
|
@@ -177,6 +177,9 @@ export interface BlockProperties {
|
|
|
177
177
|
blockCommands?: Record<string, BlockCommands>;
|
|
178
178
|
abstract?: string;
|
|
179
179
|
}
|
|
180
|
+
export interface DropHandler {
|
|
181
|
+
handleDrop: (editor: OnesEditor, dragData: BlockElement | File[], targetContainer: ContainerElement, blockIndex: number) => boolean | undefined;
|
|
182
|
+
}
|
|
180
183
|
export interface CombineToCreateOptions {
|
|
181
184
|
/**
|
|
182
185
|
* @returns sideway: 两侧合并(左右 indicator)
|
|
@@ -184,7 +187,7 @@ export interface CombineToCreateOptions {
|
|
|
184
187
|
* body: 中间合并(target block 激活)(暂未实现)
|
|
185
188
|
*/
|
|
186
189
|
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;
|
|
190
|
+
onCombine: (editor: OnesEditor, source: BlockElement, target: BlockElement, position: CombineDropInsertPos['pos'], dragObject: DragObject | null, handlers: DropHandler[]) => BlockElement | undefined;
|
|
188
191
|
}
|
|
189
192
|
export type ContainerBlockOverrideInsertEmptyBlockInsideOptionsDict = Record<string, ContainerBlockOverrideInsertEmptyBlockInsideOptions>;
|
|
190
193
|
export type ContainerBlockOverrideInsertEmptyBlockInsideOptions = {
|
|
@@ -210,6 +213,11 @@ export interface BlockOptions {
|
|
|
210
213
|
showLocker?: boolean;
|
|
211
214
|
};
|
|
212
215
|
findPreviewElement?: (editor: OnesEditor, complexBlock: BlockElement) => HTMLElement;
|
|
216
|
+
headingCollapsable?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* 拖拽时,是否显示缩略图容器自带的阴影,默认为 false
|
|
219
|
+
*/
|
|
220
|
+
previewNoShadow?: boolean;
|
|
213
221
|
}
|
|
214
222
|
export interface StandardDragObject {
|
|
215
223
|
type: 'block';
|
|
@@ -258,7 +266,7 @@ export interface Block {
|
|
|
258
266
|
handleBlockElementUpdated?: (editor: OnesEditor, block: BlockElement, blockData: DocBlock) => void;
|
|
259
267
|
handleContainerResized?: (editor: OnesEditor, block: BlockElement) => void;
|
|
260
268
|
handleDeleteBlock?: (editor: OnesEditor, block: BlockElement, local: boolean, options: DeleteBlockEventOptions) => void;
|
|
261
|
-
handleUpdateBlock?: (editor: OnesEditor, block: BlockElement, blockData: DocBlock) => boolean;
|
|
269
|
+
handleUpdateBlock?: (editor: OnesEditor, block: BlockElement, blockData: DocBlock, delta?: DocBlockDelta) => boolean;
|
|
262
270
|
handleDropOver?: (editor: OnesEditor, block: BlockElement, dragData: DragObject | DataTransferItemList | null, x: number, y: number) => DropInsertPos | false | undefined;
|
|
263
271
|
handleDrop?: (editor: OnesEditor, block: BlockElement, dragData: DragObject | File[], insertPos: DropInsertPos, options: DropOptions) => boolean | ContainerElement | undefined;
|
|
264
272
|
getClientRects?: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => DOMRect[];
|
|
@@ -299,6 +307,7 @@ export interface ComplexKindBlock extends Block {
|
|
|
299
307
|
getTextToolbarReferenceClient?: (editor: OnesEditor, complexBlock: BlockElement) => DOMRect | undefined;
|
|
300
308
|
isChildContainerVisible?: (editor: OnesEditor, complexBlock: BlockElement, childContainer: ContainerElement) => boolean;
|
|
301
309
|
showChildContainer?: (editor: OnesEditor, complexBlock: BlockElement, childContainer: ContainerElement) => void;
|
|
310
|
+
beforeInsertDoc?: (editor: OnesEditor, container: ContainerElement, insertDoc: DocObject) => DocObject | undefined;
|
|
302
311
|
}
|
|
303
312
|
export interface SelectedBlock {
|
|
304
313
|
block: BlockElement;
|
|
@@ -3,6 +3,7 @@ import type { TextBlockContentChild } from '../core/blocks/text-blocks/base/chil
|
|
|
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;
|
|
6
|
+
targetChange: (block: BlockElement | null, old: BlockElement | null, target: EventTarget | null, oldTarget: EventTarget | null) => void;
|
|
6
7
|
childChange: (block: BlockElement | null, child: TextBlockContentChild | null, old: TextBlockContentChild | null, event: MouseEvent) => void;
|
|
7
8
|
}
|
|
8
9
|
export interface OnesEditorHoveringBlockFilter extends OnesEditorCustom {
|
|
@@ -14,6 +15,7 @@ export interface OnesEditorHoveringBlockFinder extends OnesEditorCustom {
|
|
|
14
15
|
export default class OnesEditorHoveringBlock extends TypedEmitter<OnesEditorHoveringBlockEvents> {
|
|
15
16
|
private editor;
|
|
16
17
|
private hoveringBlock;
|
|
18
|
+
private hoveringElem;
|
|
17
19
|
private hoveringTextChild;
|
|
18
20
|
private filters;
|
|
19
21
|
private finders;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { BlockElement } from '../../../../@ones-editor/core';
|
|
1
|
+
import { BlockElement, OnesEditor } from '../../../../@ones-editor/core';
|
|
2
2
|
export declare function isTitleBlock(block: BlockElement): boolean;
|
|
3
|
+
export declare function canShowCollapseButtons(editor: OnesEditor, hoverBlock: BlockElement | null): boolean;
|
|
@@ -11,6 +11,8 @@ export declare class ImageObject implements ImageObjectBase {
|
|
|
11
11
|
private parentContainerResizerObserver;
|
|
12
12
|
private autoFix;
|
|
13
13
|
focusTimes: number;
|
|
14
|
+
mouseStartX: number;
|
|
15
|
+
mouseStartY: number;
|
|
14
16
|
constructor(editor: OnesEditor, blockData: DocEmbedBlock);
|
|
15
17
|
destroy(): void;
|
|
16
18
|
setAutoFix(autoFix: boolean): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OnesEditorInputHandler, OnesEditorCustom, OnesEditor, OnesEditorDocs } from '../../../@ones-editor/core';
|
|
2
|
-
export
|
|
2
|
+
export declare class LayoutBlockCaptionInputHandler implements OnesEditorInputHandler, OnesEditorCustom {
|
|
3
3
|
private editor;
|
|
4
|
-
|
|
4
|
+
private skipForRootContainer;
|
|
5
|
+
constructor(editor: OnesEditor, skipForRootContainer?: boolean);
|
|
5
6
|
destroy(): void;
|
|
6
7
|
handleBeforePaste(editor: OnesEditor, event: ClipboardEvent | null, docs: OnesEditorDocs): Promise<boolean>;
|
|
7
|
-
static init(editor: OnesEditor): void;
|
|
8
8
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BlockElement, ContainerElement } from '../../../@ones-editor/core';
|
|
2
|
-
export declare function getChildContainers(block: BlockElement, from?: string, to?: string): ContainerElement[];
|
|
1
|
+
import { BlockElement, ContainerElement, OnesEditor } from '../../../@ones-editor/core';
|
|
2
|
+
export declare function getChildContainers(editor: OnesEditor, block: BlockElement, from?: string, to?: string): ContainerElement[];
|
|
3
3
|
export declare function getChildSeparators(block: BlockElement): HTMLElement[];
|
|
@@ -9,7 +9,7 @@ export declare const LAYOUT_SHORTCUT_ID = "insert-layout";
|
|
|
9
9
|
/**
|
|
10
10
|
* 快捷键提示
|
|
11
11
|
*/
|
|
12
|
-
export declare const LAYOUT_SHORTCUT_SUBTEXT = "/
|
|
12
|
+
export declare const LAYOUT_SHORTCUT_SUBTEXT = "/column";
|
|
13
13
|
export declare const LAYOUT_BLOCK_TYPE = "layout";
|
|
14
14
|
/**
|
|
15
15
|
* 最大分栏数
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { OnesEditor, BlockElement, AutoScroll, OnesEditorCustom, ContainerElement } from '../../../@ones-editor/core';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
2
|
+
import { Instance } from 'tippy.js';
|
|
3
|
+
export declare function createSeparatorContainer(editor: OnesEditor, blockElement: BlockElement, index: number): HTMLDivElement;
|
|
4
|
+
export declare function createActionBar(editor: OnesEditor, containerID: string, _blockElement: BlockElement, columnRemovable?: boolean): {
|
|
5
|
+
actionBarContainer: HTMLDivElement;
|
|
6
|
+
tippyInstance?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
actionBarContainer: HTMLDivElement;
|
|
9
|
+
tippyInstance: Instance<import("tippy.js").Props>;
|
|
10
|
+
};
|
|
4
11
|
export declare function elementToDataUrl(editor: OnesEditor, element: HTMLElement): Promise<string>;
|
|
5
12
|
export declare class OnesEditorCustomLayoutDragHandler implements OnesEditorCustom {
|
|
6
13
|
private editor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComplexKindBlock, DocBlock } from '../../../@ones-editor/core';
|
|
1
|
+
import { ComplexKindBlock, DocBlock, OnesEditor } from '../../../@ones-editor/core';
|
|
2
2
|
export interface LayoutDocBlock extends DocBlock {
|
|
3
3
|
children: string[];
|
|
4
4
|
colsWidth: number[];
|
|
@@ -11,3 +11,7 @@ export type LayoutDropData = {
|
|
|
11
11
|
export interface CreateLayoutData {
|
|
12
12
|
colCount?: number;
|
|
13
13
|
}
|
|
14
|
+
export interface EditorConfigLayoutOptions {
|
|
15
|
+
onColumnCreated?: (editor: OnesEditor, count: number) => void;
|
|
16
|
+
onColumnWidthChange?: (editor: OnesEditor, count: number, index: number, colsWidth: number[]) => void;
|
|
17
|
+
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import { BlockElement } from '../../../@ones-editor/core';
|
|
1
|
+
import { BlockElement, ContainerElement, DocBlock, DocObject, OnesEditor } from '../../../@ones-editor/core';
|
|
2
2
|
export declare function isBlockElement(item: unknown): item is BlockElement;
|
|
3
|
+
export declare function isLayoutBlock(block: BlockElement): boolean;
|
|
4
|
+
export declare function flattenLayoutBlockIfExists(_docObject: DocObject, containerID?: string): DocBlock[];
|
|
5
|
+
export declare function currentCaptionInRootContainer(editor: OnesEditor): boolean;
|
|
6
|
+
export declare function getClosetLayoutContainer(block: BlockElement | undefined): ContainerElement | undefined;
|