@ones-editor/editor 2.1.1-beta.63 → 2.1.1-beta.67

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,9 +1,9 @@
1
- import { BlockElement, CommandItem, CommandParams, OnesEditor, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockElement, CommandItem, CommandItemWithSource, CommandParams, OnesEditor, SelectionRange } from '../../../../@ones-editor/core';
2
2
  import { ProxyProvider } from './proxy-provider';
3
3
  export default class InsertAboveProvider extends ProxyProvider {
4
4
  private editor;
5
5
  id: string;
6
6
  constructor(editor: OnesEditor);
7
7
  getAvailableCommands: (editor: OnesEditor, block: BlockElement) => CommandItem[];
8
- executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItem, params: CommandParams) => boolean;
8
+ executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItemWithSource, params: CommandParams) => boolean;
9
9
  }
@@ -1,9 +1,9 @@
1
- import { BlockElement, CommandItem, CommandParams, OnesEditor, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockElement, CommandItem, CommandItemWithSource, CommandParams, OnesEditor, SelectionRange } from '../../../../@ones-editor/core';
2
2
  import { ProxyProvider } from './proxy-provider';
3
3
  export default class InsertAfterProvider extends ProxyProvider {
4
4
  private editor;
5
5
  id: string;
6
6
  constructor(editor: OnesEditor);
7
7
  getAvailableCommands: (editor: OnesEditor, block: BlockElement) => CommandItem[];
8
- executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItem, params: CommandParams) => boolean;
8
+ executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItemWithSource, params: CommandParams) => boolean;
9
9
  }
@@ -1,4 +1,4 @@
1
- import { BlockElement, CommandItem, CommandParams, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockElement, CommandItem, CommandItemWithSource, CommandParams, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  import { ProxyProvider } from './proxy-provider';
3
3
  export declare class InlineBoxCommandProvider extends ProxyProvider implements OnesEditorCommandProvider {
4
4
  private editor;
@@ -7,6 +7,6 @@ export declare class InlineBoxCommandProvider extends ProxyProvider implements O
7
7
  create(commands: CommandItem[]): CommandItem[];
8
8
  getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => CommandItem[];
9
9
  getInsertCommands: (editor: OnesEditor, containerId: string) => CommandItem[];
10
- executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams) => boolean;
11
- executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, item: CommandItem, params: CommandParams) => boolean;
10
+ executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItemWithSource, params: CommandParams) => boolean;
11
+ executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, item: CommandItemWithSource, params: CommandParams) => boolean;
12
12
  }
@@ -1,4 +1,4 @@
1
- import { BlockElement, CommandItem, CommandParams, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockElement, CommandItem, CommandItemWithSource, CommandParams, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  import { ProxyProvider } from './proxy-provider';
3
3
  import { QuickMenuCommandProvider } from '../quick-menu/types';
4
4
  export default class InsertMenuProvider extends ProxyProvider {
@@ -11,6 +11,6 @@ export default class InsertMenuProvider extends ProxyProvider {
11
11
  constructor(editor: OnesEditor, options?: CommandParams | undefined);
12
12
  getInsertCommands: (editor: OnesEditor, containerId: string) => CommandItem[];
13
13
  getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange) => CommandItem[];
14
- executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, item: CommandItem, params: CommandParams) => boolean;
15
- executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams) => boolean;
14
+ executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, item: CommandItemWithSource, params: CommandParams) => boolean;
15
+ executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItemWithSource, params: CommandParams) => boolean;
16
16
  }
@@ -1,4 +1,4 @@
1
- import { BlockElement, CommandItem, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockElement, CommandItem, CommandItemWithSource, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  export declare class MobileLinkProvider implements OnesEditorCommandProvider {
3
3
  id: string;
4
4
  insertProvider: OnesEditorCommandProvider;
@@ -6,5 +6,5 @@ export declare class MobileLinkProvider implements OnesEditorCommandProvider {
6
6
  constructor(editor: OnesEditor);
7
7
  getSelectedLinkChild: (editor: OnesEditor, range: SelectionRange) => import("@ones-editor/core").TextBlockContentChild | null;
8
8
  getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams) => CommandItem[];
9
- executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result?: CommandResult) => boolean;
9
+ executeCommand: (editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItemWithSource, params: CommandParams, result?: CommandResult) => boolean;
10
10
  }
