@ones-editor/editor 0.0.3-beta.27 → 0.0.3-beta.29

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.
@@ -1,5 +1,5 @@
1
1
  import { OnesEditor } from '../../../../@ones-editor/core';
2
- import { OnesEditorCommentsProvider } from '../types';
2
+ import { CommentRoot, OnesEditorCommentsProvider } from '../types';
3
3
  export default class OnesEditorComments {
4
4
  private editor;
5
5
  private provider;
@@ -10,10 +10,10 @@ export default class OnesEditorComments {
10
10
  private get commentOptions();
11
11
  get commentProvider(): OnesEditorCommentsProvider;
12
12
  get isMobile(): boolean;
13
- private getCommentRoot;
14
13
  destroy(): void;
15
14
  private showComment;
16
15
  showCommentList: (groupId?: string) => void;
16
+ mount(containers: CommentRoot): void;
17
17
  private handleCommentListClose;
18
18
  private handleOnSelectComment;
19
19
  private handleMiniCommentItemClick;
@@ -8,10 +8,10 @@ interface CommentsListEvents {
8
8
  export default class CommentsList extends TypedEmitter<CommentsListEvents> implements OnesEditorCommentsEvents {
9
9
  private editor;
10
10
  private commentsProvider;
11
- private root;
11
+ root: HTMLElement;
12
12
  private groupsContainer;
13
13
  private list;
14
- constructor(editor: OnesEditor, commentsProvider: OnesEditorCommentsProvider, parent: HTMLElement);
14
+ constructor(editor: OnesEditor, commentsProvider: OnesEditorCommentsProvider);
15
15
  private get commentOptions();
16
16
  destroy(): void;
17
17
  onCreateComment(commentId: string, local: boolean): void;
@@ -11,7 +11,7 @@ export declare class MiniCommentsList extends TypedEmitter<MiniCommentsListEvent
11
11
  private commentsProvider;
12
12
  list: MiniGroupList;
13
13
  root: HTMLElement;
14
- constructor(editor: OnesEditor, commentsProvider: OnesEditorCommentsProvider, parent: HTMLElement);
14
+ constructor(editor: OnesEditor, commentsProvider: OnesEditorCommentsProvider);
15
15
  onCreateComment(commentId: string, local: boolean): void;
16
16
  onDeleteComment(commentId: string, local: boolean): void;
17
17
  onUpdateComment(commentId: string, local: boolean): void;
@@ -7,11 +7,11 @@ interface MobileCommentsListEvents {
7
7
  export declare class MobileCommentsList extends TypedEmitter<MobileCommentsListEvents> implements OnesEditorCommentsEvents {
8
8
  private editor;
9
9
  private commentsProvider;
10
- private root;
10
+ root: HTMLDivElement;
11
11
  private list;
12
12
  private mask;
13
13
  private pullInfoContainer;
14
- constructor(editor: OnesEditor, commentsProvider: OnesEditorCommentsProvider, parent: HTMLElement);
14
+ constructor(editor: OnesEditor, commentsProvider: OnesEditorCommentsProvider);
15
15
  onCreateComment(commentId: string, local: boolean): void;
16
16
  onDeleteComment(commentId: string, local: boolean): void;
17
17
  onUpdateComment(commentId: string, local: boolean): void;
@@ -6,12 +6,13 @@ export type CommentData = {
6
6
  export interface OnesEditorCommentController {
7
7
  showCommentList: () => void;
8
8
  }
9
- export type CommentRootType = keyof Pick<OnesEditorCommentOptions, 'container' | 'miniContainer' | 'mobileContainer'>;
10
- export interface OnesEditorCommentOptions {
11
- controller: OnesEditorCommentController;
9
+ export type CommentRoot = {
12
10
  container?: HTMLElement;
13
11
  miniContainer?: HTMLElement;
14
12
  mobileContainer?: HTMLElement;
13
+ };
14
+ export interface OnesEditorCommentOptions {
15
+ controller: OnesEditorCommentController;
15
16
  disableReply?: boolean;
16
17
  disableEdit?: boolean;
17
18
  pullThreshold?: number;
@@ -179,15 +179,19 @@ export interface RecognizeLinkResult {
179
179
  providerName?: string;
180
180
  url: string;
181
181
  }
182
+ export interface InsertBlockOptions {
183
+ noScroll?: boolean;
184
+ }
185
+ export type UpdateBlockOptions = InsertBlockOptions;
182
186
  export interface OnesEditorDoc {
183
187
  registerCallback: (callbacks: OnesEditorDocCallbacks) => void;
184
188
  unregisterCallback: (callbacks: OnesEditorDocCallbacks) => void;
185
189
  toJSON: () => DocObject;
186
190
  getContainerBlocks: (containerId: string) => DocBlock[];
187
191
  getBlockData: (containerId: string, blockIndex: number) => DocBlock;
188
- localUpdateBlockText: (containerId: string, blockIndex: number, actions: DocBlockTextActions) => DocBlockText;
192
+ localUpdateBlockText: (containerId: string, blockIndex: number, actions: DocBlockTextActions, options?: UpdateBlockOptions) => DocBlockText;
189
193
  localUpdateBlockData: (containerId: string, blockIndex: number, delta: DocBlockDelta, newRange: OnesEditorDocRange) => DocBlock;
190
- localInsertBlock: (containerId: string, blockIndex: number, data: DocBlock, newRange: OnesEditorDocRange) => DocBlock;
194
+ localInsertBlock: (containerId: string, blockIndex: number, data: DocBlock, newRange: OnesEditorDocRange, options?: InsertBlockOptions) => DocBlock;
191
195
  localDeleteBlock: (containerId: string, blockIndex: number, newRange: OnesEditorDocRange) => DocBlock;
192
196
  localInsertChildContainer: (containerId: string, blocks: DocBlock[]) => void;
193
197
  localDeleteChildContainers: (containerIds: string[]) => void;
@@ -1,3 +1,3 @@
1
- import { DocBlock, OnesEditorDocRange } from '../../doc';
1
+ import { InsertBlockOptions, DocBlock, OnesEditorDocRange } from '../../doc';
2
2
  import { OnesEditor } from '../../types';
3
- export declare function editorAutoInsertBlock(editor: OnesEditor, blockData: DocBlock, containerId?: string, blockIndex?: number, newRange?: OnesEditorDocRange): import("../../types").BlockElement;
3
+ export declare function editorAutoInsertBlock(editor: OnesEditor, blockData: DocBlock, containerId?: string, blockIndex?: number, newRange?: OnesEditorDocRange, insertBlockOptions?: InsertBlockOptions): import("../../types").BlockElement;
@@ -1,2 +1,2 @@
1
- import { OnesEditor, BlockElement } from '../../types';
2
- export declare function editorDeleteBlockText(editor: OnesEditor, block: BlockElement, offset: number, count: number): number;
1
+ import { OnesEditor, BlockElement, InsertTextOptions } from '../../types';
2
+ export declare function editorDeleteBlockText(editor: OnesEditor, block: BlockElement, offset: number, count: number, options?: InsertTextOptions): number;
@@ -1,3 +1,3 @@
1
- import { DocBlock, OnesEditorDocRange } from '../../doc';
1
+ import { DocBlock, InsertBlockOptions, OnesEditorDocRange } from '../../doc';
2
2
  import { OnesEditor, BlockElement } from '../../types';
3
- export declare function editorInsertBlock(editor: OnesEditor, containerId: string, blockIndex: number, blockData: DocBlock, newRange: OnesEditorDocRange): BlockElement;
3
+ export declare function editorInsertBlock(editor: OnesEditor, containerId: string, blockIndex: number, blockData: DocBlock, newRange: OnesEditorDocRange, options?: InsertBlockOptions): BlockElement;
@@ -1,6 +1,6 @@
1
- import { OnesEditor, BlockElement } from '../../types';
1
+ import { OnesEditor, BlockElement, InsertTextOptions } from '../../types';
2
2
  import { DocBlockText, DocBox } from '../../doc';
3
- export declare function editorInsertTextToBlock(editor: OnesEditor, block: BlockElement, offset: number, text: string | DocBlockText): DocBlockText;
3
+ export declare function editorInsertTextToBlock(editor: OnesEditor, block: BlockElement, offset: number, text: string | DocBlockText, options?: InsertTextOptions): DocBlockText;
4
4
  export declare function editorInsertBoxToBlock(editor: OnesEditor, block: BlockElement, offset: number, boxData: DocBox): DocBlockText;
5
5
  export declare function editorInsertTextToBlockEx(editor: OnesEditor, text: string | DocBlockText, containerId: string, blockIndex: number, offset: number): DocBlockText;
6
6
  export declare function editorInsertText(editor: OnesEditor, text: string | DocBlockText): void;
@@ -12,7 +12,7 @@ declare class DomEventHandler {
12
12
  }
13
13
  export declare class EditorDomEvents {
14
14
  private editor;
15
- handlers: Map<Document | Element | Window, DomEventHandler[]>;
15
+ handlers: Map<Element | Document | Window, DomEventHandler[]>;
16
16
  constructor(editor: OnesEditor);
17
17
  destroy(): void;
18
18
  addEventListener<T = Event>(element: Element | Document | Window, eventName: string, eventHandler: DomEventCallback<T>, data?: unknown): void;
@@ -1,5 +1,5 @@
1
1
  import { EditorDocLocalActionCallbacks, OnesEditor } from '../types';
2
- import { BuildResourceUrlOptions, DocBlock, DocBlockDelta, DocBlockText, DocBlockTextActions, DocObject, OnesEditorDoc, OnesEditorDocCallbacks, OnesEditorDocRange, OnesEditorDocServerMeta, OnesEditorDocStatus, UploadResourceOptions, UploadResourceResult } from '../doc';
2
+ import { BuildResourceUrlOptions, InsertBlockOptions, DocBlock, DocBlockDelta, DocBlockText, DocBlockTextActions, DocObject, OnesEditorDoc, OnesEditorDocCallbacks, OnesEditorDocRange, OnesEditorDocServerMeta, OnesEditorDocStatus, UploadResourceOptions, UploadResourceResult, UpdateBlockOptions } from '../doc';
3
3
  import { EventCallbacks } from '../../utils';
4
4
  export default class EditorDoc extends EventCallbacks<OnesEditorDocCallbacks> implements OnesEditorDoc, OnesEditorDocCallbacks {
5
5
  private editor;
@@ -13,9 +13,9 @@ export default class EditorDoc extends EventCallbacks<OnesEditorDocCallbacks> im
13
13
  getVersionHelper(): import("../doc").OnesEditorDocVersionHelper | undefined;
14
14
  getContainerBlocks(containerId: string): DocBlock[];
15
15
  getBlockData(containerId: string, blockIndex: number): DocBlock;
16
- localUpdateBlockText(containerId: string, blockIndex: number, actions: DocBlockTextActions): DocBlockText;
16
+ localUpdateBlockText(containerId: string, blockIndex: number, actions: DocBlockTextActions, options?: UpdateBlockOptions): DocBlockText;
17
17
  localUpdateBlockData(containerId: string, blockIndex: number, delta: DocBlockDelta, newRange: OnesEditorDocRange): DocBlock;
18
- localInsertBlock(containerId: string, blockIndex: number, data: DocBlock, newRange: OnesEditorDocRange): DocBlock;
18
+ localInsertBlock(containerId: string, blockIndex: number, data: DocBlock, newRange: OnesEditorDocRange, options?: InsertBlockOptions): DocBlock;
19
19
  localDeleteBlock(containerId: string, blockIndex: number, newRange: OnesEditorDocRange): DocBlock;
20
20
  localDeleteChildContainers(containerIds: string[]): void;
21
21
  localInsertChildContainer(containerId: string, blocks: DocBlock[]): void;
@@ -38,4 +38,5 @@ export default class EditorDoc extends EventCallbacks<OnesEditorDocCallbacks> im
38
38
  getRemoteUsers(): import("../doc").OnesEditorRemoteUsers;
39
39
  destroy(): void;
40
40
  getServerMeta(): OnesEditorDocServerMeta;
41
+ reset(doc: OnesEditorDoc): void;
41
42
  }
@@ -1,5 +1,5 @@
1
1
  import { EditorCaret } from '../blocks/text-blocks/caret/editor-caret';
2
- import { OnesEditorSelection, BlockElement, BlockPosition, SelectionRange, OnesEditor, ChangeSelectionOptions, DeleteBlockEventOptions } from '../types';
2
+ import { OnesEditorSelection, BlockElement, BlockPosition, SelectionRange, OnesEditor, DeleteBlockEventOptions, ChangeSelectionOptions } from '../types';
3
3
  export declare class EditorSelection implements OnesEditorSelection {
4
4
  readonly editor: OnesEditor;
5
5
  readonly caret: EditorCaret;
@@ -16,7 +16,7 @@ export declare class EditorSelection implements OnesEditorSelection {
16
16
  getEndBlock(): BlockElement;
17
17
  selectBlock(block: BlockElement, start: number, end?: number): void;
18
18
  setSelection(anchor: BlockPosition, focus?: BlockPosition, options?: ChangeSelectionOptions): SelectionRange;
19
- setRange(range: SelectionRange): SelectionRange;
19
+ setRange(range: SelectionRange, options?: ChangeSelectionOptions): SelectionRange;
20
20
  updateSelection(): void;
21
21
  getFocusedPos(): BlockPosition;
22
22
  getAnchorPos(): BlockPosition;
@@ -1,5 +1,5 @@
1
1
  import { TypedEmitter } from 'tiny-typed-emitter';
2
- import { DocBlock, DocBlockAttributes, DocBlocks, DocBlockText, DocBlockTextAttributes, DocBox, DocEmbedBlock, DocEmbedData, DocInsertion, DocObject, OnesEditorDoc, OnesEditorDocRange } from './doc';
2
+ import { DocBlock, DocBlockAttributes, 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
  };
@@ -427,6 +427,7 @@ export interface OnesEditorDomEvents extends OnesEditorCustom {
427
427
  removeEventListener: (element: Element | Document | Window | null, eventName: string | null, eventHandler: (editor: OnesEditor, event: Event) => void) => void;
428
428
  removeAllListeners: (element: Element | Document | Window, eventName?: string) => void;
429
429
  }
430
+ export type InsertTextOptions = InsertBlockOptions;
430
431
  export interface OnesEditor extends TypedEmitter<OnesEditorEvents> {
431
432
  readonly parent: HTMLElement;
432
433
  readonly rootElement: HTMLDivElement;
@@ -491,7 +492,7 @@ export interface OnesEditor extends TypedEmitter<OnesEditorEvents> {
491
492
  contains: (node: Node) => boolean;
492
493
  getSelectedText: () => string;
493
494
  clearSelectedContents: () => void;
494
- insertBlock: (containerId: string, blockIndex: number, blockData: DocBlock, newRange?: OnesEditorDocRange) => BlockElement;
495
+ insertBlock: (containerId: string, blockIndex: number, blockData: DocBlock, newRange?: OnesEditorDocRange, options?: InsertBlockOptions) => BlockElement;
495
496
  insertEmbed: (containerId: string, blockIndex: number, embedType: string, embedData: DocEmbedData, newRange?: OnesEditorDocRange) => BlockElement;
496
497
  deleteBlock: (block: BlockElement, newRange?: OnesEditorDocRange) => void;
497
498
  getTextPosition: () => BlockTextPosition;
@@ -502,8 +503,8 @@ export interface OnesEditor extends TypedEmitter<OnesEditorEvents> {
502
503
  getBlockText: (block: BlockElement) => DocBlockText;
503
504
  setBlockText: (block: BlockElement, text: DocBlockText) => void;
504
505
  getBoxData: (box: BoxElement) => DocBox;
505
- deleteTextFromBlock: (block: BlockElement, offset: number, count: number) => number;
506
- insertTextToBlock: (block: BlockElement, offset: number, text: string | DocBlockText) => DocBlockText;
506
+ deleteTextFromBlock: (block: BlockElement, offset: number, count: number, options?: InsertTextOptions) => number;
507
+ insertTextToBlock: (block: BlockElement, offset: number, text: string | DocBlockText, options?: InsertTextOptions) => DocBlockText;
507
508
  insertBoxToBlock: (block: BlockElement, offset: number, boxData: DocBox) => DocBlockText;
508
509
  mergeTextBlock: (block1: BlockElement, block2: BlockElement, options?: {
509
510
  focus?: boolean;
@@ -511,6 +512,7 @@ export interface OnesEditor extends TypedEmitter<OnesEditorEvents> {
511
512
  breakTextBlock: (block: BlockElement, offset: number, options?: BreakTextOptions) => BlockElement;
512
513
  insertTextBlock: (text?: string | DocBlockText, containerId?: string, blockIndex?: number, options?: {
513
514
  newRange?: OnesEditorDocRange;
515
+ insertBlockOptions?: InsertBlockOptions;
514
516
  }) => BlockElement;
515
517
  insertDoc: (block: BlockElement, offset: number, doc: DocObject, cloneDocResult?: CloneBlockResultInfo) => void;
516
518
  insertDocAt: (container: ContainerElement, blockIndex: number, doc: DocObject, cloneDocResult?: CloneBlockResultInfo) => BlockElement[];
@@ -532,7 +534,7 @@ export interface OnesEditorSelection {
532
534
  readonly startBlock: BlockElement;
533
535
  readonly endBlock: BlockElement;
534
536
  setSelection: (anchor: BlockPosition, focus?: BlockPosition, options?: ChangeSelectionOptions) => SelectionRange;
535
- setRange: (range: SelectionRange) => SelectionRange;
537
+ setRange: (range: SelectionRange, options?: ChangeSelectionOptions) => SelectionRange;
536
538
  selectBlock: (block: BlockElement, start: number, end?: number) => void;
537
539
  updateSelection: (old: SelectionRange | null) => void;
538
540
  updateLastCaretRect: () => void;
@@ -1,6 +1,7 @@
1
1
  export declare class Logger {
2
2
  private category;
3
3
  private times;
4
+ static debugMode: boolean;
4
5
  constructor(category: string);
5
6
  private _log;
6
7
  log(msg: string | object, context?: string): void;
@@ -12,6 +12,7 @@ export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> impl
12
12
  batching: number;
13
13
  status: OnesEditorDocStatus;
14
14
  disableLogout: boolean;
15
+ destroyed: boolean;
15
16
  constructor(client: ShareDBClient, doc: Doc, disableLogout?: boolean);
16
17
  beginBatchUpdate(): number;
17
18
  endBatchUpdate(): number;
@@ -19,6 +20,9 @@ export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> impl
19
20
  private handleNothingPending;
20
21
  private handleCreate;
21
22
  private handleDel;
23
+ private handleReload;
24
+ private handleReset;
25
+ private handleWriteConflictError;
22
26
  private setStatus;
23
27
  initEvents(): void;
24
28
  clearEvents(): void;