@ones-editor/editor 2.0.5 → 2.0.6-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) 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 +4 -15
  4. package/@ones-editor/block-menu/src/block-menu-button/menu-button/index.d.ts +23 -0
  5. package/@ones-editor/core/src/core/blocks/common/block-wrapper.d.ts +2 -1
  6. package/@ones-editor/core/src/core/blocks/common/insert-empty-block.d.ts +3 -2
  7. package/@ones-editor/core/src/core/blocks/embed-blocks/embed-block/common.d.ts +1 -0
  8. package/@ones-editor/core/src/core/containers/children.d.ts +5 -2
  9. package/@ones-editor/core/src/core/doc/container.d.ts +2 -2
  10. package/@ones-editor/core/src/core/editor/actions/insert-doc/insert-doc.d.ts +1 -1
  11. package/@ones-editor/core/src/core/editor-doc/handle-block-data-changed.d.ts +2 -1
  12. package/@ones-editor/core/src/core/selection/editor-selection.d.ts +1 -3
  13. package/@ones-editor/core/src/core/types.d.ts +59 -7
  14. package/@ones-editor/core/src/helper/hovering-block.d.ts +3 -1
  15. package/@ones-editor/core/src/utils/data-url.d.ts +1 -0
  16. package/@ones-editor/drop-target/src/drop-indicator.d.ts +3 -2
  17. package/@ones-editor/drop-target/src/drop-target.d.ts +2 -1
  18. package/@ones-editor/drop-target/src/find-drop-target.d.ts +1 -1
  19. package/@ones-editor/drop-target/src/index.d.ts +2 -1
  20. package/@ones-editor/find-dialog/src/shortcuts.d.ts +0 -2
  21. package/@ones-editor/graph-embed/src/helper/graph-base.d.ts +1 -1
  22. package/@ones-editor/graph-embed/src/helper/graph-block-commands.d.ts +3 -1
  23. package/@ones-editor/heading-collapse/src/heading-collapse-button/heading-utils.d.ts +2 -1
  24. package/@ones-editor/heading-collapse/src/index.d.ts +1 -0
  25. package/@ones-editor/image-embed/src/drag-drop/handle-drop-over.d.ts +1 -4
  26. package/@ones-editor/image-embed/src/drag-drop/handle-drop.d.ts +1 -0
  27. package/@ones-editor/image-embed/src/hovering-toolbar/index.d.ts +22 -0
  28. package/@ones-editor/image-embed/src/image-dom/download-image.d.ts +2 -0
  29. package/@ones-editor/image-embed/src/image-object.d.ts +3 -0
  30. package/@ones-editor/image-embed/src/index.d.ts +5 -1
  31. package/@ones-editor/image-embed/src/types.d.ts +1 -0
  32. package/@ones-editor/input-handlers/src/enforce-with-document-title/enforce-with-document-title-handler.d.ts +0 -1
  33. package/@ones-editor/input-handlers/src/enforce-with-document-title/placeholder.d.ts +0 -1
  34. package/@ones-editor/{column-block → layout-block}/package.json +1 -1
  35. package/@ones-editor/layout-block/src/block-drop.d.ts +3 -0
  36. package/@ones-editor/layout-block/src/caption.d.ts +8 -0
  37. package/@ones-editor/layout-block/src/child-containers.d.ts +3 -0
  38. package/@ones-editor/layout-block/src/column-resizer/index.d.ts +2 -0
  39. package/@ones-editor/layout-block/src/constants.d.ts +32 -0
  40. package/@ones-editor/layout-block/src/index.d.ts +6 -0
  41. package/@ones-editor/layout-block/src/layout-creator/index.d.ts +27 -0
  42. package/@ones-editor/layout-block/src/layout-operations.d.ts +11 -0
  43. package/@ones-editor/layout-block/src/locale/en-us.d.ts +10 -0
  44. package/@ones-editor/layout-block/src/locale/index.d.ts +1 -0
  45. package/@ones-editor/layout-block/src/locale/ja-jp.d.ts +10 -0
  46. package/@ones-editor/layout-block/src/locale/zh-cn.d.ts +10 -0
  47. package/@ones-editor/layout-block/src/options.d.ts +2 -0
  48. package/@ones-editor/layout-block/src/percent-bar.d.ts +3 -0
  49. package/@ones-editor/layout-block/src/selection.d.ts +5 -0
  50. package/@ones-editor/layout-block/src/toolbar.d.ts +33 -0
  51. package/@ones-editor/layout-block/src/types.d.ts +17 -0
  52. package/@ones-editor/layout-block/src/utils.d.ts +6 -0
  53. package/@ones-editor/media-embed/src/core/hovering-toolbar/index.d.ts +22 -0
  54. package/@ones-editor/misc/src/image.d.ts +1 -0
  55. package/@ones-editor/table-block/src/index.d.ts +1 -0
  56. package/@ones-editor/table-block/src/table-block/table-creator/index.d.ts +1 -1
  57. package/@ones-editor/to-docx/src/doc2other/core.d.ts +2 -0
  58. package/@ones-editor/to-docx/src/doc2other/layout.d.ts +10 -0
  59. package/@ones-editor/toc/src/build-toc.d.ts +1 -0
  60. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  61. package/@ones-editor/ui/src/quick-menu/basic-menu-items.d.ts +1 -1
  62. package/@ones-editor/ui/src/quick-menu/index.d.ts +6 -1
  63. package/@ones-editor/ui/src/quick-menu/quick-menu-items.d.ts +4 -2
  64. package/@ones-editor/ui/src/quick-menu/types.d.ts +1 -0
  65. package/@ones-editor/ui/src/toolbar/toolbar-handler.d.ts +1 -0
  66. package/@ones-editor/ui-base/src/icons/index.d.ts +4 -1
  67. package/@ones-editor/versions/src/types.d.ts +1 -1
  68. package/dist/index.d.ts +1 -0
  69. package/dist/index.js +218 -204
  70. package/dist/types.d.ts +2 -0
  71. package/package.json +1 -1
  72. package/@ones-editor/column-block/src/child-containers.d.ts +0 -2
  73. package/@ones-editor/column-block/src/columns-options.d.ts +0 -2
  74. package/@ones-editor/column-block/src/columns-properties.d.ts +0 -15
  75. package/@ones-editor/column-block/src/index.d.ts +0 -4
  76. package/@ones-editor/column-block/src/types.d.ts +0 -11
  77. package/@ones-editor/list-block/src/converter/selection-to-doc.d.ts +0 -2
