@ones-editor/editor 2.1.1-beta.47 → 2.1.1-beta.49

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.
package/dist/index.js CHANGED
@@ -6322,7 +6322,7 @@ div[data-command-bar-id=mobile-bottom-menu] .mobile-menu-wrap.editor-mention .co
6322
6322
  .command-item[data-id=preset-1] {
6323
6323
  background-color: #fff0d9 !important;
6324
6324
  }.command-m-bar {
6325
- position: sticky;
6325
+ position: fixed;
6326
6326
  z-index: 111;
6327
6327
  bottom: 0;
6328
6328
  height: 40px;
@@ -78992,7 +78992,6 @@ ${content}
78992
78992
  removeClass(this.endGripper, "active");
78993
78993
  }
78994
78994
  }
78995
- const mobile = "";
78996
78995
  class InsertMenuProvider extends ProxyProvider {
78997
78996
  constructor(editor) {
78998
78997
  super();
@@ -79295,40 +79294,62 @@ ${content}
79295
79294
  this.mobileToolbar.destroy();
79296
79295
  }
79297
79296
  }
79297
+ class ActiveElementObserver {
79298
+ constructor(options) {
79299
+ __publicField(this, "handleFocusIn", (event) => {
79300
+ if (this.isFormElement(event.target)) {
79301
+ this.options.onFocused();
79302
+ }
79303
+ });
79304
+ __publicField(this, "handleFocusOut", (event) => {
79305
+ if (this.isFormElement(event.target)) {
79306
+ this.options.onBlurred();
79307
+ }
79308
+ });
79309
+ this.options = options;
79310
+ document.addEventListener("focusin", this.handleFocusIn);
79311
+ document.addEventListener("focusout", this.handleFocusOut);
79312
+ }
79313
+ isFormElement(element) {
79314
+ return element.tagName === "INPUT" || element.tagName === "TEXTAREA";
79315
+ }
79316
+ destroy() {
79317
+ document.removeEventListener("focusin", this.handleFocusIn);
79318
+ document.removeEventListener("focusout", this.handleFocusOut);
79319
+ }
79320
+ }
79321
+ const mobile = "";
79298
79322
  class MobileCommandHandler {
79299
79323
  constructor(editor) {
79300
79324
  __publicField(this, "commandBar");
79325
+ __publicField(this, "observer");
79301
79326
  __publicField(this, "showKeyboard", false);
79302
- __publicField(this, "initViewportHeight", window.visualViewport.height);
79303
- __publicField(this, "toggle", () => {
79304
- if (this.isKeyboardShow) {
79305
- const offsetHeight = Math.max(document.body.clientHeight - this.virtualViewportHeight - document.documentElement.scrollTop - this.virtualViewportOffsetTop, 0);
79306
- this.commandBar.bar.style.bottom = `${offsetHeight}px`;
79307
- } else {
79308
- this.commandBar.bar.style.bottom = "0px";
79309
- }
79310
- });
79311
- __publicField(this, "handleViewportScroll", () => {
79312
- this.setDebugInfo();
79313
- this.toggle();
79314
- });
79327
+ __publicField(this, "initViewportHeight", this.window.visualViewport.height);
79328
+ __publicField(this, "toggle", debounce__default.default(() => {
79329
+ const offsetHeight = Math.max(this.clientHeight - this.virtualViewportHeight, 0);
79330
+ this.commandBar.bar.style.bottom = `${offsetHeight}px`;
79331
+ }, 100));
79315
79332
  __publicField(this, "handleFocusIn", () => {
79316
79333
  if (!this.showKeyboard) {
79317
79334
  this.showKeyboard = true;
79318
79335
  }
79336
+ this.setDebugInfo();
79337
+ this.toggle();
79319
79338
  });
79320
- __publicField(this, "handleFocusOut", (event) => {
79339
+ __publicField(this, "handleFocusOut", () => {
79321
79340
  if (this.showKeyboard) {
79322
79341
  this.showKeyboard = false;
79323
79342
  }
79343
+ this.setDebugInfo();
79344
+ this.toggle();
79324
79345
  });
79325
- var _a, _b;
79326
79346
  this.editor = editor;
79327
79347
  this.commandBar = new MobileToolbarHandler(editor, document.body);
79328
- document.addEventListener("focusin", this.handleFocusIn);
79329
- document.addEventListener("focusout", this.handleFocusOut);
79330
- (_a = window == null ? void 0 : window.visualViewport) == null ? void 0 : _a.addEventListener("scroll", this.handleViewportScroll);
79331
- (_b = window == null ? void 0 : window.visualViewport) == null ? void 0 : _b.addEventListener("resize", this.handleViewportScroll);
79348
+ this.observer = new ActiveElementObserver({
79349
+ onFocused: this.handleFocusIn,
79350
+ onBlurred: this.handleFocusOut
79351
+ });
79352
+ this.toggle();
79332
79353
  setTimeout(() => {
79333
79354
  const container = this.commandBar.bar.firstChild;
79334
79355
  if (container.scrollWidth > container.clientWidth) {
@@ -79339,24 +79360,31 @@ ${content}
79339
79360
  }, 500);
79340
79361
  }
79341
79362
  destroy() {
79342
- var _a, _b;
79343
- document.removeEventListener("focusin", this.handleFocusIn);
79344
- document.removeEventListener("focusout", this.handleFocusOut);
79345
- (_a = window == null ? void 0 : window.visualViewport) == null ? void 0 : _a.removeEventListener("scroll", this.handleViewportScroll);
79346
- (_b = window == null ? void 0 : window.visualViewport) == null ? void 0 : _b.removeEventListener("resize", this.handleViewportScroll);
79363
+ this.observer.destroy();
79364
+ this.commandBar.destroy();
79347
79365
  }
79348
79366
  get isKeyboardShow() {
79349
79367
  const isKeyboardShow = this.virtualViewportHeight < this.initViewportHeight;
79350
79368
  return isKeyboardShow;
79351
79369
  }
79352
79370
  get virtualViewportHeight() {
79353
- const virtualViewportHeight = window.visualViewport.height;
79371
+ const virtualViewportHeight = this.window.visualViewport.height;
79354
79372
  return virtualViewportHeight;
79355
79373
  }
79374
+ get clientHeight() {
79375
+ const clientHeight = this.window.document.body.clientHeight;
79376
+ return clientHeight;
79377
+ }
79356
79378
  get virtualViewportOffsetTop() {
79357
- const virtualViewportOffsetTop = window.visualViewport.offsetTop;
79379
+ const virtualViewportOffsetTop = this.window.visualViewport.offsetTop;
79358
79380
  return virtualViewportOffsetTop;
79359
79381
  }
79382
+ get window() {
79383
+ if (window.parent) {
79384
+ return window.parent;
79385
+ }
79386
+ return window;
79387
+ }
79360
79388
  setDebugInfo() {
79361
79389
  setInterval(() => {
79362
79390
  const visualViewport = document.querySelector("#visualViewport");
@@ -79364,18 +79392,18 @@ ${content}
79364
79392
  const clientHeight = document.querySelector("#clientHeight");
79365
79393
  const bottom = document.querySelector("#bottom");
79366
79394
  visualViewport.innerText = JSON.stringify({
79367
- height: window.visualViewport.height,
79368
- offsetTop: window.visualViewport.offsetTop,
79369
- scale: window.visualViewport.scale,
79370
- pageTop: window.visualViewport.pageTop,
79371
- onscroll: window.visualViewport.onscroll
79395
+ height: this.window.visualViewport.height,
79396
+ offsetTop: this.window.visualViewport.offsetTop,
79397
+ scale: this.window.visualViewport.scale,
79398
+ pageTop: this.window.visualViewport.pageTop,
79399
+ onscroll: this.window.visualViewport.onscroll
79372
79400
  });
79373
79401
  scrollTop.innerText = JSON.stringify(document.documentElement.scrollTop);
79374
- clientHeight.innerText = `${JSON.stringify(document.body.clientHeight)} , offset: ${document.body.offsetTop}`;
79402
+ clientHeight.innerText = `${JSON.stringify(this.clientHeight)} , offset: ${Math.max(this.clientHeight - this.virtualViewportHeight, 0)}`;
79375
79403
  const bottomOffset = this.commandBar.bar.style.bottom;
79376
79404
  bottom.innerText = JSON.stringify(bottomOffset);
79377
79405
  const d = document.querySelector("#debug");
79378
- d.style.top = `${window.visualViewport.offsetTop}px`;
79406
+ d.style.top = `${this.window.visualViewport.offsetTop}px`;
79379
79407
  }, 1e3);
79380
79408
  }
79381
79409
  }
@@ -85818,7 +85846,7 @@ ${data2.flowchartText}
85818
85846
  }
85819
85847
  }
85820
85848
  });
85821
- editor.version = "2.1.1-beta.47";
85849
+ editor.version = "2.1.1-beta.49";
85822
85850
  if (Logger$2.level === LogLevel.DEBUG) {
85823
85851
  window.setReauthFail = (fail) => {
85824
85852
  window.isReauthError = fail;
@@ -85916,7 +85944,7 @@ ${data2.flowchartText}
85916
85944
  });
85917
85945
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
85918
85946
  OnesEditorToolbar.register(editor);
85919
- editor.version = "2.1.1-beta.47";
85947
+ editor.version = "2.1.1-beta.49";
85920
85948
  return editor;
85921
85949
  }
85922
85950
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.1.1-beta.47",
3
+ "version": "2.1.1-beta.49",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",