@@ -1,9 +1,9 @@
1
- import { BlockElement, CommandItem, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockElement, CommandItem, CommandItemWithSource, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  export declare abstract class ProxyProvider implements OnesEditorCommandProvider {
3
3
  abstract id: string;
4
4
  providers: OnesEditorCommandProvider[];
5
5
  getAvailableCommands: (editor: OnesEditor, block: BlockElement, range: SelectionRange, params?: CommandParams) => CommandItem[];
6
6
  getInsertCommands: (editor: OnesEditor, containerId: string) => CommandItem[];
7
- executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItem, params: CommandParams, result?: CommandResult): boolean;
8
- executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, item: CommandItem, params: CommandParams, result?: CommandResult) => boolean;
7
+ executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, command: CommandItemWithSource, params: CommandParams, result?: CommandResult): boolean;
8
+ executeInsertCommand: (editor: OnesEditor, containerId: string, blockIndex: number, item: CommandItemWithSource, params: CommandParams, result?: CommandResult) => boolean;
9
9
  }
@@ -1,4 +1,4 @@
1
- import { BlockAttributesHandler, BlockElement, CommandItem, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
1
+ import { BlockAttributesHandler, BlockElement, CommandItem, CommandItemWithSource, CommandParams, CommandResult, OnesEditor, OnesEditorCommandProvider, SelectionRange } from '../../../../@ones-editor/core';
2
2
  export default class TextCommandProvider implements OnesEditorCommandProvider {
3
3
  private editor;
4
4
  private options?;
@@ -7,7 +7,7 @@ export default class TextCommandProvider implements OnesEditorCommandProvider {
7
7
  private providers;
8
8
  constructor(editor: OnesEditor, options?: CommandParams | undefined);
9
9
  getAvailableCommands(editor: OnesEditor, block: BlockElement, range: SelectionRange): CommandItem[];
10
- executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItem, params: CommandParams, result?: CommandResult): boolean;
10
+ executeCommand(editor: OnesEditor, block: BlockElement, range: SelectionRange, item: CommandItemWithSource, params: CommandParams, result?: CommandResult): boolean;
11
11
  get blockAttributesHandler(): BlockAttributesHandler;
12
12
  private executeCommandOnEmptyText;
13
13
  private setCommandsStates;
@@ -16,6 +16,7 @@ export interface AutoSuggestMenuOptions {
16
16
  disableSelectedScroll?: boolean;
17
17
  onClose?: () => void;
18
18
  onShow?: (menu: AutoSuggestMenu) => boolean | undefined;
19
+ onShown?: (menu: AutoSuggestMenu) => void;
19
20
  onClickItem: (menu: AutoSuggestMenu, item: CommandItem) => void;
20
21
  queryItems: (menu: AutoSuggestMenu, text: string) => Promise<CommandItem[]>;
21
22
  renderMenuItem?: (menu: AutoSuggestMenu, item: CommandItem) => HTMLElement | undefined;
@@ -40,6 +41,7 @@ export default class AutoSuggestMenu {
40
41
  handleSearchTextPure(text: string): Promise<void>;
41
42
  handleClick: import("lodash").DebouncedFuncLeading<(menu: AbstractCommandBar, item: CommandItem) => void>;
42
43
  handleShow: (menu: AbstractCommandBar) => void;
44
+ handleShown: () => void;
43
45
  handleClose: () => void;
44
46
  handleKeydown: (event: KeyboardEvent) => boolean;
45
47
  protected highlightText(search: string, items?: CommandItem[]): void;
@@ -26,6 +26,7 @@ export interface AutoSuggestOptions {
26
26
  onClickItem: (menu: OnesEditorAutoSuggest, item: CommandItem, anchor: AutoSuggestAnchor) => void;
27
27
  queryItems: (menu: OnesEditorAutoSuggest, text: string) => Promise<CommandItem[]>;
28
28
  renderMenuItem?: (menu: OnesEditorAutoSuggest, item: CommandItem) => HTMLElement | undefined;
29
+ onShown?: (menu: OnesEditorAutoSuggest) => void;
29
30
  }
30
31
  declare class OnesEditorAutoSuggest implements OnesEditorInputHandler {
31
32
  private editor;
@@ -46,6 +47,7 @@ declare class OnesEditorAutoSuggest implements OnesEditorInputHandler {
46
47
  deleteTrigger: () => boolean;
47
48
  private onClose;
48
49
  private onShow;
50
+ private onShown;
49
51
  private onClickItem;
50
52
  private queryItems;
51
53
  private renderMenuItem;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import { LayoutQuickMenuItemFilter, isLayoutBlock } from '../@ones-editor/layout
7
7
  import ShareDBDocVersionsProvider from './versions/versions-provider';
8
8
  import { CreateLocalEditorOptions, CreateOnesEditorOptions } from './types';
9
9
  import './lang';
10
+ export * from '../@ones-editor/scroll-container';
10
11
  export * from '../@ones-editor/to-docx';
11
12
  export * from '../@ones-editor/core';
12
13
  export * from '../@ones-editor/sharedb-doc';
package/dist/index.js CHANGED
@@ -8985,9 +8985,6 @@ var __publicField = (obj, key, value) => {
8985
8985
  });
8986
8986
  return elem || document.body;
8987
8987
  }
8988
- function ensureIsMobileEvent$1(events2) {
8989
- return clientType.isMobile;
8990
- }
8991
8988
  function createMouseEventFromTouchEvent(event, type) {
8992
8989
  const touch = event.changedTouches[0];
8993
8990
  const mouseEvent = new MouseEvent("mousedown", {
@@ -9002,24 +8999,24 @@ var __publicField = (obj, key, value) => {
9002
8999
  Object.defineProperty(mouseEvent, "target", { value: event.target, enumerable: true });
9003
9000
  return mouseEvent;
9004
9001
  }
9005
- function bindTouchEnd(elem, callback) {
9006
- let isMove = false;
9007
- const handleTouchMove = (e2) => {
9008
- isMove = true;
9009
- };
9010
- const handleTouchEnd = (e2) => {
9011
- if (isMove) {
9012
- e2.stopPropagation();
9002
+ function ensureIsMobileEvent(events2) {
9003
+ return events2 instanceof TouchEvent;
9004
+ }
9005
+ function bindDbClick(elem, handler) {
9006
+ let touchTime = 0;
9007
+ const callback = (event) => {
9008
+ if (touchTime === 0) {
9009
+ touchTime = new Date().getTime();
9010
+ } else {
9011
+ if (new Date().getTime() - touchTime < 800) {
9012
+ handler(event);
9013
+ }
9014
+ touchTime = 0;
9013
9015
  }
9014
- isMove = false;
9015
9016
  };
9016
- window.addEventListener("touchmove", handleTouchMove);
9017
- window.addEventListener("touchend", handleTouchEnd, true);
9018
- elem.addEventListener("touchend", callback);
9017
+ elem.addEventListener("click", callback);
9019
9018
  return () => {
9020
- window.removeEventListener("touchmove", handleTouchMove);
9021
- window.removeEventListener("touchend", handleTouchEnd, true);
9022
- elem.removeEventListener("touchend", callback);
9019
+ elem.removeEventListener("click", callback);
9023
9020
  };
9024
9021
  }
9025
9022
  class ScrollDomElement {
@@ -11233,32 +11230,22 @@ var __publicField = (obj, key, value) => {
11233
11230
  }
11234
11231
  const logger$4m = getLogger("root-container");
11235
11232
  const MIN_DISTANCE_THRESHOLD = 3;
11236
- function ensureIsMobileEvent(events2) {
11237
- return events2 instanceof TouchEvent;
11238
- }
11239
- function bindDbClick(elem, handler) {
11240
- let touchTime = 0;
11241
- const callback = (event) => {
11242
- if (touchTime === 0) {
11243
- touchTime = new Date().getTime();
11244
- } else {
11245
- if (new Date().getTime() - touchTime < 800) {
11246
- handler(event);
11247
- }
11248
- touchTime = 0;
11249
- }
11250
- };
11251
- elem.addEventListener("click", callback);
11252
- return () => {
11253
- elem.removeEventListener("click", callback);
11254
- };
11255
- }
11256
11233
  class RootContainer {
11257
11234
  constructor(editor, rootContainer) {
11258
11235
  __publicField(this, "resizeObserver");
11259
11236
  __publicField(this, "isMoved", false);
11260
11237
  __publicField(this, "mouseDownEvent", null);
11261
11238
  __publicField(this, "dbClickRef", null);
11239
+ __publicField(this, "isMove", false);
11240
+ __publicField(this, "handleTouchMove", (e2) => {
11241
+ this.isMove = true;
11242
+ });
11243
+ __publicField(this, "handleTouchEnd", (e2) => {
11244
+ if (this.isMove) {
11245
+ e2.stopPropagation();
11246
+ }
11247
+ this.isMove = false;
11248
+ });
11262
11249
  __publicField(this, "handleContextMenu", (event) => {
11263
11250
  if (clientType.isSafari) {
11264
11251
  const sel = document.getSelection();
@@ -11400,18 +11387,19 @@ var __publicField = (obj, key, value) => {
11400
11387
  this.resizeObserver.observe(rootContainer);
11401
11388
  const container = this.editor.rootElement;
11402
11389
  if (clientType.isMobile) {
11403
- bindTouchEnd(container, this.handleMouseDown);
11404
- container.onclick = this.handleClick;
11390
+ container.ontouchend = this.handleMouseDown;
11391
+ window.addEventListener("touchmove", this.handleTouchMove);
11392
+ window.addEventListener("touchend", this.handleTouchEnd, true);
11405
11393
  } else {
11406
11394
  container.onmousedown = this.handleMouseDown;
11407
11395
  container.oncontextmenu = this.handleContextMenu;
11408
- container.onclick = this.handleClick;
11409
11396
  }
11410
11397
  if (clientType.isIOS) {
11411
11398
  this.dbClickRef = bindDbClick(container, this.handleDblClick);
11412
11399
  } else {
11413
11400
  container.ondblclick = this.handleDblClick;
11414
11401
  }
11402
+ container.onclick = this.handleClick;
11415
11403
  }
11416
11404
  unbindEvents() {
11417
11405
  this.resizeObserver.disconnect();
@@ -11420,6 +11408,9 @@ var __publicField = (obj, key, value) => {
11420
11408
  container.ondblclick = null;
11421
11409
  container.onclick = null;
11422
11410
  container.oncontextmenu = null;
11411
+ container.ontouchend = null;
11412
+ window.removeEventListener("touchmove", this.handleTouchMove);
11413
+ window.removeEventListener("touchend", this.handleTouchEnd, true);
11423
11414
  if (this.dbClickRef) {
11424
11415
  this.dbClickRef();
11425
11416
  this.dbClickRef = null;
@@ -24740,7 +24731,7 @@ var __publicField = (obj, key, value) => {
24740
24731
  });
24741
24732
  __publicField(this, "handleDocumentClick", (event) => {
24742
24733
  const rootContainer = this.editor.rootContainer;
24743
- const target = clientType.isMobile ? event.changedTouches[0].target : event.target;
24734
+ const target = ensureIsMobileEvent(event) ? event.changedTouches[0].target : event.target;
24744
24735
  const isInDisableScrollMask = this.isInDisableScrollMask(target);
24745
24736
  if (target && (isInDisableScrollMask || rootContainer.contains(target))) {
24746
24737
  if (!isInDisableScrollMask && !isInBlockTools(target)) {
@@ -24878,7 +24869,7 @@ var __publicField = (obj, key, value) => {
24878
24869
  input2.addEventListener("compositionend", this.handleCompositionend);
24879
24870
  this.inputElement = input2;
24880
24871
  if (clientType.isMobile) {
24881
- bindTouchEnd(document, this.handleDocumentClick);
24872
+ document.addEventListener("touchend", this.handleDocumentClick);
24882
24873
  } else {
24883
24874
  document.addEventListener("mousedown", this.handleDocumentClick);
24884
24875
  }
@@ -24927,7 +24918,7 @@ var __publicField = (obj, key, value) => {
24927
24918
  this.editor.selection.caret.update();
24928
24919
  }
24929
24920
  if (clientType.isMobile) {
24930
- this.inputElement.focus();
24921
+ this.inputElement.focus(options);
24931
24922
  this.callbacks.onFocus();
24932
24923
  } else {
24933
24924
  setTimeout(() => {
@@ -27102,7 +27093,7 @@ var __publicField = (obj, key, value) => {
27102
27093
  if (newEndPos.blockId !== currentBlockId) {
27103
27094
  newEndPos = createSimpleBlockPosition(block, getBlockTextLength$6(editor, block), "end");
27104
27095
  }
27105
- editor.selection.setSelection(newStartPos, newEndPos, { noScroll: true });
27096
+ editor.selection.setSelection(newStartPos, newEndPos);
27106
27097
  }
27107
27098
  function editorFocusToEnd(editor) {
27108
27099
  editorSelectEnd(editor);
@@ -27531,8 +27522,8 @@ var __publicField = (obj, key, value) => {
27531
27522
  __publicField(this, "handleMouseDown", (event, options) => {
27532
27523
  var _a;
27533
27524
  this.mouseDownEvent = event;
27534
- const x = ensureIsMobileEvent$1() ? event.changedTouches[0].clientX : event.x;
27535
- const y = ensureIsMobileEvent$1() ? event.changedTouches[0].clientY : event.y;
27525
+ const x = ensureIsMobileEvent(event) ? event.changedTouches[0].clientX : event.x;
27526
+ const y = ensureIsMobileEvent(event) ? event.changedTouches[0].clientY : event.y;
27536
27527
  const range = getBlockNearestRangeFromPoint(this.editor, x, y);
27537
27528
  if (range) {
27538
27529
  if (range instanceof EditorComplexSelectionRange) {
@@ -27569,7 +27560,7 @@ var __publicField = (obj, key, value) => {
27569
27560
  return;
27570
27561
  if (!this.mouseDownEvent)
27571
27562
  return;
27572
- if (ensureIsMobileEvent$1(this.mouseDownEvent))
27563
+ if (ensureIsMobileEvent(this.mouseDownEvent))
27573
27564
  return;
27574
27565
  if (Math.abs(this.mouseDownEvent.x - event.x) < 3 && Math.abs(this.mouseDownEvent.y - event.y) < 3) {
27575
27566
  return;
@@ -40483,6 +40474,10 @@ ${codeText}
40483
40474
  }, 300, { leading: true, trailing: false }));
40484
40475
  __publicField(this, "handleShow", (menu) => {
40485
40476
  });
40477
+ __publicField(this, "handleShown", () => {
40478
+ var _a, _b;
40479
+ (_b = (_a = this.options).onShown) == null ? void 0 : _b.call(_a, this);
40480
+ });
40486
40481
  __publicField(this, "handleClose", () => {
40487
40482
  var _a, _b;
40488
40483
  (_b = (_a = this.options).onClose) == null ? void 0 : _b.call(_a);
@@ -40509,6 +40504,7 @@ ${codeText}
40509
40504
  this.menu.addListener("click", this.handleClick);
40510
40505
  this.menu.addListener("close", this.handleClose);
40511
40506
  this.menu.addListener("show", this.handleShow);
40507
+ this.menu.addListener("shown", this.handleShown);
40512
40508
  if (this.options.wait) {
40513
40509
  this.handleSearchText = debounce__default.default(async (text2) => {
40514
40510
  this.handleSearchTextPure(text2);
@@ -41310,6 +41306,10 @@ ${codeText}
41310
41306
  }
41311
41307
  return void 0;
41312
41308
  });
41309
+ __publicField(this, "onShown", () => {
41310
+ var _a, _b;
41311
+ (_b = (_a = this.options).onShown) == null ? void 0 : _b.call(_a, this);
41312
+ });
41313
41313
  __publicField(this, "onClickItem", (menu, item) => {
41314
41314
  if (!this.anchor) {
41315
41315
  return;
@@ -41343,6 +41343,7 @@ ${codeText}
41343
41343
  highlight: options.highlight,
41344
41344
  onClose: this.onClose,
41345
41345
  onShow: this.onShow,
41346
+ onShown: this.onShown,
41346
41347
  onClickItem: this.onClickItem,
41347
41348
  queryItems: this.queryItems,
41348
41349
  renderMenuItem: this.renderMenuItem
@@ -49701,6 +49702,9 @@ ${codeText}
49701
49702
  super();
49702
49703
  __publicField(this, "linkPopup");
49703
49704
  __publicField(this, "onShow", () => {
49705
+ const scrollContainer = getScrollContainer$1(document.body);
49706
+ const clientHeight = scrollContainer.clientHeight;
49707
+ this.linkPopup.content.style.maxHeight = `${clientHeight - 20}px`;
49704
49708
  this.emit("show");
49705
49709
  });
49706
49710
  __publicField(this, "close", () => {
@@ -49746,13 +49750,7 @@ ${codeText}
49746
49750
  const { target } = this.options;
49747
49751
  this.linkPopup.addListener("show", this.onShow);
49748
49752
  this.linkPopup.addListener("shown", this.handleShown);
49749
- document.activeElement.blur();
49750
- setTimeout(() => {
49751
- const scrollContainer = getScrollContainer$1(document.body);
49752
- const clientHeight = scrollContainer.clientHeight;
49753
- this.linkPopup.content.style.maxHeight = `${clientHeight - 20}px`;
49754
- this.linkPopup.manualShow(target);
49755
- }, 200);
49753
+ this.linkPopup.manualShow(target);
49756
49754
  });
49757
49755
  this.editor = editor;
49758
49756
  this.content = content;
@@ -65002,7 +65000,7 @@ ${codeText}
65002
65000
  }
65003
65001
  get commands() {
65004
65002
  var _a, _b, _c, _d;
65005
- if (this.editor.readonly || clientType.isMobile) {
65003
+ if (clientType.isMobile) {
65006
65004
  return [];
65007
65005
  }
65008
65006
  let standardCommands = [];
@@ -78405,6 +78403,14 @@ ${content}
78405
78403
  }
78406
78404
  return true;
78407
78405
  });
78406
+ __publicField(this, "onShown", (bar2) => {
78407
+ if (clientType.isMobile) {
78408
+ const mobileWrap = this.getMobileCommandElement();
78409
+ const input2 = mobileWrap.querySelector("input");
78410
+ input2.focus();
78411
+ scrollIntoView(bar2.menu.menu, this.editor);
78412
+ }
78413
+ });
78408
78414
  __publicField(this, "handleClickItem", (item) => {
78409
78415
  const user = item.data;
78410
78416
  const mentionData = {
@@ -78475,33 +78481,40 @@ ${content}
78475
78481
  this.createMobileItems(content, items, find);
78476
78482
  });
78477
78483
  }, 100));
78478
- __publicField(this, "createMobileCommandItem", (items) => {
78484
+ __publicField(this, "getMobileCommandElement", () => {
78485
+ if (this.mobileWrap) {
78486
+ return this.mobileWrap;
78487
+ }
78479
78488
  this.mobileWrap = createElement("div", ["mobile-item-wrap"], null);
78480
78489
  const content = createElement("div", ["mobile-item-content"], null);
78481
- const clientHeight = this.editor.scrollContainer.clientHeight;
78482
- content.style.maxHeight = `${clientHeight - 180}px`;
78483
78490
  const icon = createElement("div", ["editor-input-icon"], null);
78484
78491
  icon.innerHTML = SearchIcon;
78485
- const input2 = createInput(this.mobileWrap, {
78492
+ createInput(this.mobileWrap, {
78486
78493
  onChange: (e2) => this.onInputChanged(content, e2),
78487
78494
  placeholder: i18n$1.t("mention.placeholder"),
78488
78495
  prefix: icon,
78489
78496
  suffixClose: true
78490
78497
  });
78491
- setTimeout(() => {
78492
- input2.focus();
78493
- }, 200);
78494
78498
  this.mobileWrap.appendChild(content);
78495
- this.createMobileItems(content, items, "");
78496
78499
  this.mobileWrap.addEventListener("click", this.handleMobileWrapClick);
78497
78500
  content.addEventListener("scroll", () => {
78498
78501
  var _a;
78499
78502
  return (_a = document.activeElement) == null ? void 0 : _a.blur();
78500
78503
  });
78504
+ return this.mobileWrap;
78505
+ });
78506
+ __publicField(this, "createMobileCommandItem", (items) => {
78507
+ const mobileWrap = this.getMobileCommandElement();
78508
+ const content = mobileWrap.querySelector(".mobile-item-content");
78509
+ this.createMobileItems(content, items, "");
78510
+ setTimeout(() => {
78511
+ const clientHeight = this.editor.scrollContainer.clientHeight;
78512
+ content.style.maxHeight = `${clientHeight - 180}px`;
78513
+ }, 60);
78501
78514
  return [{
78502
78515
  id: "create-mobile-item",
78503
78516
  name: "Create Mobile Item",
78504
- element: this.mobileWrap
78517
+ element: mobileWrap
78505
78518
  }];
78506
78519
  });
78507
78520
  __publicField(this, "_queryItems", async (text2) => {
@@ -78540,6 +78553,7 @@ ${content}
78540
78553
  showLoading: true,
78541
78554
  header: this.createMobileHeader(),
78542
78555
  onShow: this.onShow,
78556
+ onShown: this.onShown,
78543
78557
  onClickItem: this.onClickItem,
78544
78558
  queryItems: this.queryItems,
78545
78559
  onClose: this.onClose
@@ -82221,7 +82235,7 @@ ${content}
82221
82235
  }
82222
82236
  function getBlockProperties$5(editor, block) {
82223
82237
  const properties = getStandardEmbedBlockProperties(editor, block, {
82224
- presetIds: ["add-comment"],
82238
+ presetIds: editor.readonly ? [] : ["add-comment"],
82225
82239
  extCommands: [{
82226
82240
  id: "refresh",
82227
82241
  name: i18n$1.t("webpage.command.refresh"),
@@ -83027,9 +83041,6 @@ ${content}
83027
83041
  return false;
83028
83042
  },
83029
83043
  extCommands: (editor2, block2) => {
83030
- if (editor2.readonly) {
83031
- return [];
83032
- }
83033
83044
  const blockContent = getBlockContent(block2);
83034
83045
  const drawioImg = blockContent.querySelector(".editor-drawio-content img");
83035
83046
  return [{
@@ -83039,8 +83050,8 @@ ${content}
83039
83050
  states: !drawioImg ? ["disabled"] : []
83040
83051
  }];
83041
83052
  },
83042
- presetIds: ["edit"],
83043
- extIds: ["separator", "add-comment"]
83053
+ presetIds: editor.readonly ? [] : ["edit"],
83054
+ extIds: editor.readonly ? [] : ["separator", "add-comment"]
83044
83055
  });
83045
83056
  return { ...properties, abstract: i18n$1.t("drawio.abstract") };
83046
83057
  }
@@ -83274,12 +83285,17 @@ ${content}
83274
83285
  plantuml: "https://plantuml.com/"
83275
83286
  };
83276
83287
  class GraphBlockCommands {
83277
- constructor(graphType, properties) {
83278
- __publicField(this, "presetIds", ["edit"]);
83279
- __publicField(this, "extIds", ["separator", "add-comment"]);
83288
+ constructor(editor, graphType, properties) {
83289
+ this.editor = editor;
83280
83290
  this.graphType = graphType;
83281
83291
  this.properties = properties;
83282
83292
  }
83293
+ get presetIds() {
83294
+ return this.editor.readonly ? [] : ["edit"];
83295
+ }
83296
+ get extIds() {
83297
+ return this.editor.readonly ? [] : ["separator", "add-comment"];
83298
+ }
83283
83299
  extCommands(editor, block) {
83284
83300
  const commands = [
83285
83301
  {
@@ -83288,9 +83304,6 @@ ${content}
83288
83304
  icon: HelpIcon
83289
83305
  }
83290
83306
  ];
83291
- if (editor.readonly) {
83292
- return commands;
83293
- }
83294
83307
  const blockContent = getBlockContent(block);
83295
83308
  const graphImg = blockContent.querySelector("img.graph-embed-image");
83296
83309
  const graphImgSrc = graphImg == null ? void 0 : graphImg.src;
@@ -83322,7 +83335,7 @@ ${content}
83322
83335
  }
83323
83336
  }
83324
83337
  function getGraphEmbedBlockProperties(editor, block, type, properties) {
83325
- const standardProperties = getStandardEmbedBlockProperties(editor, block, new GraphBlockCommands(type, properties));
83338
+ const standardProperties = getStandardEmbedBlockProperties(editor, block, new GraphBlockCommands(editor, type, properties));
83326
83339
  return { ...standardProperties, abstract: lodash.exports.capitalize(type) };
83327
83340
  }
83328
83341
  class GraphBase {
@@ -86759,7 +86772,7 @@ ${data2.flowchartText}
86759
86772
  }
86760
86773
  }
86761
86774
  });
86762
- editor.version = "2.1.1-beta.63";
86775
+ editor.version = "2.1.1-beta.67";
86763
86776
  if (Logger$2.level === LogLevel.DEBUG) {
86764
86777
  window.setReauthFail = (fail) => {
86765
86778
  window.isReauthError = fail;
@@ -86857,7 +86870,7 @@ ${data2.flowchartText}
86857
86870
  });
86858
86871
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
86859
86872
  OnesEditorToolbar.register(editor);
86860
- editor.version = "2.1.1-beta.63";
86873
+ editor.version = "2.1.1-beta.67";
86861
86874
  return editor;
86862
86875
  }
86863
86876
  async function showDocVersions(editor, options, serverUrl) {
@@ -132691,6 +132704,7 @@ ${data2.flowchartText}
132691
132704
  exports2.RequestReloadError = RequestReloadError;
132692
132705
  exports2.RichText = RichText;
132693
132706
  exports2.ScriptDropdownProvider = ScriptDropdownProvider;
132707
+ exports2.ScrollContainer = ScrollContainer;
132694
132708
  exports2.ShareDBDoc = ShareDBDoc;
132695
132709
  exports2.ShareDBDocVersionsProvider = ShareDBDocVersionsProvider;
132696
132710
  exports2.ShareDBServer = ShareDBServer;
@@ -132722,8 +132736,8 @@ ${data2.flowchartText}
132722
132736
  exports2.applyPlaceholderToBlock = applyPlaceholderToBlock;
132723
132737
  exports2.assert = assert;
132724
132738
  exports2.autoShowHideTemplates = autoShowHideTemplates;
132739
+ exports2.bindDbClick = bindDbClick;
132725
132740
  exports2.bindKeyDownEvent = bindKeyDownEvent;
132726
- exports2.bindTouchEnd = bindTouchEnd;
132727
132741
  exports2.blob2String = blob2String$1;
132728
132742
  exports2.blobToDataUrl = blobToDataUrl;
132729
132743
  exports2.blobToString = blobToString;
@@ -132793,6 +132807,7 @@ ${data2.flowchartText}
132793
132807
  exports2.createRange = createRange;
132794
132808
  exports2.createRichText = createRichText;
132795
132809
  exports2.createRootContainer = createRootContainer;
132810
+ exports2.createScrollContainer = createScrollContainer;
132796
132811
  exports2.createSimpleBlockPosition = createSimpleBlockPosition;
132797
132812
  exports2.createSimpleDocPos = createSimpleDocPos;
132798
132813
  exports2.createTextBlockData = createTextBlockData;
@@ -132887,7 +132902,7 @@ ${data2.flowchartText}
132887
132902
  exports2.editorUpdateCompositionText = editorUpdateCompositionText;
132888
132903
  exports2.editorUpdateEmbedData = editorUpdateEmbedData;
132889
132904
  exports2.enablePageScroll = enablePageScroll;
132890
- exports2.ensureIsMobileEvent = ensureIsMobileEvent$1;
132905
+ exports2.ensureIsMobileEvent = ensureIsMobileEvent;
132891
132906
  exports2.escapeHtmlText = escapeHtmlText;
132892
132907
  exports2.escapeRegExp = escapeRegExp;
132893
132908
  exports2.escapeSpace = escapeSpace;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.1.1-beta.63",
3
+ "version": "2.1.1-beta.67",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",