@@ -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,8 @@
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;
10
6
  constructor(editor: OnesEditor);
11
7
  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
8
  }
@@ -0,0 +1,23 @@
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 {
5
+ private editor;
6
+ buttonElement: HTMLButtonElement;
7
+ emptyBlockMenu: EmptyBlockMenu;
8
+ blockMenu: BlockMenu;
9
+ private dragHandler;
10
+ constructor(editor: OnesEditor);
11
+ destroy(): void;
12
+ handleHoverBlock: (hoverBlock: BlockElement | null, oldBlock: BlockElement | null, target: EventTarget | null, oldTarget: EventTarget | null) => void;
13
+ showRootButton(hoverBlock: BlockElement): void;
14
+ showParentButton(hoverBlock: BlockElement): boolean;
15
+ removeParentButton: () => void;
16
+ addButtonToView(block: BlockElement): void;
17
+ handleButtonClick: () => void;
18
+ updatePlaceholder: (block: BlockElement) => void;
19
+ handleChanged: () => void;
20
+ createButton(): HTMLButtonElement;
21
+ setButtonType(type: 'move' | 'insert'): void;
22
+ updateButton(block: BlockElement): void;
23
+ }
@@ -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
- 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,3 +1,4 @@
1
1
  import { BlockElement } from '../../../types';
2
+ export declare function isColumnsBlock(block: BlockElement): boolean;
2
3
  export declare function isEmbedBlock(block: BlockElement): boolean;
3
4
  export declare function getEmbedType(block: BlockElement): string;
@@ -1,5 +1,8 @@
1
- import { BlockElement, ContainerElement } from '../types';
2
- export declare function getChildBlocks(container: ContainerElement): BlockElement[];
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, blocks: DocBlock[]): string;
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, insertedDoc: DocObject, cloneDocResult?: CloneBlockResultInfo): BlockElement[];
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;
@@ -17,9 +17,7 @@ export declare class EditorSelection implements OnesEditorSelection {
17
17
  selectBlock(block: BlockElement, start: number, end?: number, options?: ChangeSelectionOptions): void;
18
18
  setSelection(anchor: BlockPosition, focus?: BlockPosition, options?: ChangeSelectionOptions): SelectionRange;
19
19
  setRange(range: SelectionRange, options?: ChangeSelectionOptions): SelectionRange;
20
- updateSelection(oldRange: SelectionRange | null, options?: {
21
- focusBlockChanged: boolean;
22
- }): void;
20
+ updateSelection(): void;
23
21
  getFocusedPos(): BlockPosition;
24
22
  getAnchorPos(): BlockPosition;
25
23
  selectionChanging(anchor: BlockPosition, focus: BlockPosition): boolean;
@@ -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
  };
@@ -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,14 @@ 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;
155
+ /**
156
+ * defaults to true
157
+ */
158
+ clickToClose?: boolean;
150
159
  }
151
160
  export interface BlockCommandItem extends CommandItem {
152
161
  blockId: string;
@@ -172,10 +181,47 @@ export interface BlockProperties {
172
181
  blockCommands?: Record<string, BlockCommands>;
173
182
  abstract?: string;
174
183
  }
184
+ export interface DropHandler {
185
+ handleDrop: (editor: OnesEditor, dragData: BlockElement | File[], targetContainer: ContainerElement, blockIndex: number) => boolean | undefined;
186
+ }
187
+ export interface CombineToCreateOptions {
188
+ /**
189
+ * @returns sideway: 两侧合并(左右 indicator)
190
+ *
191
+ * body: 中间合并(target block 激活)(暂未实现)
192
+ */
193
+ combinable: (editor: OnesEditor, source: BlockElement, target: BlockElement) => undefined | 'sideway' | 'body';
194
+ onCombine: (editor: OnesEditor, source: BlockElement, target: BlockElement, position: CombineDropInsertPos['pos'], dragObject: DragObject | null, handlers: DropHandler[]) => BlockElement | undefined;
195
+ }
196
+ export type ContainerBlockOverrideInsertEmptyBlockInsideOptionsDict = Record<string, ContainerBlockOverrideInsertEmptyBlockInsideOptions>;
197
+ export type ContainerBlockOverrideInsertEmptyBlockInsideOptions = {
198
+ item?: CommandItem;
199
+ data?: Record<string, unknown>;
200
+ };
175
201
  export interface BlockOptions {
176
202
  name: string;
177
203
  insertBlockCommandItems?: CommandItem[];
204
+ overrideInertEmptyBlockInsideOptions?: ContainerBlockOverrideInsertEmptyBlockInsideOptionsDict;
178
205
  handleInsertEmptyBlock?: (editor: OnesEditor, options: InsertEmptyBlockOptions) => Promise<BlockElement | null>;
206
+ isMenuButtonBaseContainer?: (container: ContainerElement) => boolean;
207
+ combineToCreate?: CombineToCreateOptions;
208
+ /**
209
+ * defaults to true.
210
+ *
211
+ * 'without-margin': include margin for dragging preview computing.
212
+ */
213
+ draggingPreview?: boolean | 'margin-included';
214
+ innerToc?: boolean;
215
+ blockMenu?: {
216
+ showComment?: boolean;
217
+ showLocker?: boolean;
218
+ };
219
+ findPreviewElement?: (editor: OnesEditor, complexBlock: BlockElement) => HTMLElement;
220
+ headingCollapsable?: boolean;
221
+ /**
222
+ * 拖拽时,是否显示缩略图容器自带的阴影,默认为 false
223
+ */
224
+ previewNoShadow?: boolean;
179
225
  }
180
226
  export interface StandardDragObject {
181
227
  type: 'block';
@@ -193,10 +239,17 @@ export interface CustomDragObject {
193
239
  }
194
240
  export type DragObject = StandardDragObject | CustomDragObject;
195
241
  export interface CustomDropInsertPos {
242
+ type: 'custom';
196
243
  rect: DOMRect;
197
244
  data: unknown;
245
+ targetBlock?: BlockElement;
198
246
  }
199
- export type DropInsertPos = 'before' | 'after' | CustomDropInsertPos;
247
+ export type CombineDropInsertPos = {
248
+ type: 'combine';
249
+ pos: 'left' | 'right';
250
+ onCombine: CombineToCreateOptions['onCombine'];
251
+ };
252
+ export type DropInsertPos = 'before' | 'after' | CombineDropInsertPos | CustomDropInsertPos;
200
253
  export interface DropOptions {
201
254
  isSourceBlock: boolean;
202
255
  targetBlock: BlockElement;
@@ -217,9 +270,9 @@ export interface Block {
217
270
  handleBlockElementUpdated?: (editor: OnesEditor, block: BlockElement, blockData: DocBlock) => void;
218
271
  handleContainerResized?: (editor: OnesEditor, block: BlockElement) => void;
219
272
  handleDeleteBlock?: (editor: OnesEditor, block: BlockElement, local: boolean, options: DeleteBlockEventOptions) => void;
220
- handleUpdateBlock?: (editor: OnesEditor, block: BlockElement, blockData: DocBlock) => boolean;
273
+ handleUpdateBlock?: (editor: OnesEditor, block: BlockElement, blockData: DocBlock, delta?: DocBlockDelta) => boolean;
221
274
  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;
275
+ handleDrop?: (editor: OnesEditor, block: BlockElement, dragData: DragObject | File[], insertPos: DropInsertPos, options: DropOptions) => boolean | ContainerElement | undefined;
223
276
  getClientRects?: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => DOMRect[];
224
277
  getMinWidth?: (editor: OnesEditor, block: BlockElement) => number | undefined;
225
278
  convertFrom?: (editor: OnesEditor, srcBlock: BlockElement, options: {
@@ -258,6 +311,7 @@ export interface ComplexKindBlock extends Block {
258
311
  getTextToolbarReferenceClient?: (editor: OnesEditor, complexBlock: BlockElement) => DOMRect | undefined;
259
312
  isChildContainerVisible?: (editor: OnesEditor, complexBlock: BlockElement, childContainer: ContainerElement) => boolean;
260
313
  showChildContainer?: (editor: OnesEditor, complexBlock: BlockElement, childContainer: ContainerElement) => void;
314
+ beforeInsertDoc?: (editor: OnesEditor, container: ContainerElement, insertDoc: DocObject) => DocObject | undefined;
261
315
  }
262
316
  export interface SelectedBlock {
263
317
  block: BlockElement;
@@ -568,9 +622,7 @@ export interface OnesEditorSelection {
568
622
  setSelection: (anchor: BlockPosition, focus?: BlockPosition, options?: ChangeSelectionOptions) => SelectionRange;
569
623
  setRange: (range: SelectionRange, options?: ChangeSelectionOptions) => SelectionRange;
570
624
  selectBlock: (block: BlockElement, start: number, end?: number, options?: ChangeSelectionOptions) => void;
571
- updateSelection: (old: SelectionRange | null, options?: {
572
- focusBlockChanged: boolean;
573
- }) => void;
625
+ updateSelection: (old: SelectionRange | null) => void;
574
626
  updateLastCaretRect: () => void;
575
627
  getSuggestedCaretX: () => number | undefined;
576
628
  getAnchorPos: () => BlockPosition;
@@ -1,8 +1,9 @@
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;
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
1
  export declare function stringToDataUrl(data: string, type: string): Promise<string>;
2
2
  export declare function fileToDataUrl(file: File): Promise<string>;
3
+ export declare function blobToDataUrl(blob: Blob): Promise<string>;
@@ -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,9 +1,7 @@
1
1
  import { OnesEditor } from '../../../@ones-editor/core';
2
2
  import './locale';
3
3
  export declare function handleFindReplace(editor: OnesEditor): boolean;
4
- declare function handleReplaceAndFind(editor: OnesEditor): boolean;
5
4
  declare const FindReplaceShortcuts: {
6
5
  'CtrlOrCmd+F': typeof handleFindReplace;
7
- 'CtrlOrCmd+Shift+H': typeof handleReplaceAndFind;
8
6
  };
9
7
  export { FindReplaceShortcuts, };
@@ -8,7 +8,7 @@ export default abstract class GraphBase {
8
8
  logger: Logger;
9
9
  editing: boolean;
10
10
  private graphEmbedContent;
11
- private status;
11
+ private _status;
12
12
  constructor(editor: OnesEditor, graphType: GraphType, codeEmbedDataKey: string);
13
13
  protected abstract code2ObjectUrl(code: string): Promise<string>;
14
14
  protected abstract code2ResourceId(code: string): Promise<string>;
@@ -1,5 +1,6 @@
1
+ import { BlockElement } from '../../../../@ones-editor/core';
1
2
  import { StandardEmbedBlockCommands } from '../../../../@ones-editor/embed-block-helper';
2
- import type { BlockElement, CommandItem, OnesEditor } from '../../../../@ones-editor/core';
3
+ import type { CommandItem, OnesEditor } from '../../../../@ones-editor/core';
3
4
  import type { StandardEmbedBlockProperties } from '../../../../@ones-editor/embed-block-helper';
4
5
  export type PresetCommandId = 'edit' | 'help';
5
6
  export type GraphType = 'mermaid' | 'flowchart' | 'plantuml';
@@ -12,6 +13,7 @@ declare class GraphBlockCommands extends StandardEmbedBlockCommands<PresetComman
12
13
  group: string;
13
14
  _commands: CommandItem[];
14
15
  constructor(editor: OnesEditor, block: BlockElement, graphType: GraphType, properties?: GraphEmbedBlockProperties | undefined);
16
+ get commands(): CommandItem[];
15
17
  executeCommand(editor: OnesEditor, block: BlockElement, item: CommandItem): void;
16
18
  }
17
19
  export declare function getGraphEmbedBlockProperties(editor: OnesEditor, block: BlockElement, type: 'mermaid' | 'flowchart' | 'plantuml', properties?: GraphEmbedBlockProperties): {
@@ -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;
@@ -3,3 +3,4 @@ import './style.scss';
3
3
  export * from './heading-collapse-button';
4
4
  export * from './keyboard';
5
5
  export * from './doc-event';
6
+ export { isHeadingCollapsed } from './doc-event/collapse-handler';
@@ -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
+ }
@@ -1 +1,3 @@
1
+ import { BlockElement } from '../../../../@ones-editor/core';
1
2
  export declare function downloadImageToFile(src: string): Promise<File | null>;
3
+ export declare function downloadImage(block: BlockElement): void;
@@ -10,6 +10,9 @@ export declare class ImageObject implements ImageObjectBase {
10
10
  private resizing;
11
11
  private parentContainerResizerObserver;
12
12
  private autoFix;
13
+ focusTimes: number;
14
+ mouseStartX: number;
15
+ mouseStartY: number;
13
16
  constructor(editor: OnesEditor, blockData: DocEmbedBlock);
14
17
  destroy(): void;
15
18
  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[];
@@ -12,7 +12,6 @@ declare class EnforceWithDocumentTitleHandler implements OnesEditorInputHandler
12
12
  handleSelectionChange: (editor: OnesEditor) => void;
13
13
  private reload;
14
14
  private applyPlaceholder;
15
- private removePlaceholder;
16
15
  private isDocumentTitleBlock;
17
16
  }
18
17
  export default EnforceWithDocumentTitleHandler;
@@ -3,5 +3,4 @@ import { EnforceWithDocumentTitleHandlerOptions } from './types';
3
3
  export declare function isEmptyTextBlockWithoutCompositionText(editor: OnesEditor, block: BlockElement): boolean;
4
4
  export declare function removePlaceholderFromBlock(editor: OnesEditor, block: BlockElement): void;
5
5
  export declare function applyPlaceholderToBlock(editor: OnesEditor, block: BlockElement, placeholder: string | Element): void;
6
- export declare function removeAllPlaceholders(editor: OnesEditor): void;
7
6
  export declare function applyPlaceholder(editor: OnesEditor, options: EnforceWithDocumentTitleHandlerOptions): void;
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "@ones-editor/columns-block",
2
+ "name": "@ones-editor/layout-block",
3
3
  "version": "1.0.0",
4
4
  "type": "module",
5
5
  "private": true,
@@ -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 declare class LayoutBlockCaptionInputHandler implements OnesEditorInputHandler, OnesEditorCustom {
3
+ private editor;
4
+ private skipForRootContainer;
5
+ constructor(editor: OnesEditor, skipForRootContainer?: boolean);
6
+ destroy(): void;
7
+ handleBeforePaste(editor: OnesEditor, event: ClipboardEvent | null, docs: OnesEditorDocs): Promise<boolean>;
8
+ }
@@ -0,0 +1,3 @@
1
+ import { BlockElement, ContainerElement, OnesEditor } from '../../../@ones-editor/core';
2
+ export declare function getChildContainers(editor: OnesEditor, 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 = "/column";
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,6 @@
1
+ import './locale';
2
+ import './layout-styles.scss';
3
+ import { LayoutKindBlock } from './types';
4
+ export declare const LayoutBlock: LayoutKindBlock;
5
+ export { isLayoutBlock } from './utils';
6
+ export * from './caption';
@@ -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 {};