@ones-editor/editor 2.1.5 → 2.1.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.
@@ -40,6 +40,6 @@ export default class AutoSuggestMenu {
40
40
  handleClick: import("lodash").DebouncedFuncLeading<(menu: AbstractCommandBar, item: CommandItem) => void>;
41
41
  handleShow: (menu: AbstractCommandBar) => void;
42
42
  handleClose: () => void;
43
- handleKeydown: (event: KeyboardEvent) => void;
43
+ handleKeydown: (event: KeyboardEvent) => boolean;
44
44
  protected highlightText(search: string, items?: CommandItem[]): void;
45
45
  }
@@ -21,7 +21,7 @@ export default abstract class CommandBar extends TypedEmitter<CommandBarEvents>
21
21
  abstract readonly isVisible: boolean;
22
22
  get isSubCommandBar(): boolean;
23
23
  updateItems(items: CommandItem[]): void;
24
- handleDocumentKeydown: (event: KeyboardEvent) => void;
24
+ handleDocumentKeydown: (event: KeyboardEvent) => boolean;
25
25
  protected handleDocumentMouseDown: (event: MouseEvent) => void;
26
26
  protected handleHidden: () => void;
27
27
  protected handleShow: () => void;
@@ -26,7 +26,7 @@ export interface AbstractCommandBar extends TypedEmitter<CommandBarEvents> {
26
26
  close: (reason: CloseReason) => void;
27
27
  destroy: () => void;
28
28
  isInCommandBar: (target: EventTarget | null) => boolean;
29
- handleDocumentKeydown: (event: KeyboardEvent) => void;
29
+ handleDocumentKeydown: (event: KeyboardEvent) => boolean;
30
30
  getSubBarOptions: (item: CommandItem) => ManualShowCommandBarOptions;
31
31
  }
32
32
  export interface ShowCommandBarOptions {
package/dist/index.js CHANGED
@@ -36726,6 +36726,7 @@ ${codeText}
36726
36726
  __publicField(this, "status", "clean");
36727
36727
  __publicField(this, "disableLogout");
36728
36728
  __publicField(this, "destroyed", false);
36729
+ __publicField(this, "options", null);
36729
36730
  __publicField(this, "handleNothingPending", () => {
36730
36731
  this.setStatus("clean");
36731
36732
  });
@@ -36936,6 +36937,7 @@ ${codeText}
36936
36937
  });
36937
36938
  const doc2 = await client.getDoc();
36938
36939
  const shareDBDoc = new ShareDBDoc(client, doc2, options.disableLogout);
