@ones-editor/editor 2.1.7 → 2.1.8

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.
@@ -0,0 +1,16 @@
1
+ import { DocObject, OnesEditor, OnesEditorComment, OnesEditorDocRange, SelectionRange } from '../../../../@ones-editor/core';
2
+ export interface AddCommentToOldVersionBody {
3
+ avatarUrl: string;
4
+ containerId: string;
5
+ rangeType: 'simple' | 'complex';
6
+ range: OnesEditorDocRange;
7
+ selectedContainers: string[];
8
+ commentId?: string;
9
+ commentGroupId?: string;
10
+ comment: DocObject;
11
+ abstract?: string;
12
+ }
13
+ export declare function addCommentToOldVersion(editor: OnesEditor, version: number, range: SelectionRange, comment: OnesEditorComment, commentDoc: DocObject): Promise<void>;
14
+ export declare function replyCommentToOldVersion(editor: OnesEditor, version: number, comment: OnesEditorComment, commentDoc: DocObject): Promise<unknown>;
15
+ export declare function updateCommentToOldDoc(editor: OnesEditor, version: number, commentId: string, commentDoc: DocObject): Promise<unknown>;
16
+ export declare function deleteCommentFromOldDoc(editor: OnesEditor, version: number, commentId: string): Promise<unknown>;
@@ -8,4 +8,7 @@ export { OnesEditorComments };
8
8
  export type { CommentItem } from './comment-item';
9
9
  export type { CommentGroupItem } from './comments-list/group-item';
10
10
  export { removeCommentFromBlock } from './actions/remove-comment-from-block';
11
+ export { addCommentToTextBlocks } from './actions/add-comment-to-text-block';
12
+ export { addCommentToBlock } from './actions/add-comment-to-block';
11
13
  export { editorAddComment } from './actions/editor-add-comment';
14
+ export * from './comments-helper/old-version-comment';
@@ -1,10 +1,10 @@
1
- import { BlockCommands, BlockElement, OnesEditor } from '../../types';
1
+ import { BlockCommands, BlockElement, BoxCommands, OnesEditor, TextBlockContentChild } from '../../types';
2
2
  export declare function getBlockProperties(editor: OnesEditor, block: BlockElement): import("../../types").BlockProperties | undefined;
3
- export declare function getBlockCommandsWithHook(editor: OnesEditor, block: BlockElement): Record<string, BlockCommands>;
4
- export declare function getSpecialBlockCommands(editor: OnesEditor, blockElement: BlockElement, group: string): {
5
- element: import("../../types").BlockContentElement;
6
- commands: import("../../types").CommandItem[];
7
- } | {
8
- element: null;
9
- commands: never[];
10
- };
3
+ export declare function getBlockCommandsWithHook(editor: OnesEditor, block: BlockElement, child: TextBlockContentChild | null): Record<string, BlockCommands>;
4
+ interface SpecialBlockCommands {
5
+ element: HTMLElement | null;
6
+ blockCommands: BlockCommands[];
7
+ boxCommands: BoxCommands[];
8
+ }
9
+ export declare function getSpecialBlockCommands(editor: OnesEditor, blockElement: BlockElement, child: TextBlockContentChild | null, group: string): SpecialBlockCommands;
10
+ export {};
@@ -1,7 +1,8 @@
1
- import { BlockElement, OnesEditor, SelectedBlock } from '../../types';
1
+ import { BlockElement, OnesEditor, SelectedBlock, SelectionRange } from '../../types';
2
2
  export type GetAllChildBlocksOptions = {
3
3
  simpleBlockOnly?: boolean;
4
4
  visibleOnly?: boolean;
5
+ range?: SelectionRange;
5
6
  };
6
7
  export declare function getAllChildBlocks(editor: OnesEditor, options?: GetAllChildBlocksOptions): BlockElement[];
7
8
  export declare function getAllSelectedBlocks(editor: OnesEditor, options?: GetAllChildBlocksOptions): SelectedBlock[];
@@ -1,4 +1,4 @@
1
- import { OnesEditor, BlockElement, BlockPosition, ContainerElement, ComplexBlockPosition, GetChildContainerOptions } from '../../types';
1
+ import { OnesEditor, BlockElement, BlockPosition, ContainerElement, ComplexBlockPosition, GetChildContainerOptions, ComplexSelectionRange } from '../../types';
2
2
  export declare function complexBlockGetAllChildContainers(editor: OnesEditor, block: BlockElement, options?: GetChildContainerOptions): ContainerElement[];
3
3
  export declare function complexBlockGetSelectedContainers(editor: OnesEditor, block: BlockElement, start: BlockPosition, end: BlockPosition): ContainerElement[];
4
4
  export declare function isFirstChildBlockInComplexBlock(editor: OnesEditor, childBlock: BlockElement): boolean;
@@ -13,3 +13,4 @@ export declare function complexBlockAdjustSelectionPos(editor: OnesEditor, compl
13
13
  anchor: ComplexBlockPosition;
14
14
  focus: ComplexBlockPosition;
15
15
  };
16
+ export declare function isFullSelectedOneComplexBlock(editor: OnesEditor, complexRange?: ComplexSelectionRange): boolean;
@@ -1,10 +1,5 @@
1
- import { BlockElement, BoxElement, InsertionElement } from '../../../types';
2
- export type TextBlockContentTextChild = HTMLSpanElement & {
3
- __neverUse: 'TextBlockContentTextChild';
4
- };
5
- export type TextBlockContentInsertionChild = InsertionElement;
6
- export type TextBlockContentBoxChild = BoxElement;
7
- export type TextBlockContentChild = TextBlockContentTextChild | TextBlockContentBoxChild | TextBlockContentInsertionChild;
1
+ import { BlockElement, TextBlockContentTextChild, TextBlockContentBoxChild, TextBlockContentInsertionChild, TextBlockContentChild } from '../../../types';
2
+ export type { TextBlockContentTextChild, TextBlockContentBoxChild, TextBlockContentInsertionChild, TextBlockContentChild };
8
3
  export type TextBlockContentChildren = TextBlockContentChild[];
9
4
  export type TextBlockContentChildType = 'text' | 'box' | 'insertion';
10
5
  export declare function isTextBlockContentChild(elem: Element): boolean;
@@ -110,10 +110,12 @@ export interface OnesEditorDocComplexBlockPos {
110
110
  }
111
111
  export type OnesEditorDocBlockPos = OnesEditorDocSimpleBlockPos | OnesEditorDocComplexBlockPos;
112
112
  export interface OnesEditorDocSimpleRange {
113
+ reverse?: boolean;
113
114
  anchor: OnesEditorDocSimpleBlockPos;
114
115
  focus: OnesEditorDocSimpleBlockPos;
115
116
  }
116
117
  export interface OnesEditorDocComplexRange {
118
+ reverse?: boolean;
117
119
  anchor: OnesEditorDocComplexBlockPos;
118
120
  focus: OnesEditorDocComplexBlockPos;
119
121
  }
@@ -202,6 +204,7 @@ export interface OnesEditorDocServerMeta {
202
204
  serverId?: string;
203
205
  docId?: string;
204
206
  appId?: string;
207
+ apiServer?: string;
205
208
  }
206
209
  export interface RecognizeLinkResult {
207
210
  type?: 'iframe' | 'video' | 'audio' | 'image';
@@ -1,5 +1,11 @@
1
1
  import { TypedEmitter } from 'tiny-typed-emitter';
2
2
  import { DocBlock, DocBlockAttributes, DocBlockDelta, DocBlocks, DocBlockText, DocBlockTextAttributes, DocBox, DocEmbedBlock, DocEmbedData, DocInsertion, DocObject, InsertBlockOptions, OnesEditorDoc, OnesEditorDocRange, UpdateBlockOptions } from './doc';
3
+ export type TextBlockContentTextChild = HTMLSpanElement & {
4
+ __neverUse: 'TextBlockContentTextChild';
5
+ };
6
+ export type TextBlockContentInsertionChild = InsertionElement;
7
+ export type TextBlockContentBoxChild = BoxElement;
8
+ export type TextBlockContentChild = TextBlockContentTextChild | TextBlockContentBoxChild | TextBlockContentInsertionChild;
3
9
  export type ContainerElement = HTMLDivElement & {
4
10
  __neverUse: 'ContainerElement';
5
11
  };
@@ -52,6 +58,7 @@ export type BlockPosition = SimpleBlockPosition | ComplexBlockPosition;
52
58
  export interface BoxCommands {
53
59
  group: string;
54
60
  commands: CommandItem[];
61
+ startGroup?: boolean;
55
62
  executeCommand: (editor: OnesEditor, block: BlockElement, box: BoxElement, item: CommandItem) => unknown;
56
63
  }
57
64
  export interface BoxProperties {
@@ -174,9 +181,11 @@ export type BlockPathComponent = {
174
181
  };
175
182
  export type BlockPath = BlockPathComponent[];
176
183
  export interface BlockCommands {
184
+ element?: HTMLElement;
177
185
  group: string;
178
186
  commands: CommandItem[];
179
- executeCommand: (editor: OnesEditor, block: BlockElement, item: CommandItem) => unknown;
187
+ startGroup?: boolean;
188
+ executeCommand: (editor: OnesEditor, block: BlockElement, item: CommandItem, child: TextBlockContentChild | null) => unknown;
180
189
  }
181
190
  export interface BlockProperties {
182
191
  blockCommands?: Record<string, BlockCommands>;
@@ -753,5 +762,5 @@ export interface OnesEditorBlockHook {
753
762
  create?: (editor: OnesEditor, path: BlockPath, container: ContainerElement, blockElement: BlockElement, blockData: DocBlock) => void;
754
763
  update?: (editor: OnesEditor, path: BlockPath, container: ContainerElement, blockElement: BlockElement, blockData: DocBlock) => void;
755
764
  writable?: (editor: OnesEditor, blockElement: BlockElement | BlockElement[]) => boolean | undefined;
756
- commands?: (editor: OnesEditor, blockElement: BlockElement) => BlockCommands;
765
+ commands?: (editor: OnesEditor, blockElement: BlockElement, child: TextBlockContentChild | null) => BlockCommands | undefined;
757
766
  }
@@ -0,0 +1,24 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { BuildResourceUrlOptions } from '../../../../@ones-editor/core';
3
+ import { OnProgress } from '../types';
4
+ export default abstract class ShareDBClientBase {
5
+ abstract apiServer(): string;
6
+ abstract request<T = unknown>(url: string, opt?: any): Promise<AxiosResponse<any, T>>;
7
+ abstract token(): string;
8
+ abstract resourceToken(): string;
9
+ abstract docId(): string;
10
+ getFileUrlByHash(uploadFileUrl: string, hash: string, name: string, size: number, headers: {
11
+ [index: string]: string;
12
+ }): Promise<any>;
13
+ getFileUrlsByHashes(resourceHashes: string[]): Promise<any[]>;
14
+ uploadFile(url: string, file: File, headers: {
15
+ [index: string]: string;
16
+ }, onProgress: OnProgress, options?: {
17
+ thumbnail?: boolean;
18
+ }): Promise<string>;
19
+ uploadResource(file: File, onProgress?: OnProgress, options?: {
20
+ thumbnail?: boolean;
21
+ }): Promise<string>;
22
+ getResourceId(url: string): string;
23
+ buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
24
+ }
@@ -11,6 +11,9 @@ export default class ShareDBClient {
11
11
  private reauthFunc?;
12
12
  clientId: string;
13
13
  constructor(auth: AuthMessage, serverUrl: string, reauthFunc?: ReauthFunc);
14
+ token(): string;
15
+ resourceToken(): string;
16
+ docId(): string;
14
17
  editorServer(): string;
15
18
  close(logout: boolean): void;
16
19
  on(event: 'open' | 'close' | 'error', callback: (event: Event | Error) => void): void;
@@ -52,7 +55,7 @@ export default class ShareDBClient {
52
55
  revertVersion(ver: number): Promise<void>;
53
56
  createVersion(tag: string, publish: boolean): Promise<any>;
54
57
  recognizeLink(url: string): Promise<LinkDetails>;
55
- private getResourceId;
58
+ getResourceId(url: string): string;
56
59
  buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
57
60
  reAuth(auto?: boolean): void;
58
61
  }
@@ -0,0 +1,17 @@
1
+ import { DocObject, LocalDoc, OnesEditorUser, UploadResourceOptions, UploadResourceResult } from '../../../../@ones-editor/core';
2
+ export interface ShareDBLocalDocOptions {
3
+ serverUrl: string;
4
+ token: string;
5
+ resourceToken?: string;
6
+ user: OnesEditorUser;
7
+ docId: string;
8
+ }
9
+ export default class ShareDBLocalDoc extends LocalDoc {
10
+ private _options;
11
+ private _client;
12
+ constructor(docObject: DocObject, _options: ShareDBLocalDocOptions);
13
+ buildResourceUrl(src: string): string;
14
+ getUser(): OnesEditorUser;
15
+ request<T>(url: string, opt?: any): Promise<T>;
16
+ uploadResource(file: File, options?: UploadResourceOptions | undefined): Promise<UploadResourceResult>;
17
+ }
@@ -1,6 +1,13 @@
1
+ import axios from 'axios';
1
2
  import ShareDBDoc from './doc/sharedb-doc';
2
3
  import { RemoteCarets, RemoteCaretsDecorator } from './remote-carets';
3
- export { ShareDBDoc, RemoteCarets, RemoteCaretsDecorator };
4
+ import ShareDBClientBase from './doc/sharedb-client-base';
5
+ import ShareDBLocalDoc from './doc/sharedb-local-doc';
6
+ import type { ShareDBLocalDocOptions } from './doc/sharedb-local-doc';
7
+ export { ShareDBDoc, RemoteCarets, RemoteCaretsDecorator, ShareDBClientBase, ShareDBLocalDoc };
8
+ export type { ShareDBLocalDocOptions };
4
9
  export * from './doc/comments';
5
10
  export * from './types';
6
11
  export * from './versions';
12
+ export * from './utils/converter';
13
+ export { axios };