@ones-editor/editor 1.1.6-beta.6 → 1.1.6-beta.7

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,3 +1,3 @@
1
1
  import { BlockElement, OnesEditor } from '../../../types';
2
2
  import EditorSimpleSelectionRange from '../../../selection/range/simple-range';
3
- export declare function getTextBlockRangeFromPoint(editor: OnesEditor, block: BlockElement, x: number, y: number): EditorSimpleSelectionRange | null;
3
+ export declare function getTextBlockRangeFromPoint(editor: OnesEditor, block: BlockElement, xOrign: number, yOrign: number): EditorSimpleSelectionRange | null;
@@ -109,6 +109,7 @@ export interface OnesEditorDocCallbacks {
109
109
  onCustomMessage?: (msg: unknown) => void;
110
110
  onStatusChanged?: (status: OnesEditorDocStatus) => void;
111
111
  onError?: (error: Error) => void;
112
+ onAuthRecover?: () => void;
112
113
  }
113
114
  export interface UploadResourceOptions {
114
115
  onProgress?: (progress: number) => void;
@@ -119,6 +120,7 @@ export interface UploadResourceResult {
119
120
  export interface BuildResourceUrlOptions {
120
121
  withToken?: boolean;
121
122
  downloadFileName?: string;
123
+ syncNewResources?: (newResourceId: string, resourceUrl: string) => void;
122
124
  }
123
125
  export type OnesEditorUserPermission = 'w' | 'r' | 'c';
124
126
  export interface OnesEditorUser {
@@ -221,6 +223,7 @@ export interface OnesEditorDoc extends OnesEditorDocServer {
221
223
  recognizeLink?: (link: string) => Promise<RecognizeLinkResult>;
222
224
  beginBatchUpdate: () => number;
223
225
  endBatchUpdate: () => number;
226
+ triggerReAuth?: () => void;
224
227
  }
225
228
  export interface OnesEditorDocHistoryData {
226
229
  user: {
@@ -41,6 +41,7 @@ export default class EditorDoc extends EventCallbacks<OnesEditorDocCallbacks> im
41
41
  broadcastMessage(data: unknown): void;
42
42
  getUser(): import("../doc").OnesEditorUser;
43
43
  getRemoteUsers(): import("../doc").OnesEditorRemoteUsers;
44
+ triggerReAuth(): void | undefined;
44
45
  destroy(): void;
45
46
  getServerMeta(): OnesEditorDocServerMeta;
46
47
  reset(doc: OnesEditorDoc): void;
@@ -11,7 +11,9 @@
11
11
  "license": "ISC",
12
12
  "devDependencies": {
13
13
  "@types/mime-db": "^1.43.1",
14
- "@types/pako": "^2.0.0"
14
+ "@types/pako": "^2.0.0",
15
+ "@types/lodash-es": "4.17.8",
16
+ "@types/lodash.clonedeep": "^4.5.0"
15
17
  },
16
18
  "types": "src/index.d.ts"
17
19
  }
@@ -7,7 +7,7 @@ export declare function getDrawioIframeUrl(editor: OnesEditor): string;
7
7
  export declare function resizeObserver(el: HTMLElement): {
8
8
  disconnect: () => void;
9
9
  };
10
- export declare function initializeDrawioIframe(editor: OnesEditor): Promise<{
10
+ export declare function initializeDrawioIframe(editor: OnesEditor, block: BlockElement): Promise<{
11
11
  drawioIframe: HTMLIFrameElement;
12
12
  exit: () => void;
13
13
  }>;
@@ -6,7 +6,9 @@
6
6
  "devDependencies": {
7
7
  "@types/lodash.camelcase": "^4.3.7",
8
8
  "@types/mermaid": "^9.1.0",
9
- "@types/plantuml-encoder": "^1.4.0"
9
+ "@types/plantuml-encoder": "^1.4.0",
10
+ "@types/lodash-es": "4.17.8",
11
+ "@types/lodash.clonedeep": "^4.5.0"
10
12
  },
11
13
  "types": "src/index.d.ts"
12
14
  }
@@ -5,7 +5,8 @@
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "devDependencies": {
8
- "@types/lodash.debounce": "^4.0.7"
8
+ "@types/lodash.debounce": "^4.0.7",
9
+ "@types/lodash.clonedeep": "^4.5.0"
9
10
  },
10
11
  "types": "src/index.d.ts"
11
12
  }
@@ -3,5 +3,9 @@
3
3
  "version": "1.0.0",
4
4
  "main": "src/index.ts",
5
5
  "type": "module",
6
+ "devDependencies": {
7
+ "@types/lodash-es": "4.17.8",
8
+ "@types/lodash.clonedeep": "^4.5.0"
9
+ },
6
10
  "types": "src/index.d.ts"
7
11
  }
@@ -20,7 +20,7 @@ export declare class Media extends TypedEmitter<MediaEvent> {
20
20
  private renderMediaElement;
21
21
  handleUploadFile: (file: File) => Promise<void>;
22
22
  renderEmpty(blockData: MediaBlockData): void;
23
- getResourceUrl(url: string): string;
23
+ getResourceUrl(blockData: MediaBlockData, content?: BlockContentElement): string;
24
24
  setFullScreen(): void;
25
25
  removeFullScreen(): void;
26
26
  updateBlockAlign(blockData: MediaBlockData, content: BlockContentElement): void;
@@ -1,3 +1,4 @@
1
1
  export * from './image';
2
2
  export * from './title';
3
3
  export * from './image-downloader';
4
+ export * from './re-auth';
@@ -0,0 +1,18 @@
1
+ import { TypedEmitter } from 'tiny-typed-emitter';
2
+ import type { OnesEditor, OnesEditorCustom, OnesEditorDocCallbacks } from '../../../../@ones-editor/core';
3
+ import ReAuthToolbar from './ui/toolbar';
4
+ import './locale';
5
+ type EventCallback = (() => void) | undefined;
6
+ declare const DOC_RE_AUTH_KEYS = "doc-re-auth-event";
7
+ declare class DocReAuthCallbacks extends TypedEmitter implements OnesEditorCustom, OnesEditorDocCallbacks {
8
+ private editor;
9
+ private authErrorCallback;
10
+ private authRecoverCallback;
11
+ constructor(editor: OnesEditor);
12
+ addAuthListen(event: 'authError' | 'authRecover', callback: EventCallback): void;
13
+ removeListeners(): void;
14
+ destroy: () => void;
15
+ onError: (error: Error) => void;
16
+ onAuthRecover: () => void;
17
+ }
18
+ export { ReAuthToolbar, DocReAuthCallbacks, DOC_RE_AUTH_KEYS, };
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ authError: {
3
+ tips: string;
4
+ };
5
+ };
6
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ authError: {
3
+ tips: string;
4
+ };
5
+ };
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ authError: {
3
+ tips: string;
4
+ };
5
+ };
6
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import type { BlockElement, OnesEditor } from '../../../../../@ones-editor/core';
2
+ import './toolbar.scss';
3
+ export default class ReAuthToolbar {
4
+ private editor;
5
+ private isShown;
6
+ private currentBlock;
7
+ constructor(editor: OnesEditor);
8
+ render(block: BlockElement, onExit?: () => void): void;
9
+ destroy(): void;
10
+ }
@@ -14,6 +14,10 @@ export declare class AuthConnection {
14
14
  events: EventEmitter;
15
15
  token: string | null;
16
16
  resourceToken: string | null;
17
+ pingOptions: {
18
+ interval: number;
19
+ timeout: number;
20
+ };
17
21
  constructor(url: string, reauthFunc?: ReauthFunc | undefined);
18
22
  getBaseURL(): string;
19
23
  getBase64BaseURL(): string;
@@ -24,6 +28,9 @@ export declare class AuthConnection {
24
28
  logout(): Promise<void>;
25
29
  init(auth: AuthMessage): Promise<void>;
26
30
  handleAuthError(): Promise<void>;
31
+ reAuth: () => Promise<void>;
32
+ private emitPermissionError;
33
+ private emitAuthRecover;
27
34
  private emitAuthError;
28
35
  private emitRequestReloadError;
29
36
  private emitWriteConflictError;
@@ -32,6 +39,7 @@ export declare class AuthConnection {
32
39
  get(collectionName: string, documentID: string): Doc;
33
40
  addEventListener(event: 'open' | 'close' | 'error', callback: (e: Event | Error) => void): void;
34
41
  onAuthError(callback: (error: Error) => void): void;
42
+ onAuthRecover(callback: () => void): void;
35
43
  onWriteConflictError(callback: (error: Error) => void): void;
36
44
  onMaxUsersError(callback: () => void): void;
37
45
  onRequestReloadError(callback: (error: Error) => void): void;
@@ -15,6 +15,7 @@ export default class ShareDBClient {
15
15
  close(logout: boolean): void;
16
16
  on(event: 'open' | 'close' | 'error', callback: (event: Event | Error) => void): void;
17
17
  onAuthError(callback: (error: Error) => void): void;
18
+ onAuthRecover(callback: () => void): void;
18
19
  onWriteConflictError(callback: (error: Error) => void): void;
19
20
  onMaxUsersError(callback: () => void): void;
20
21
  onRequestReloadError(callback: (error: Error) => void): void;
@@ -51,5 +52,7 @@ export default class ShareDBClient {
51
52
  revertVersion(ver: number): Promise<void>;
52
53
  createVersion(tag: string, publish: boolean): Promise<any>;
53
54
  recognizeLink(url: string): Promise<LinkDetails>;
55
+ private getResourceId;
54
56
  buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
57
+ reAuth(): void;
55
58
  }
@@ -75,6 +75,7 @@ export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> impl
75
75
  onCreateComment(commentId: string, local: boolean): void;
76
76
  onUpdateComment(commentId: string, local: boolean): void;
77
77
  onCustomMessage(msg: unknown): void;
78
+ onAuthRecover(): void;
78
79
  addResources(resourceIds: string[]): Promise<string[]>;
79
80
  uploadResource(file: File, options?: UploadResourceOptions): Promise<UploadResourceResult>;
80
81
  buildResourceUrl(resourceId: string, options?: BuildResourceUrlOptions): string;
@@ -106,4 +107,5 @@ export default class ShareDBDoc extends EventCallbacks<ShareDBDocCallbacks> impl
106
107
  recognizeLink(url: string): Promise<import("../types").LinkDetails>;
107
108
  parseHistoryData(historyData: OnesEditorDocHistoryData, handler: OnesEditorHistoryDataParseHandler): void;
108
109
  getServerMeta(): OnesEditorDocServerMeta;
110
+ triggerReAuth(): void;
109
111
  }
@@ -3,6 +3,7 @@ declare module 'sharedb/lib/client' {
3
3
  interface Connection {
4
4
  id: string | null;
5
5
  auth: object;
6
+ _ping: number;
6
7
  lastReceiveTime?: number;
7
8
  _initializeHandshake(): void;
8
9
  send(message: object): void;