36940
+ shareDBDoc.options = options;
36939
36941
  if (doc2.type === null) {
36940
36942
  if (options.autoCreateDoc === false) {
36941
36943
  const error2 = new Error("doc not exists");
@@ -37215,14 +37217,28 @@ ${codeText}
37215
37217
  return ret;
37216
37218
  }
37217
37219
  async uploadResource(file2, options) {
37218
- var _a;
37219
- const ret = await this.client.uploadResource(file2, (_a = options == null ? void 0 : options.onProgress) != null ? _a : () => {
37220
+ var _a, _b;
37221
+ if ((_a = this.options) == null ? void 0 : _a.uploadResource) {
37222
+ try {
37223
+ const ret2 = await this.options.uploadResource(file2, options);
37224
+ return ret2;
37225
+ } catch (err) {
37226
+ }
37227
+ }
37228
+ const ret = await this.client.uploadResource(file2, (_b = options == null ? void 0 : options.onProgress) != null ? _b : () => {
37220
37229
  });
37221
37230
  return {
37222
37231
  resourceId: ret
37223
37232
  };
37224
37233
  }
37225
37234
  buildResourceUrl(resourceId, options) {
37235
+ var _a;
37236
+ if ((_a = this.options) == null ? void 0 : _a.buildResourceUrl) {
37237
+ const ret = this.options.buildResourceUrl(resourceId, options);
37238
+ if (ret) {
37239
+ return ret;
37240
+ }
37241
+ }
37226
37242
  return this.client.buildResourceUrl(resourceId, options);
37227
37243
  }
37228
37244
  request(url, options) {
@@ -38120,27 +38136,26 @@ ${codeText}
38120
38136
  __publicField(this, "handleDocumentKeydown", (event) => {
38121
38137
  var _a, _b;
38122
38138
  if (!this.isVisible) {
38123
- return;
38139
+ return true;
38124
38140
  }
38125
38141
  if (event.isComposing) {
38126
- return;
38142
+ return true;
38127
38143
  }
38128
38144
  if (isInBlockTools(event.target)) {
38129
- return;
38145
+ return true;
38130
38146
  }
38131
38147
  if (this.subBar) {
38132
- this.subBar.handleDocumentKeydown(event);
38133
- return;
38148
+ return this.subBar.handleDocumentKeydown(event);
38134
38149
  }
38135
38150
  if (this.items.length === 0) {
38136
- return;
38151
+ return true;
38137
38152
  }
38138
38153
  if (event.key === "Escape") {
38139
38154
  if ((_b = (_a = this.options).beforeClose) == null ? void 0 : _b.call(_a)) {
38140
- return;
38155
+ return true;
38141
38156
  }
38142
38157
  this.close("cancelBar");
38143
- return;
38158
+ return true;
38144
38159
  }
38145
38160
  if (event.key === "ArrowUp") {
38146
38161
  const prev = this.getPrevItemIndex(this.getSelectedItemIndex());
@@ -38166,7 +38181,7 @@ ${codeText}
38166
38181
  } else if (event.key === "Enter") {
38167
38182
  const index2 = this.getSelectedItemIndex();
38168
38183
  if (index2 === -1) {
38169
- return;
38184
+ return false;
38170
38185
  }
38171
38186
  const item = this.items[index2];
38172
38187
  const elem = this.getItemElementById(item.id);
@@ -38174,6 +38189,7 @@ ${codeText}
38174
38189
  this.emit("click", this, item, elem);
38175
38190
  }
38176
38191
  }
38192
+ return true;
38177
38193
  });
38178
38194
  __publicField(this, "handleDocumentMouseDown", (event) => {
38179
38195
  var _a, _b;
@@ -38229,6 +38245,9 @@ ${codeText}
38229
38245
  }
38230
38246
  const itemId = this.getItemElementId(elem);
38231
38247
  const item = this.getItemById(itemId);
38248
+ if (item.states && item.states.indexOf("disabled") !== -1) {
38249
+ return;
38250
+ }
38232
38251
  this.selectItem(itemId);
38233
38252
  if (item.manualShowChildren) {
38234
38253
  return;
@@ -39317,9 +39336,7 @@ ${codeText}
39317
39336
  var _a, _b;
39318
39337
  (_b = (_a = this.options).onClose) == null ? void 0 : _b.call(_a);
39319
39338
  });
39320
- __publicField(this, "handleKeydown", (event) => {
39321
- this.menu.handleDocumentKeydown(event);
39322
- });
39339
+ __publicField(this, "handleKeydown", (event) => this.menu.handleDocumentKeydown(event));
39323
39340
  this.options = options;
39324
39341
  this.menu = new ManualMenu([], void 0, {
39325
39342
  id: options.id,
@@ -39341,7 +39358,13 @@ ${codeText}
39341
39358
  setItems(items) {
39342
39359
  this.menu.updateItems(items);
39343
39360
  if (items.length > 0) {
39344
- const firstItem = items.find((item) => item.type !== "section" && item.type !== "separator");
39361
+ const selectable = (item) => {
39362
+ if (item.states && item.states.indexOf("disabled") !== -1) {
39363
+ return false;
39364
+ }
39365
+ return item.type !== "section" && item.type !== "separator";
39366
+ };
39367
+ const firstItem = items.find(selectable);
39345
39368
  if (firstItem) {
39346
39369
  this.menu.selectItem(firstItem.id, "manual");
39347
39370
  }
@@ -40109,8 +40132,7 @@ ${codeText}
40109
40132
  this.menu.close();
40110
40133
  return true;
40111
40134
  }
40112
- this.menu.handleKeydown(event);
40113
- return true;
40135
+ return this.menu.handleKeydown(event);
40114
40136
  }
40115
40137
  popup(block, offset, leftText, trigger) {
40116
40138
  this.anchor = {
@@ -82932,7 +82954,9 @@ ${data2.flowchartText}
82932
82954
  serverUrl: options.serverUrl,
82933
82955
  reauthFunc,
82934
82956
  disableLogout: options.disableLogout,
82935
- onMaxUsersError: options.onMaxUsersError
82957
+ onMaxUsersError: options.onMaxUsersError,
82958
+ uploadResource: options.uploadResource,
82959
+ buildResourceUrl: options.buildResourceUrl
82936
82960
  };
82937
82961
  const doc2 = await ShareDBDoc.load(docOptions);
82938
82962
  const enableComments = options == null ? void 0 : options.enableComments;
@@ -83080,7 +83104,7 @@ ${data2.flowchartText}
83080
83104
  }
83081
83105
  }
83082
83106
  });
83083
- editor.version = "2.1.5";
83107
+ editor.version = "2.1.7";
83084
83108
  if (Logger$2.level === LogLevel.DEBUG) {
83085
83109
  window.setReauthFail = (fail) => {
83086
83110
  window.isReauthError = fail;
@@ -83175,7 +83199,7 @@ ${data2.flowchartText}
83175
83199
  if (!clientType.isMobile) {
83176
83200
  OnesEditorToolbar.register(editor);
83177
83201
  }
83178
- editor.version = "2.1.5";
83202
+ editor.version = "2.1.7";
83179
83203
  return editor;
83180
83204
  }
83181
83205
  async function showDocVersions(editor, options, serverUrl) {
@@ -129449,6 +129473,7 @@ ${data2.flowchartText}
129449
129473
  exports2.toPlainText = toPlainText;
129450
129474
  exports2.toPlainTextKeepLength = toPlainTextKeepLength;
129451
129475
  exports2.trimChar = trimChar;
129476
+ exports2.turndownService = turndownService;
129452
129477
  exports2.unexclusiveBlock = unexclusiveBlock;
129453
129478
  exports2.unicodeLength = unicodeLength;
129454
129479
  exports2.unicodeSubstr = unicodeSubstr;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Embed, Box, i18n, OnesEditor, OnesEditorUser, OnesEditorUserPermission, OnesEditorBlockHook, OnesEditorCommandProvider, LogLevel, Block, ShortcutRecords, OnesEditorBlockRenderer } from '../@ones-editor/core';
1
+ import { Embed, Box, i18n, OnesEditor, OnesEditorUser, OnesEditorUserPermission, OnesEditorBlockHook, OnesEditorCommandProvider, LogLevel, Block, ShortcutRecords, OnesEditorBlockRenderer, BuildResourceUrlOptions, UploadResourceOptions, UploadResourceResult } from '../@ones-editor/core';
2
2
  import { DrawIoOptions } from '../@ones-editor/drawio-embed';
3
3
  import { FlowCharEmbedOptions, MermaidEmbedOptions, PlantumlEmbedOptions } from '../@ones-editor/graph-embed';
4
4
  import { ImageOptions } from '../@ones-editor/image-embed';
@@ -82,6 +82,8 @@ export interface CreateOnesEditorOptions {
82
82
  events?: EditorEvents;
83
83
  shortcuts?: ShortcutRecords[];
84
84
  componentsOptions?: EditorComponentOptions;
85
+ buildResourceUrl?: (resourceId: string, options?: BuildResourceUrlOptions) => string;
86
+ uploadResource?: (file: File, options?: UploadResourceOptions) => Promise<UploadResourceResult>;
85
87
  }
86
88
  export interface CreateLocalEditorOptions {
87
89
  id?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",