@ones-editor/editor 3.1.4 → 3.1.5-beta.ONES22302330.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
@@ -5276,6 +5276,14 @@ div[data-command-bar-id=table-row-column-toolbar] .tippy-box .tippy-content butt
5276
5276
  div[data-command-bar-id=table-cell-menu] .tippy-box .tippy-content .editor-command-bar.menu .command-item.selected[data-id=delete-select-row], div[data-command-bar-id=table-cell-menu] .tippy-box .tippy-content .editor-command-bar.menu .command-item.selected[data-id=delete-select-col] {
5277
5277
  color: #eb3723;
5278
5278
  background-color: #fff6f5;
5279
+ }
5280
+ @media screen {
5281
+ @supports (content-visibility: auto) and (contain-intrinsic-size: auto 400px) {
5282
+ .editor-root.readonly:not(.find-dialog-open) [data-type=table-content].deferred-table-content {
5283
+ content-visibility: auto;
5284
+ contain-intrinsic-size: auto 1000px auto 400px;
5285
+ }
5286
+ }
5279
5287
  }.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-anchor[data-id=paste-special-button-anchor] {
5280
5288
  z-index: unset;
5281
5289
  }
@@ -11852,6 +11860,94 @@ var __publicField = (obj, key, value) => {
11852
11860
  const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
11853
11861
  return ColorNames[colorIndex];
11854
11862
  }
11863
+ const renderers = /* @__PURE__ */ new WeakMap();
11864
+ const pendingEditors = /* @__PURE__ */ new WeakMap();
11865
+ function renderDeferredBlock(block) {
11866
+ var _a;
11867
+ (_a = renderers.get(block)) == null ? void 0 : _a();
11868
+ }
11869
+ class DeferredContents {
11870
+ constructor(editor) {
11871
+ __publicField(this, "pending", /* @__PURE__ */ new Map());
11872
+ __publicField(this, "owners", /* @__PURE__ */ new Map());
11873
+ __publicField(this, "observer");
11874
+ __publicField(this, "renderAll", () => {
11875
+ this.pending.forEach((ids, block) => renderDeferredBlock(block));
11876
+ });
11877
+ __publicField(this, "handleReadonlyChanged", () => {
11878
+ if (!this.editor.readonly)
11879
+ this.renderAll();
11880
+ });
11881
+ __publicField(this, "handleKeyDown", (event) => {
11882
+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "f")
11883
+ this.renderAll();
11884
+ });
11885
+ var _a;
11886
+ this.editor = editor;
11887
+ this.observer = new IntersectionObserver((entries) => {
11888
+ entries.forEach((entry) => {
11889
+ if (entry.isIntersecting)
11890
+ renderDeferredBlock(entry.target);
11891
+ });
11892
+ }, { root: (_a = editor.options.scrollContainer) != null ? _a : null, rootMargin: "1000px 0px" });
11893
+ editor.on("readonlyChanged", this.handleReadonlyChanged);
11894
+ window.addEventListener("beforeprint", this.renderAll);
11895
+ window.addEventListener("keydown", this.handleKeyDown, true);
11896
+ }
11897
+ add(block, ids, render) {
11898
+ this.pending.set(block, ids);
11899
+ ids.forEach((id) => this.owners.set(id, block));
11900
+ renderers.set(block, () => {
11901
+ this.remove(block);
11902
+ render();
11903
+ });
11904
+ block.setAttribute("data-deferred-content", "true");
11905
+ this.observer.observe(block);
11906
+ }
11907
+ remove(block) {
11908
+ var _a;
11909
+ (_a = this.pending.get(block)) == null ? void 0 : _a.forEach((id) => this.owners.delete(id));
11910
+ this.pending.delete(block);
11911
+ renderers.delete(block);
11912
+ block.removeAttribute("data-deferred-content");
11913
+ this.observer.unobserve(block);
11914
+ }
11915
+ renderId(id) {
11916
+ const block = this.owners.get(id);
11917
+ if (block)
11918
+ renderDeferredBlock(block);
11919
+ }
11920
+ destroy() {
11921
+ this.observer.disconnect();
11922
+ this.pending.forEach((ids, block) => renderers.delete(block));
11923
+ this.owners.clear();
11924
+ this.pending.clear();
11925
+ this.editor.off("readonlyChanged", this.handleReadonlyChanged);
11926
+ window.removeEventListener("beforeprint", this.renderAll);
11927
+ window.removeEventListener("keydown", this.handleKeyDown, true);
11928
+ pendingEditors.delete(this.editor);
11929
+ }
11930
+ }
11931
+ function deferBlockContent(editor, block, ids, render) {
11932
+ let pending = pendingEditors.get(editor);
11933
+ if (!pending) {
11934
+ pending = editor.addCustom("deferred-contents", () => new DeferredContents(editor));
11935
+ pendingEditors.set(editor, pending);
11936
+ }
11937
+ pending.add(block, ids, render);
11938
+ }
11939
+ function renderDeferredContents(editor) {
11940
+ var _a;
11941
+ (_a = pendingEditors.get(editor)) == null ? void 0 : _a.renderAll();
11942
+ }
11943
+ function removeDeferredBlock(editor, block) {
11944
+ var _a;
11945
+ (_a = pendingEditors.get(editor)) == null ? void 0 : _a.remove(block);
11946
+ }
11947
+ function renderDeferredId(editor, id) {
11948
+ var _a;
11949
+ (_a = pendingEditors.get(editor)) == null ? void 0 : _a.renderId(id);
11950
+ }
11855
11951
  const logger$4P = getLogger("container");
11856
11952
  function isContainer(elem) {
11857
11953
  return elem.getAttribute("data-type") === "editor-container";
@@ -11887,7 +11983,11 @@ var __publicField = (obj, key, value) => {
11887
11983
  return container;
11888
11984
  }
11889
11985
  function getContainerById(editor, containerId) {
11890
- const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
11986
+ let container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
11987
+ if (!container) {
11988
+ renderDeferredId(editor, containerId);
11989
+ container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
11990
+ }
11891
11991
  assert(logger$4O, container, `no container: ${containerId}`);
11892
11992
  return container;
11893
11993
  }
@@ -26711,9 +26811,25 @@ var __publicField = (obj, key, value) => {
26711
26811
  }
26712
26812
  }
26713
26813
  }
26814
+ function allSelected(editor, range) {
26815
+ if (range.isCollapsed()) {
26816
+ return false;
26817
+ }
26818
+ const firstChildBlock = getFirstChildBlock(editor.rootContainer);
26819
+ const lastChildBlock = getLastChildBlock(editor.rootContainer);
26820
+ const { start, end } = range;
26821
+ return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
26822
+ }
26714
26823
  function updateSelectionBackground(editor) {
26715
26824
  clearAllSelection(editor);
26716
- editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
26825
+ const { range } = editor.selection;
26826
+ const cssSelection = hasClass(editor.rootContainer, "select-all") && range.isSimple() && allSelected(editor, range);
26827
+ range.getSelectedBlocks().forEach((s) => {
26828
+ if (cssSelection && isTextKindBlock(editor, s.block) && !s.block.hasAttribute("data-document-title")) {
26829
+ return;
26830
+ }
26831
+ updateBlockSelection(editor, s.block, s.start, s.end);
26832
+ });
26717
26833
  }
26718
26834
  const logger$3T = getLogger("editor-dom");
26719
26835
  function editorGetClientHeight(editor) {
@@ -26862,15 +26978,6 @@ var __publicField = (obj, key, value) => {
26862
26978
  anchorElem.remove();
26863
26979
  }, 200);
26864
26980
  }
26865
- function allSelected(editor, range) {
26866
- if (range.isCollapsed()) {
26867
- return false;
26868
- }
26869
- const firstChildBlock = getFirstChildBlock(editor.rootContainer);
26870
- const lastChildBlock = getLastChildBlock(editor.rootContainer);
26871
- const { start, end } = range;
26872
- return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
26873
- }
26874
26981
  const logger$3S = getLogger("range-in-block");
26875
26982
  function rangeInBlock(block, range) {
26876
26983
  const editor = range.getEditor();
@@ -27637,14 +27744,14 @@ var __publicField = (obj, key, value) => {
27637
27744
  }
27638
27745
  function mergeDocs(docs) {
27639
27746
  const rootBlocks = [];
27640
- let childContainers = {};
27747
+ const childContainers = /* @__PURE__ */ Object.create(null);
27641
27748
  docs.forEach((doc2) => {
27642
27749
  rootBlocks.push(...doc2.blocks.root);
27643
- const { root: root2, ...subContainers } = doc2.blocks;
27644
- childContainers = {
27645
- ...childContainers,
27646
- ...subContainers
27647
- };
27750
+ Object.entries(doc2.blocks).forEach(([containerId, blocks]) => {
27751
+ if (containerId !== "root") {
27752
+ childContainers[containerId] = blocks;
27753
+ }
27754
+ });
27648
27755
  });
27649
27756
  return {
27650
27757
  blocks: {
@@ -28949,10 +29056,10 @@ var __publicField = (obj, key, value) => {
28949
29056
  doc2.blocks[childContainerId] = cloneDeep__default.default(childBlocks);
28950
29057
  });
28951
29058
  }
28952
- function selectedBlockToDoc(editor, selectedBlock) {
29059
+ function selectedBlockToDoc(editor, selectedBlock, getSourceDoc) {
28953
29060
  const blockClass = getBlockClass(editor, selectedBlock.block);
28954
29061
  if (blockClass.selectionToDoc) {
28955
- return blockClass.selectionToDoc(editor, selectedBlock);
29062
+ return blockClass.selectionToDoc(editor, selectedBlock, getSourceDoc);
28956
29063
  }
28957
29064
  const data2 = cloneDeep__default.default(editorGetBlockData(editor, selectedBlock.block));
28958
29065
  if (isTextKindBlock(editor, selectedBlock.block)) {
@@ -29019,7 +29126,12 @@ var __publicField = (obj, key, value) => {
29019
29126
  }
29020
29127
  function selectionToDoc$2(editor) {
29021
29128
  const selectedBlocks = editor.selection.range.getSelectedBlocks();
29022
- const docs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
29129
+ let sourceDoc;
29130
+ const getSourceDoc = () => {
29131
+ sourceDoc != null ? sourceDoc : sourceDoc = editor.doc.toJSON();
29132
+ return sourceDoc;
29133
+ };
29134
+ const docs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s, getSourceDoc));
29023
29135
  return mergeDocs(docs);
29024
29136
  }
29025
29137
  function containerToDoc(editor, containerId) {
@@ -32447,7 +32559,11 @@ ${codeText}
32447
32559
  return this.selection.getFocusedBlock();
32448
32560
  }
32449
32561
  findBlockById(id) {
32450
- const block = this.rootContainer.querySelector(`#${id}`);
32562
+ let block = this.rootContainer.querySelector(`#${id}`);
32563
+ if (!block) {
32564
+ renderDeferredId(this, id);
32565
+ block = this.rootContainer.querySelector(`#${id}`);
32566
+ }
32451
32567
  if (block) {
32452
32568
  assert(logger$3a, isBlock$1(block), "not an valid block element");
32453
32569
  }
@@ -41084,9 +41200,31 @@ ${codeText}
41084
41200
  class ChildBlockEventTracker extends tinyTypedEmitter.TypedEmitter {
41085
41201
  constructor(editor) {
41086
41202
  super();
41203
+ __publicField(this, "trackedListeners", /* @__PURE__ */ new Map());
41087
41204
  this.editor = editor;
41088
41205
  this.editor.doc.registerCallback(this);
41089
41206
  }
41207
+ track(callback) {
41208
+ var _a;
41209
+ const count = (_a = this.trackedListeners.get(callback)) != null ? _a : 0;
41210
+ this.trackedListeners.set(callback, count + 1);
41211
+ if (count === 0) {
41212
+ this.addListener("change", callback);
41213
+ this.addListener("insert", callback);
41214
+ }
41215
+ }
41216
+ untrack(callback) {
41217
+ const count = this.trackedListeners.get(callback);
41218
+ if (!count)
41219
+ return;
41220
+ if (count > 1) {
41221
+ this.trackedListeners.set(callback, count - 1);
41222
+ } else {
41223
+ this.trackedListeners.delete(callback);
41224
+ this.removeListener("change", callback);
41225
+ this.removeListener("insert", callback);
41226
+ }
41227
+ }
41090
41228
  handleChild(containerId, blockIndex, action) {
41091
41229
  if (isRootContainer(getContainerById(this.editor, containerId))) {
41092
41230
  return;
@@ -41114,6 +41252,8 @@ ${codeText}
41114
41252
  }
41115
41253
  destroy() {
41116
41254
  this.editor.doc.unregisterCallback(this);
41255
+ this.trackedListeners.clear();
41256
+ this.removeAllListeners();
41117
41257
  }
41118
41258
  }
41119
41259
  function trackChildBlockEvent(editor, callback) {
@@ -41121,16 +41261,14 @@ ${codeText}
41121
41261
  "child-block-tracker",
41122
41262
  () => new ChildBlockEventTracker(editor)
41123
41263
  );
41124
- handler.addListener("change", callback);
41125
- handler.addListener("insert", callback);
41264
+ handler.track(callback);
41126
41265
  }
41127
41266
  function untrackChildBlockEvent(editor, callback) {
41128
41267
  const handler = editor.addCustom(
41129
41268
  "child-block-tracker",
41130
41269
  () => new ChildBlockEventTracker(editor)
41131
41270
  );
41132
- handler.removeListener("change", callback);
41133
- handler.removeListener("insert", callback);
41271
+ handler.untrack(callback);
41134
41272
  }
41135
41273
  const style$e = "";
41136
41274
  const zhCN$x = {
@@ -45510,6 +45648,7 @@ ${codeText}
45510
45648
  return `${getBlockId(block)}_scroll`;
45511
45649
  }
45512
45650
  function getBlockTable(block) {
45651
+ renderDeferredBlock(block);
45513
45652
  const table = block.querySelector("div[data-type=table-content] >table");
45514
45653
  assert(logger$2D, table instanceof HTMLTableElement, "invalid table");
45515
45654
  return table;
@@ -48593,13 +48732,22 @@ ${codeText}
48593
48732
  class ContainerIntersectionObserver {
48594
48733
  constructor(scrollCore, callback) {
48595
48734
  __publicField(this, "intersectionObserver");
48735
+ __publicField(this, "intersecting", /* @__PURE__ */ new WeakSet());
48596
48736
  __publicField(this, "handleIntersection", (entries) => {
48597
48737
  entries.forEach((entry) => {
48598
48738
  const container = this.containers.get(getContainer(entry.target));
48599
48739
  if (container) {
48600
- this.handleIntersectionEntry(entry);
48740
+ if (entry.isIntersecting || this.intersecting.has(entry.target)) {
48741
+ this.handleIntersectionEntry(entry);
48742
+ }
48743
+ if (entry.isIntersecting) {
48744
+ this.intersecting.add(entry.target);
48745
+ } else {
48746
+ this.intersecting.delete(entry.target);
48747
+ }
48601
48748
  this.callback(entry);
48602
48749
  } else {
48750
+ this.intersecting.delete(entry.target);
48603
48751
  this.intersectionObserver.unobserve(entry.target);
48604
48752
  }
48605
48753
  });
@@ -48628,9 +48776,11 @@ ${codeText}
48628
48776
  this.intersectionObserver.observe(scrollContainer);
48629
48777
  }
48630
48778
  unbind(scrollContainer) {
48779
+ this.intersecting.delete(scrollContainer);
48631
48780
  this.intersectionObserver.unobserve(scrollContainer);
48632
48781
  }
48633
48782
  destroy() {
48783
+ this.intersecting = /* @__PURE__ */ new WeakSet();
48634
48784
  this.intersectionObserver.disconnect();
48635
48785
  }
48636
48786
  }
@@ -48969,11 +49119,17 @@ ${codeText}
48969
49119
  __publicField(this, "scrollWrapResizeObserve", null);
48970
49120
  __publicField(this, "locatingContainerResizeObserver", null);
48971
49121
  __publicField(this, "isWindowEventBind", false);
49122
+ __publicField(this, "boundContainers", /* @__PURE__ */ new WeakSet());
48972
49123
  __publicField(this, "containers", /* @__PURE__ */ new Map());
49124
+ __publicField(this, "containerCallbacks", /* @__PURE__ */ new Map());
48973
49125
  __publicField(this, "handleScrollContainerScroll", (scrollContainerElement) => {
49126
+ var _a;
49127
+ (_a = this.containerCallbacks.get(getContainer(scrollContainerElement))) == null ? void 0 : _a.scroll(this, scrollContainerElement);
48974
49128
  this.emit("scroll", this, scrollContainerElement);
48975
49129
  });
48976
49130
  __publicField(this, "handleResize", (scrollContainerElement) => {
49131
+ var _a;
49132
+ (_a = this.containerCallbacks.get(getContainer(scrollContainerElement))) == null ? void 0 : _a.resize(this, scrollContainerElement);
48977
49133
  this.emit("resize", this, scrollContainerElement);
48978
49134
  });
48979
49135
  __publicField(this, "handleIntersection", (entry) => {
@@ -49026,6 +49182,8 @@ ${codeText}
49026
49182
  }
49027
49183
  unbindCore(scrollContainer, scrollWrap) {
49028
49184
  var _a, _b, _c, _d, _e, _f;
49185
+ if (!this.boundContainers.delete(scrollContainer))
49186
+ return;
49029
49187
  const scrollbarContainer = getScrollbarContainer(scrollContainer);
49030
49188
  (_a = this.containerScrollObserver) == null ? void 0 : _a.unbindContentScroll(scrollContainer);
49031
49189
  (_b = this.containerScrollObserver) == null ? void 0 : _b.unbind(scrollbarContainer);
@@ -49050,8 +49208,11 @@ ${codeText}
49050
49208
  (_e = this.parentContainerScrollObserver) == null ? void 0 : _e.bindScrollContainer(scrollContainer);
49051
49209
  }
49052
49210
  (_f = this.locatingContainerResizeObserver) == null ? void 0 : _f.bind(scrollContainer);
49211
+ this.boundContainers.add(scrollContainer);
49053
49212
  }
49054
- bind(container, option) {
49213
+ bind(container, option, callbacks) {
49214
+ if (callbacks)
49215
+ this.containerCallbacks.set(container, callbacks);
49055
49216
  this.containers.set(container, option);
49056
49217
  const scrollContainer = container.firstElementChild;
49057
49218
  if (!this.containerIntersectionObserver) {
@@ -49065,6 +49226,7 @@ ${codeText}
49065
49226
  const scrollWrap = getContainerScrollArea(scrollContainer);
49066
49227
  this.unbindCore(scrollContainer, scrollWrap);
49067
49228
  this.containers.delete(container);
49229
+ this.containerCallbacks.delete(container);
49068
49230
  (_a = this.containerIntersectionObserver) == null ? void 0 : _a.unbind(scrollContainer);
49069
49231
  if (!this.containers.size) {
49070
49232
  this.destroy();
@@ -49113,9 +49275,10 @@ ${codeText}
49113
49275
  rootScrollMap.set(parentContainer, this.scrollListener);
49114
49276
  }
49115
49277
  this.scrollListener.unbind(container);
49116
- this.scrollListener.bind(container, options);
49117
- this.scrollListener.on("scroll", this.handleContainerScroll);
49118
- this.scrollListener.on("resize", this.handleResize);
49278
+ this.scrollListener.bind(container, options, {
49279
+ scroll: this.handleContainerScroll,
49280
+ resize: this.handleResize
49281
+ });
49119
49282
  this.scrollContainerElement = scrollContainerElement;
49120
49283
  });
49121
49284
  __publicField(this, "handleContainerScroll", (scrollListener, scrollContainerElement) => {
@@ -49144,8 +49307,6 @@ ${codeText}
49144
49307
  baseListener.destroy();
49145
49308
  }
49146
49309
  destroy() {
49147
- var _a;
49148
- (_a = this.scrollListener) == null ? void 0 : _a.off("scroll", this.handleContainerScroll);
49149
49310
  const container = getContainer(this.contentElement);
49150
49311
  if (container) {
49151
49312
  rootScrollMap.forEach((baseListener, parentContainer) => {
@@ -74718,6 +74879,7 @@ ${codeText}
74718
74879
  return table;
74719
74880
  }
74720
74881
  function createBlockContent$2(editor, path, container, blockElement, blockData) {
74882
+ var _a, _b;
74721
74883
  assert(logger$_, blockData.type === "table", "not table data");
74722
74884
  assert(logger$_, getContainerId(container) === path[path.length - 1].containerId, "invalid path");
74723
74885
  const tableData = blockData;
@@ -74725,9 +74887,40 @@ ${codeText}
74725
74887
  try {
74726
74888
  const tableContent = createElement("div", [], null);
74727
74889
  tableContent.setAttribute("data-type", "table-content");
74728
- const table = createTable(editor, path, tableData);
74729
- table.classList.add("drag-preview-element");
74730
- tableContent.appendChild(table);
74890
+ if (isRootContainer(container)) {
74891
+ addClass(tableContent, "deferred-table-content");
74892
+ }
74893
+ let placeholder2;
74894
+ const renderTable = () => {
74895
+ try {
74896
+ const table = createTable(editor, path, tableData);
74897
+ table.classList.add("drag-preview-element");
74898
+ tableContent.appendChild(table);
74899
+ } catch (err) {
74900
+ const message = `invalid table data: ${JSON.stringify(tableData)}`;
74901
+ logger$_.error(message);
74902
+ createElement("div", ["error"], tableContent).innerText = message;
74903
+ }
74904
+ placeholder2 == null ? void 0 : placeholder2.remove();
74905
+ tableContent.style.minHeight = "";
74906
+ };
74907
+ const defer = editor.readonly && isRootContainer(container) && path[0].blockIndex >= 10 && !tableData.chart && ((_a = tableData.colsWidth) == null ? void 0 : _a.length) === tableData.cols && tableData.colsWidth.every((width) => width > 0) && typeof IntersectionObserver !== "undefined" && editor.doc.getContainerBlocks("root").length >= 200 && tableData.children.every((id) => editor.doc.getContainerBlocks(id).every((block) => {
74908
+ var _a2;
74909
+ return block.type === "text" && !block.heading && !block.children && ((_a2 = block.text) == null ? void 0 : _a2.every((op) => {
74910
+ var _a3, _b2;
74911
+ return !((_a3 = op.attributes) == null ? void 0 : _a3.box) && !((_b2 = op.attributes) == null ? void 0 : _b2.insertion);
74912
+ }));
74913
+ }));
74914
+ if (defer) {
74915
+ tableContent.style.minHeight = "400px";
74916
+ placeholder2 = createElement("table", [], tableContent);
74917
+ placeholder2.style.minWidth = `${((_b = tableData.colsWidth) != null ? _b : []).reduce((sum, width) => sum + width, 0)}px`;
74918
+ placeholder2.setAttribute("aria-hidden", "true");
74919
+ const ids = tableData.children.flatMap((id) => [id, ...editor.doc.getContainerBlocks(id).map((block) => block.id)]);
74920
+ deferBlockContent(editor, blockElement, ids, renderTable);
74921
+ } else {
74922
+ renderTable();
74923
+ }
74731
74924
  const options = editor.getComponentOptions("table");
74732
74925
  if (!clientType.isMobile) {
74733
74926
  handleTableResizeMouseEvent(editor);
@@ -74740,15 +74933,16 @@ ${codeText}
74740
74933
  }
74741
74934
  trackChildBlockEvent(editor, handleChartDebounceUpdate);
74742
74935
  const scrollContainer = editor.addCustom(getTableScrollKey(blockElement), () => createScrollContainer());
74743
- const overflowY = window.getComputedStyle(container).overflowY;
74936
+ const rootContainer = isRootContainer(container);
74937
+ const overflowY = rootContainer ? "" : window.getComputedStyle(container).overflowY;
74744
74938
  const containerScrollable = overflowY === "auto" || overflowY === "scroll";
74745
74939
  scrollContainer.init({
74746
74940
  parentElement: content,
74747
74941
  childElement: tableContent,
74748
74942
  safeRightSpace: clientType.isMobile ? 20 : 50,
74749
74943
  safeLeftSpace: 40,
74750
- parentContainer: isRootContainer(container) || !containerScrollable ? editor.scrollContainer : container,
74751
- locatingContainer: isRootContainer(container) ? (options == null ? void 0 : options.locatingContainer) || editor.parent : container,
74944
+ parentContainer: rootContainer || !containerScrollable ? editor.scrollContainer : container,
74945
+ locatingContainer: rootContainer ? (options == null ? void 0 : options.locatingContainer) || editor.parent : container,
74752
74946
  paddingLeft: TABLE_BAR_WIDTH + INSERT_BUTTON_SIZE,
74753
74947
  paddingTop: TABLE_BAR_WIDTH + INSERT_BUTTON_SIZE,
74754
74948
  paddingBottom: INSERT_BUTTON_SIZE / 2,
@@ -74760,9 +74954,11 @@ ${codeText}
74760
74954
  const tableScrollEvents = handleTableScrollEvents(editor);
74761
74955
  scrollContainer.on("scroll", tableScrollEvents.handleReset);
74762
74956
  scrollContainer.on("resize", tableScrollEvents.handleReset);
74763
- setTimeout(() => {
74764
- handleChartUpdate(editor, blockElement);
74765
- });
74957
+ if (tableData.chart) {
74958
+ setTimeout(() => {
74959
+ handleChartUpdate(editor, blockElement);
74960
+ });
74961
+ }
74766
74962
  } catch (err) {
74767
74963
  const message = `invalid table data: ${JSON.stringify(tableData)}`;
74768
74964
  logger$_.error(message);
@@ -74917,13 +75113,14 @@ ${codeText}
74917
75113
  return acc;
74918
75114
  }, {});
74919
75115
  }
74920
- function selectionToDoc(editor, selectedBlock) {
75116
+ function selectionToDoc(editor, selectedBlock, getSourceDoc) {
74921
75117
  const { start, end, block } = selectedBlock;
74922
75118
  const blockType = getBlockType(block);
74923
75119
  assert(logger$Y, blockType === "table", `invalid block type: ${blockType}`);
74924
75120
  const blockData = editor.getBlockData(block);
75121
+ const oldDoc = getSourceDoc ? getSourceDoc() : editor.doc.toJSON();
74925
75122
  if (start.isSimple() && end.isSimple()) {
74926
- const doc2 = cloneBlock(editor.editorBlocks, editor.doc.toJSON(), blockData);
75123
+ const doc2 = cloneBlock(editor.editorBlocks, oldDoc, blockData);
74927
75124
  return doc2;
74928
75125
  }
74929
75126
  assert(logger$Y, !start.isSimple() && !end.isSimple(), "invalid block pos type");
@@ -74931,7 +75128,6 @@ ${codeText}
74931
75128
  const { fromCol, toCol, fromRow, toRow } = getTableSelectionRange(block, start, end);
74932
75129
  const spanData = {};
74933
75130
  const children = [];
74934
- const oldDoc = editor.doc.toJSON();
74935
75131
  let childContainers = {};
74936
75132
  const subGrid = grid.sub({ row: fromRow, col: fromCol }, { row: toRow, col: toCol });
74937
75133
  subGrid.forEach((row, rowIndex) => {
@@ -75585,13 +75781,14 @@ ${codeText}
75585
75781
  return new DOMRect(clientRect.left, clientRect.top + offset, clientRect.width, Math.max(clientRect.height - offset * 2, 0));
75586
75782
  }
75587
75783
  function handleDeleteBlock$4(editor, block) {
75784
+ removeDeferredBlock(editor, block);
75588
75785
  untrackChildBlockEvent(editor, handleChartDebounceUpdate);
75589
75786
  const scrollContent = editor.findCustom(getTableScrollKey(block));
75590
75787
  if (scrollContent) {
75591
75788
  const tableScrollEvents = handleTableScrollEvents(editor);
75592
75789
  scrollContent.off("scroll", tableScrollEvents.handleReset);
75593
75790
  scrollContent.off("resize", tableScrollEvents.handleReset);
75594
- scrollContent.destroy();
75791
+ editor.destroyCustom(getTableScrollKey(block));
75595
75792
  }
75596
75793
  }
75597
75794
  function getBlockProperties$9() {
@@ -79715,7 +79912,11 @@ ${docStr}
79715
79912
  const eleRect = firstChild.getBoundingClientRect();
79716
79913
  offsetTop = eleRect.y;
79717
79914
  }
79718
- scrollIntoView(editor, firstChild, { animation: true });
79915
+ if (editor.readonly) {
79916
+ firstChild.scrollIntoView({ block: "center", inline: "nearest" });
79917
+ } else {
79918
+ scrollIntoView(editor, firstChild, { animation: true });
79919
+ }
79719
79920
  }
79720
79921
  function getCurrentHighligh(editor) {
79721
79922
  const elem = editor.rootContainer.querySelector(".editor-highlight.active");
@@ -79982,6 +80183,7 @@ ${docStr}
79982
80183
  if (!find) {
79983
80184
  return;
79984
80185
  }
80186
+ renderDeferredContents(editor);
79985
80187
  const blocks = getAllChildBlocks(editor, {
79986
80188
  simpleBlockOnly: true,
79987
80189
  visibleOnly: true
@@ -80310,6 +80512,7 @@ ${docStr}
80310
80512
  this.components.statusContainer.style.display = "flex";
80311
80513
  }
80312
80514
  show(options) {
80515
+ this.editor.rootElement.classList.add("find-dialog-open");
80313
80516
  document.addEventListener("keydown", this.handleDocumentKeyDown);
80314
80517
  const text2 = this.editor.getSelectedText();
80315
80518
  if (text2.length > 0 && text2.length < 50) {
@@ -80362,6 +80565,7 @@ ${docStr}
80362
80565
  }
80363
80566
  hide() {
80364
80567
  var _a;
80568
+ this.editor.rootElement.classList.remove("find-dialog-open");
80365
80569
  (_a = this.dialog) == null ? void 0 : _a.close("cancelBar");
80366
80570
  clearAllHighlights(this.editor);
80367
80571
  document.removeEventListener("keydown", this.handleDocumentKeyDown);
@@ -80376,6 +80580,7 @@ ${docStr}
80376
80580
  }
80377
80581
  destroy() {
80378
80582
  var _a;
80583
+ this.editor.rootElement.classList.remove("find-dialog-open");
80379
80584
  (_a = this.dialog) == null ? void 0 : _a.destroy();
80380
80585
  }
80381
80586
  }
@@ -97197,7 +97402,7 @@ ${JSON.stringify(error2, null, 2)}`);
97197
97402
  }
97198
97403
  }
97199
97404
  });
97200
- editor.version = "3.1.4";
97405
+ editor.version = "3.1.5-beta.ONES22302330.1";
97201
97406
  return editor;
97202
97407
  }
97203
97408
  function isDoc(doc2) {
@@ -97338,7 +97543,7 @@ ${JSON.stringify(error2, null, 2)}`);
97338
97543
  OnesEditorDropTarget.register(editor);
97339
97544
  OnesEditorTocProvider.register(editor);
97340
97545
  OnesEditorExclusiveBlock.register(editor);
97341
- editor.version = "3.1.4";
97546
+ editor.version = "3.1.5-beta.ONES22302330.1";
97342
97547
  return editor;
97343
97548
  } catch (error2) {
97344
97549
  if (editorForCleanup) {
@@ -143542,6 +143747,7 @@ ${JSON.stringify(error2, null, 2)}`);
143542
143747
  exports2.createTextWithReplaceSoftReturn = createTextWithReplaceSoftReturn;
143543
143748
  exports2.dataURLToBlob = dataURLToBlob;
143544
143749
  exports2.daysAfter = daysAfter;
143750
+ exports2.deferBlockContent = deferBlockContent;
143545
143751
  exports2.deleteColor = deleteColor;
143546
143752
  exports2.deleteText = deleteText;
143547
143753
  exports2.diffDays = diffDays;
@@ -143905,9 +144111,13 @@ ${JSON.stringify(error2, null, 2)}`);
143905
144111
  exports2.registerDragDrop = registerDragDrop;
143906
144112
  exports2.removeAttribute = removeAttribute;
143907
144113
  exports2.removeClass = removeClass;
144114
+ exports2.removeDeferredBlock = removeDeferredBlock;
143908
144115
  exports2.removeLastBr = removeLastBr;
143909
144116
  exports2.removePlaceholderFromBlock = removePlaceholderFromBlock;
143910
144117
  exports2.removeStyle = removeStyle;
144118
+ exports2.renderDeferredBlock = renderDeferredBlock;
144119
+ exports2.renderDeferredContents = renderDeferredContents;
144120
+ exports2.renderDeferredId = renderDeferredId;
143911
144121
  exports2.repairDuplicatedBlockIds = repairDuplicatedBlockIds;
143912
144122
  exports2.replaceAll = replaceAll$1;
143913
144123
  exports2.replaceAllCaseInsensitive = replaceAllCaseInsensitive;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "3.1.4",
3
+ "version": "3.1.5-beta.ONES22302330.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {