@ones-editor/editor 5.0.3 → 5.0.4-beta.ONES22302091.1

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
@@ -25955,29 +25955,42 @@ var __publicField = (obj, key, value) => {
25955
25955
  __publicField(this, "hoveringTextChild", null);
25956
25956
  __publicField(this, "filters", []);
25957
25957
  __publicField(this, "finders", []);
25958
+ __publicField(this, "pendingEvent", null);
25959
+ __publicField(this, "animationFrame", null);
25958
25960
  __publicField(this, "handleDocumentMouseMove", (event) => {
25959
25961
  if (this.hoveringBlock) {
25960
25962
  for (const filter of this.filters) {
25961
25963
  if (filter.isInBlock(this.hoveringBlock, event)) {
25964
+ this.cancelPendingEvent();
25962
25965
  return;
25963
25966
  }
25964
25967
  }
25965
25968
  }
25966
- const elem = getElementFromPoint(event.x, event.y, { noFilter: true });
25967
- if (!elem) {
25968
- this.setHoveringBlock(null, event, null, elem);
25969
+ const inEditor = event.target instanceof Node && this.editor.rootElement.contains(event.target);
25970
+ const inFinder = !inEditor && this.finders.some((finder) => !finder.isInScope || finder.isInScope(this.editor, event));
25971
+ if (!inEditor && !inFinder) {
25972
+ this.cancelPendingEvent();
25973
+ if (this.hoveringBlock || this.hoveringTextChild || this.hoveringElem) {
25974
+ this.setHoveringBlock(null, event, null, null);
25975
+ }
25969
25976
  return;
25970
25977
  }
25971
- let block = getParentBlock(elem);
25972
- if (!block || !isChildNode(this.editor.rootContainer, block)) {
25973
- block = this.findBlockByFinders(event);
25974
- if (!block) {
25975
- this.setHoveringBlock(null, event, null, elem);
25976
- return;
25977
- }
25978
+ if (event.type === "click") {
25979
+ this.processMouseMove(event);
25980
+ return;
25981
+ }
25982
+ this.pendingEvent = event;
25983
+ if (this.animationFrame === null) {
25984
+ this.animationFrame = requestAnimationFrame(this.flushPendingEvent);
25985
+ }
25986
+ });
25987
+ __publicField(this, "flushPendingEvent", () => {
25988
+ this.animationFrame = null;
25989
+ const event = this.pendingEvent;
25990
+ this.pendingEvent = null;
25991
+ if (event) {
25992
+ this.processMouseMove(event);
25978
25993
  }
25979
- const child = this.getParentTextContentChild(block, elem);
25980
- this.setHoveringBlock(block, event, child, elem);
25981
25994
  });
25982
25995
  this.editor = editor;
25983
25996
  if (clientType.isMobile) {
@@ -25988,6 +26001,8 @@ var __publicField = (obj, key, value) => {
25988
26001
  }
25989
26002
  destroy() {
25990
26003
  document.removeEventListener("mousemove", this.handleDocumentMouseMove);
26004
+ document.removeEventListener("click", this.handleDocumentMouseMove);
26005
+ this.cancelPendingEvent();
25991
26006
  this.filters.forEach((filter) => filter.destroy());
25992
26007
  this.filters = [];
25993
26008
  this.finders.forEach((finder) => finder.destroy());
@@ -26015,6 +26030,30 @@ var __publicField = (obj, key, value) => {
26015
26030
  }
26016
26031
  return null;
26017
26032
  }
26033
+ cancelPendingEvent() {
26034
+ if (this.animationFrame !== null) {
26035
+ cancelAnimationFrame(this.animationFrame);
26036
+ this.animationFrame = null;
26037
+ }
26038
+ this.pendingEvent = null;
26039
+ }
26040
+ processMouseMove(event) {
26041
+ const elem = getElementFromPoint(event.x, event.y, { noFilter: true });
26042
+ if (!elem) {
26043
+ this.setHoveringBlock(null, event, null, elem);
26044
+ return;
26045
+ }
26046
+ let block = getParentBlock(elem);
26047
+ if (!block || !isChildNode(this.editor.rootContainer, block)) {
26048
+ block = this.findBlockByFinders(event);
26049
+ if (!block) {
26050
+ this.setHoveringBlock(null, event, null, elem);
26051
+ return;
26052
+ }
26053
+ }
26054
+ const child = this.getParentTextContentChild(block, elem);
26055
+ this.setHoveringBlock(block, event, child, elem);
26056
+ }
26018
26057
  setHoveringBlock(block, event, child, pointElem) {
26019
26058
  if (this.hoveringBlock === block && this.hoveringTextChild === child && this.hoveringElem === event.target) {
26020
26059
  return;
@@ -63189,7 +63228,7 @@ $$${mathData.mathjaxText}$$
63189
63228
  alignLeft: "\u5DE6\u63C3\u3048",
63190
63229
  alignRight: "\u53F3\u63C3\u3048",
63191
63230
  alignCenter: "\u4E2D\u592E\u63C3\u3048",
63192
- alignGroup: "\u5BF9\u9F50\u65B9\u5F0F",
63231
+ alignGroup: "\u6587\u5B57\u63C3\u3048",
63193
63232
  heading: "\u898B\u51FA\u3057{name}",
63194
63233
  headingGroup: "\u30BF\u30A4\u30C8\u30EB\u30B9\u30BF\u30A4\u30EB",
63195
63234
  text: "\u672C\u6587",
@@ -65896,6 +65935,9 @@ $$${mathData.mathjaxText}$$
65896
65935
  const BLOCK_HELPER_BUTTON_WIDTH = 40;
65897
65936
  const BLOCK_TOP_MARGIN = 20;
65898
65937
  class BlockHelperHoveringBlockFinder {
65938
+ isInScope(editor, event) {
65939
+ return event.target instanceof Node && editor.parent.contains(event.target);
65940
+ }
65899
65941
  findTargetBlock(editor, event) {
65900
65942
  const target = event.target;
65901
65943
  if (target && target instanceof Element) {
@@ -97530,7 +97572,7 @@ ${JSON.stringify(error2, null, 2)}`);
97530
97572
  }
97531
97573
  }
97532
97574
  });
97533
- editor.version = "5.0.3";
97575
+ editor.version = "5.0.4-beta.ONES22302091.1";
97534
97576
  return editor;
97535
97577
  }
97536
97578
  function isDoc(doc2) {
@@ -97666,7 +97708,7 @@ ${JSON.stringify(error2, null, 2)}`);
97666
97708
  OnesEditorDropTarget.register(editor);
97667
97709
  OnesEditorTocProvider.register(editor);
97668
97710
  OnesEditorExclusiveBlock.register(editor);
97669
- editor.version = "5.0.3";
97711
+ editor.version = "5.0.4-beta.ONES22302091.1";
97670
97712
  return editor;
97671
97713
  } catch (error2) {
97672
97714
  try {
@@ -97809,7 +97851,7 @@ ${JSON.stringify(error2, null, 2)}`);
97809
97851
  }
97810
97852
  }
97811
97853
  });
97812
- editor.version = "5.0.3";
97854
+ editor.version = "5.0.4-beta.ONES22302091.1";
97813
97855
  return editor;
97814
97856
  }
97815
97857
  const emojis$1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "5.0.3",
3
+ "version": "5.0.4-beta.ONES22302091.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {