@ones-editor/editor 2.0.2 → 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.
Files changed (56) hide show
  1. package/@ones-editor/block-menu/src/block-menu/items/insert-block-items/index.d.ts +1 -1
  2. package/@ones-editor/block-menu/src/block-menu-button/drag-preview/element-to-data-url.d.ts +1 -1
  3. package/@ones-editor/block-menu/src/block-menu-button/index.d.ts +5 -15
  4. package/@ones-editor/block-menu/src/block-menu-button/menu-button/index.d.ts +32 -0
  5. package/@ones-editor/comments/src/comments-list/mini-comment/mini-comments-list.d.ts +1 -1
  6. package/@ones-editor/core/src/core/blocks/common/block-wrapper.d.ts +2 -1
  7. package/@ones-editor/core/src/core/blocks/common/insert-empty-block.d.ts +2 -1
  8. package/@ones-editor/core/src/core/composition/editor-input.d.ts +1 -0
  9. package/@ones-editor/core/src/core/doc/apply-data-delta.d.ts +1 -0
  10. package/@ones-editor/core/src/core/doc/doc.d.ts +21 -0
  11. package/@ones-editor/core/src/core/types.d.ts +43 -2
  12. package/@ones-editor/core/src/helper/hovering-block.d.ts +1 -1
  13. package/@ones-editor/drop-target/src/drop-indicator.d.ts +3 -2
  14. package/@ones-editor/drop-target/src/drop-target.d.ts +2 -1
  15. package/@ones-editor/drop-target/src/find-drop-target.d.ts +1 -1
  16. package/@ones-editor/drop-target/src/index.d.ts +2 -1
  17. package/@ones-editor/image-embed/src/drag-drop/handle-drop-over.d.ts +1 -4
  18. package/@ones-editor/image-embed/src/drag-drop/handle-drop.d.ts +1 -0
  19. package/@ones-editor/image-embed/src/hovering-toolbar/index.d.ts +22 -0
  20. package/@ones-editor/image-embed/src/image-object.d.ts +1 -0
  21. package/@ones-editor/image-embed/src/index.d.ts +5 -1
  22. package/@ones-editor/image-embed/src/types.d.ts +1 -0
  23. package/@ones-editor/layout-block/package.json +8 -0
  24. package/@ones-editor/layout-block/src/block-drop.d.ts +3 -0
  25. package/@ones-editor/layout-block/src/caption.d.ts +8 -0
  26. package/@ones-editor/layout-block/src/child-containers.d.ts +3 -0
  27. package/@ones-editor/layout-block/src/column-resizer/index.d.ts +2 -0
  28. package/@ones-editor/layout-block/src/constants.d.ts +32 -0
  29. package/@ones-editor/layout-block/src/index.d.ts +5 -0
  30. package/@ones-editor/layout-block/src/layout-creator/index.d.ts +27 -0
  31. package/@ones-editor/layout-block/src/layout-operations.d.ts +11 -0
  32. package/@ones-editor/layout-block/src/locale/en-us.d.ts +10 -0
  33. package/@ones-editor/layout-block/src/locale/index.d.ts +1 -0
  34. package/@ones-editor/layout-block/src/locale/ja-jp.d.ts +10 -0
  35. package/@ones-editor/layout-block/src/locale/zh-cn.d.ts +10 -0
  36. package/@ones-editor/layout-block/src/options.d.ts +2 -0
  37. package/@ones-editor/layout-block/src/paste.d.ts +7 -0
  38. package/@ones-editor/layout-block/src/percent-bar.d.ts +3 -0
  39. package/@ones-editor/layout-block/src/selection.d.ts +5 -0
  40. package/@ones-editor/layout-block/src/toolbar.d.ts +26 -0
  41. package/@ones-editor/layout-block/src/types.d.ts +13 -0
  42. package/@ones-editor/layout-block/src/utils.d.ts +2 -0
  43. package/@ones-editor/media-embed/src/core/hovering-toolbar/index.d.ts +22 -0
  44. package/@ones-editor/table-block/src/index.d.ts +1 -0
  45. package/@ones-editor/table-block/src/table-block/table-creator/index.d.ts +1 -1
  46. package/@ones-editor/to-docx/src/doc2other/core.d.ts +2 -0
  47. package/@ones-editor/to-docx/src/doc2other/layout.d.ts +10 -0
  48. package/@ones-editor/toc/src/build-toc.d.ts +1 -0
  49. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  50. package/@ones-editor/ui/src/quick-menu/basic-menu-items.d.ts +1 -1
  51. package/@ones-editor/ui/src/quick-menu/index.d.ts +6 -1
  52. package/@ones-editor/ui/src/quick-menu/quick-menu-items.d.ts +4 -2
  53. package/@ones-editor/ui/src/quick-menu/types.d.ts +1 -0
  54. package/@ones-editor/ui-base/src/icons/index.d.ts +3 -1
  55. package/dist/index.js +214 -203
  56. 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 { BlockElement, OnesEditor } from '../../../../@ones-editor/core';
2
- import EmptyBlockMenu from '../empty-block-menu';
3
- import BlockMenu from '../block-menu';
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
- buttonElement: HTMLButtonElement;
7
- emptyBlockMenu: EmptyBlockMenu;
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,6 +1,6 @@
1
1
  import { OnesEditor } from '../../../../../@ones-editor/core';
2
2
  import { TypedEmitter } from 'tiny-typed-emitter';
3
- import { OnesEditorCommentsEvents, OnesEditorCommentsProvider } from '../../types';
3
+ import type { OnesEditorCommentsEvents, OnesEditorCommentsProvider } from '../../types';
4
4
  import { MiniGroupList } from './group-list';
5
5
  interface MiniCommentsListEvents {
6
6
  onMiniCommentClose: () => void;
@@ -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;
@@ -33,6 +33,7 @@ export declare class EditorInput implements OnesEditorInput {
33
33
  focus(): void;
34
34
  isInDisableScrollMask(target: HTMLElement): boolean;
35
35
  handleWindowBlur: () => void;
36
+ handleWindowFocus: () => void;
36
37
  handleDocumentClick: (event: MouseEvent) => void;
37
38
  handleDocumentSelectionChange: () => void;
38
39
  handleEditorSelectionChanged: () => void;
@@ -5,4 +5,5 @@ export declare function applyBlockDataDelta(oldData: DocBlock, delta: DocBlockDe
5
5
  id: string;
6
6
  text?: import("./doc").DocBlockText | undefined;
7
7
  children?: string[] | undefined;
8
+ exportSpec?: import("./doc").DocExportSpec[] | undefined;
8
9
  };
@@ -23,11 +23,32 @@ export type DocBlockTextActions = DocBlockTextActionOp[];
23
23
  export type DocBlockAttributes = {
24
24
  [index: string]: unknown;
25
25
  };
26
+ export type ExportDSpecText = {
27
+ type: 'text';
28
+ data: string;
29
+ };
30
+ export type ExportDSpecImage = {
31
+ type: 'image';
32
+ data: string;
33
+ };
34
+ export type ExportDSpecLink = {
35
+ type: 'link';
36
+ data: {
37
+ url: string;
38
+ title: string;
39
+ };
40
+ };
41
+ export type ExportDSpecBlock = {
42
+ type: 'block';
43
+ data: string[];
44
+ };
45
+ export type DocExportSpec = ExportDSpecText | ExportDSpecImage | ExportDSpecLink | ExportDSpecBlock;
26
46
  export type DocBlock = {
27
47
  type: string;
28
48
  id: string;
29
49
  text?: DocBlockText;
30
50
  children?: string[];
51
+ exportSpec?: DocExportSpec[];
31
52
  } & DocBlockAttributes;
32
53
  export type DocEmbedData = {
33
54
  [index: string]: unknown;
@@ -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 DropInsertPos = 'before' | 'after' | CustomDropInsertPos;
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: number, y: number): BlockElement | null;
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 };
@@ -6,6 +6,7 @@ export interface ImageOptions {
6
6
  callbacks?: {
7
7
  onError?: (editor: OnesEditor, error: Error) => void;
8
8
  };
9
+ onPreview?: (editor: OnesEditor, event: MouseEvent) => void;
9
10
  }
10
11
  export interface ImageEmbedData extends DocEmbedData {
11
12
  src: string | string[];
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@ones-editor/layout-block",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "main": "./src/index.ts",
7
+ "types": "src/index.d.ts"
8
+ }
@@ -0,0 +1,3 @@
1
+ import { LayoutKindBlock } from './types';
2
+ export declare const handleDrop: LayoutKindBlock['handleDrop'];
3
+ export declare const handleDropOver: LayoutKindBlock['handleDropOver'];
@@ -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,3 @@
1
+ import { BlockElement, ContainerElement } from '../../../@ones-editor/core';
2
+ export declare function getChildContainers(block: BlockElement, from?: string, to?: string): ContainerElement[];
3
+ export declare function getChildSeparators(block: BlockElement): HTMLElement[];
@@ -0,0 +1,2 @@
1
+ import { OnesEditor } from '../../../../@ones-editor/core';
2
+ export default function initLayoutColumnWidthDragger(editor: OnesEditor): void;
@@ -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,5 @@
1
+ import './locale';
2
+ import './layout-styles.scss';
3
+ import { LayoutKindBlock } from './types';
4
+ export declare const LayoutBlock: LayoutKindBlock;
5
+ export * from './paste';
@@ -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,10 @@
1
+ declare const _default: {
2
+ layout: {
3
+ title: string;
4
+ columnDrag: string;
5
+ insertColumn: string;
6
+ selectColumn: string;
7
+ currentCols: string;
8
+ };
9
+ };
10
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ layout: {
3
+ title: string;
4
+ columnDrag: string;
5
+ insertColumn: string;
6
+ selectColumn: string;
7
+ currentCols: string;
8
+ };
9
+ };
10
+ export default _default;
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ layout: {
3
+ title: string;
4
+ columnDrag: string;
5
+ insertColumn: string;
6
+ selectColumn: string;
7
+ currentCols: string;
8
+ };
9
+ };
10
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { LayoutKindBlock } from './types';
2
+ export declare const getLayoutOptions: Exclude<LayoutKindBlock['getOptions'], undefined>;
@@ -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,3 @@
1
+ import { ContainerElement, OnesEditor } from '../../../@ones-editor/core';
2
+ import { LayoutDocBlock } from './types';
3
+ export declare function createPercentBar(editor: OnesEditor, container: ContainerElement, layoutData: LayoutDocBlock, index: number): void;
@@ -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,2 @@
1
+ import { BlockElement } from '../../../@ones-editor/core';
2
+ export declare function isBlockElement(item: unknown): item is BlockElement;
@@ -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
+ }
@@ -5,3 +5,4 @@ import './table-style.scss';
5
5
  import TableShortcuts from './table-block/table-shortcuts';
6
6
  export * from './types';
7
7
  export { TableBlock, TableBlockCommandProvider, TableShortcuts, includeBigTable };
8
+ export type { CreateTableData } from './table-block/table-creator';