@ones-editor/editor 4.0.3 → 4.0.4-beta.ONES22301801.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
@@ -25951,29 +25951,42 @@ var __publicField = (obj, key, value) => {
25951
25951
  __publicField(this, "hoveringTextChild", null);
25952
25952
  __publicField(this, "filters", []);
25953
25953
  __publicField(this, "finders", []);
25954
+ __publicField(this, "pendingEvent", null);
25955
+ __publicField(this, "animationFrame", null);
25954
25956
  __publicField(this, "handleDocumentMouseMove", (event) => {
25955
25957
  if (this.hoveringBlock) {
25956
25958
  for (const filter of this.filters) {
25957
25959
  if (filter.isInBlock(this.hoveringBlock, event)) {
25960
+ this.cancelPendingEvent();
25958
25961
  return;
25959
25962
  }
25960
25963
  }
25961
25964
  }
25962
- const elem = getElementFromPoint(event.x, event.y, { noFilter: true });
25963
- if (!elem) {
25964
- this.setHoveringBlock(null, event, null, elem);
25965
+ const inEditor = event.target instanceof Node && this.editor.rootElement.contains(event.target);
25966
+ const inFinder = !inEditor && this.finders.some((finder) => !finder.isInScope || finder.isInScope(this.editor, event));
25967
+ if (!inEditor && !inFinder) {
25968
+ this.cancelPendingEvent();
25969
+ if (this.hoveringBlock || this.hoveringTextChild || this.hoveringElem) {
25970
+ this.setHoveringBlock(null, event, null, null);
25971
+ }
25965
25972
  return;
25966
25973
  }
25967
- let block = getParentBlock(elem);
25968
- if (!block || !isChildNode(this.editor.rootContainer, block)) {
25969
- block = this.findBlockByFinders(event);
25970
- if (!block) {
25971
- this.setHoveringBlock(null, event, null, elem);
25972
- return;
25973
- }
25974
+ if (event.type === "click") {
25975
+ this.processMouseMove(event);
25976
+ return;
25977
+ }
25978
+ this.pendingEvent = event;
25979
+ if (this.animationFrame === null) {
25980
+ this.animationFrame = requestAnimationFrame(this.flushPendingEvent);
25981
+ }
25982
+ });
25983
+ __publicField(this, "flushPendingEvent", () => {
25984
+ this.animationFrame = null;
25985
+ const event = this.pendingEvent;
25986
+ this.pendingEvent = null;
25987
+ if (event) {
25988
+ this.processMouseMove(event);
25974
25989
  }
25975
- const child = this.getParentTextContentChild(block, elem);
25976
- this.setHoveringBlock(block, event, child, elem);
25977
25990
  });
25978
25991
  this.editor = editor;
25979
25992
  if (clientType.isMobile) {
@@ -25984,6 +25997,8 @@ var __publicField = (obj, key, value) => {
25984
25997
  }
25985
25998
  destroy() {
25986
25999
  document.removeEventListener("mousemove", this.handleDocumentMouseMove);
26000
+ document.removeEventListener("click", this.handleDocumentMouseMove);
26001
+ this.cancelPendingEvent();
25987
26002
  this.filters.forEach((filter) => filter.destroy());
25988
26003
  this.filters = [];
25989
26004
  this.finders.forEach((finder) => finder.destroy());
@@ -26011,6 +26026,30 @@ var __publicField = (obj, key, value) => {
26011
26026
  }
26012
26027
  return null;
26013
26028
  }
26029
+ cancelPendingEvent() {
26030
+ if (this.animationFrame !== null) {
26031
+ cancelAnimationFrame(this.animationFrame);
26032
+ this.animationFrame = null;
26033
+ }
26034
+ this.pendingEvent = null;
26035
+ }
26036
+ processMouseMove(event) {
26037
+ const elem = getElementFromPoint(event.x, event.y, { noFilter: true });
26038
+ if (!elem) {
26039
+ this.setHoveringBlock(null, event, null, elem);
26040
+ return;
26041
+ }
26042
+ let block = getParentBlock(elem);
26043
+ if (!block || !isChildNode(this.editor.rootContainer, block)) {
26044
+ block = this.findBlockByFinders(event);
26045
+ if (!block) {
26046
+ this.setHoveringBlock(null, event, null, elem);
26047
+ return;
26048
+ }
26049
+ }
26050
+ const child = this.getParentTextContentChild(block, elem);
26051
+ this.setHoveringBlock(block, event, child, elem);
26052
+ }
26014
26053
  setHoveringBlock(block, event, child, pointElem) {
26015
26054
  if (this.hoveringBlock === block && this.hoveringTextChild === child && this.hoveringElem === event.target) {
26016
26055
  return;
@@ -65868,6 +65907,9 @@ $$${mathData.mathjaxText}$$
65868
65907
  const BLOCK_HELPER_BUTTON_WIDTH = 40;
65869
65908
  const BLOCK_TOP_MARGIN = 20;
65870
65909
  class BlockHelperHoveringBlockFinder {
65910
+ isInScope(editor, event) {
65911
+ return event.target instanceof Node && editor.parent.contains(event.target);
65912
+ }
65871
65913
  findTargetBlock(editor, event) {
65872
65914
  const target = event.target;
65873
65915
  if (target && target instanceof Element) {
@@ -97211,7 +97253,7 @@ ${JSON.stringify(error2, null, 2)}`);
97211
97253
  }
97212
97254
  }
97213
97255
  });
97214
- editor.version = "4.0.3";
97256
+ editor.version = "4.0.4-beta.ONES22301801.1";
97215
97257
  return editor;
97216
97258
  }
97217
97259
  function isDoc(doc2) {
@@ -97347,7 +97389,7 @@ ${JSON.stringify(error2, null, 2)}`);
97347
97389
  OnesEditorDropTarget.register(editor);
97348
97390
  OnesEditorTocProvider.register(editor);
97349
97391
  OnesEditorExclusiveBlock.register(editor);
97350
- editor.version = "4.0.3";
97392
+ editor.version = "4.0.4-beta.ONES22301801.1";
97351
97393
  return editor;
97352
97394
  } catch (error2) {
97353
97395
  try {
@@ -97490,7 +97532,7 @@ ${JSON.stringify(error2, null, 2)}`);
97490
97532
  }
97491
97533
  }
97492
97534
  });
97493
- editor.version = "4.0.3";
97535
+ editor.version = "4.0.4-beta.ONES22301801.1";
97494
97536
  return editor;
97495
97537
  }
97496
97538
  const emojis$1 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "4.0.3",
3
+ "version": "4.0.4-beta.ONES22301801.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {