@ones-editor/editor 4.0.4 → 4.0.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
  }
@@ -11884,6 +11892,94 @@ var __publicField = (obj, key, value) => {
11884
11892
  const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
11885
11893
  return ColorNames[colorIndex];
11886
11894
  }
11895
+ const renderers = /* @__PURE__ */ new WeakMap();
11896
+ const pendingEditors = /* @__PURE__ */ new WeakMap();
11897
+ function renderDeferredBlock(block) {
11898
+ var _a;
11899
+ (_a = renderers.get(block)) == null ? void 0 : _a();
11900
+ }
11901
+ class DeferredContents {
11902
+ constructor(editor) {
11903
+ __publicField(this, "pending", /* @__PURE__ */ new Map());
11904
+ __publicField(this, "owners", /* @__PURE__ */ new Map());
11905
+ __publicField(this, "observer");
11906
+ __publicField(this, "renderAll", () => {
11907
+ this.pending.forEach((ids, block) => renderDeferredBlock(block));
11908
+ });
11909
+ __publicField(this, "handleReadonlyChanged", () => {
11910
+ if (!this.editor.readonly)
11911
+ this.renderAll();
11912
+ });
11913
+ __publicField(this, "handleKeyDown", (event) => {
11914
+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "f")
11915
+ this.renderAll();
11916
+ });
11917
+ var _a;
11918
+ this.editor = editor;
11919
+ this.observer = new IntersectionObserver((entries) => {
11920
+ entries.forEach((entry) => {
11921
+ if (entry.isIntersecting)
11922
+ renderDeferredBlock(entry.target);
11923
+ });
11924
+ }, { root: (_a = editor.options.scrollContainer) != null ? _a : null, rootMargin: "1000px 0px" });
11925
+ editor.on("readonlyChanged", this.handleReadonlyChanged);
11926
+ window.addEventListener("beforeprint", this.renderAll);
11927
+ window.addEventListener("keydown", this.handleKeyDown, true);
11928
+ }
11929
+ add(block, ids, render) {
11930
+ this.pending.set(block, ids);
11931
+ ids.forEach((id) => this.owners.set(id, block));
11932
+ renderers.set(block, () => {
11933
+ this.remove(block);
11934
+ render();
11935
+ });
11936
+ block.setAttribute("data-deferred-content", "true");
11937
+ this.observer.observe(block);
11938
+ }
11939
+ remove(block) {
11940
+ var _a;
11941
+ (_a = this.pending.get(block)) == null ? void 0 : _a.forEach((id) => this.owners.delete(id));
11942
+ this.pending.delete(block);
11943
+ renderers.delete(block);
11944
+ block.removeAttribute("data-deferred-content");
11945
+ this.observer.unobserve(block);
11946
+ }
11947
+ renderId(id) {
11948
+ const block = this.owners.get(id);
11949
+ if (block)
11950
+ renderDeferredBlock(block);
11951
+ }
11952
+ destroy() {
11953
+ this.observer.disconnect();
11954
+ this.pending.forEach((ids, block) => renderers.delete(block));
11955
+ this.owners.clear();
11956
+ this.pending.clear();
11957
+ this.editor.off("readonlyChanged", this.handleReadonlyChanged);
11958
+ window.removeEventListener("beforeprint", this.renderAll);
11959
+ window.removeEventListener("keydown", this.handleKeyDown, true);
11960
+ pendingEditors.delete(this.editor);
11961
+ }
11962
+ }
11963
+ function deferBlockContent(editor, block, ids, render) {
11964
+ let pending = pendingEditors.get(editor);
11965
+ if (!pending) {
11966
+ pending = editor.addCustom("deferred-contents", () => new DeferredContents(editor));
11967
+ pendingEditors.set(editor, pending);
11968
+ }
11969
+ pending.add(block, ids, render);
11970
+ }
11971
+ function renderDeferredContents(editor) {
11972
+ var _a;
11973
+ (_a = pendingEditors.get(editor)) == null ? void 0 : _a.renderAll();
11974
+ }
11975
+ function removeDeferredBlock(editor, block) {
11976
+ var _a;
11977
+ (_a = pendingEditors.get(editor)) == null ? void 0 : _a.remove(block);
11978
+ }
11979
+ function renderDeferredId(editor, id) {
11980
+ var _a;
11981
+ (_a = pendingEditors.get(editor)) == null ? void 0 : _a.renderId(id);
11982
+ }
11887
11983
  const logger$4P = getLogger("container");
11888
11984
  function isContainer(elem) {
11889
11985
  return elem.getAttribute("data-type") === "editor-container";
@@ -11919,7 +12015,11 @@ var __publicField = (obj, key, value) => {
11919
12015
  return container;
11920
12016
  }
11921
12017
  function getContainerById(editor, containerId) {
11922
- const container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
12018
+ let container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
12019
+ if (!container) {
12020
+ renderDeferredId(editor, containerId);
12021
+ container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
12022
+ }
11923
12023
  assert(logger$4O, container, `no container: ${containerId}`);
11924
12024
  return container;
11925
12025
  }
@@ -26782,9 +26882,25 @@ var __publicField = (obj, key, value) => {
26782
26882
  }
26783
26883
  }
26784
26884
  }
26885
+ function allSelected(editor, range) {
26886
+ if (range.isCollapsed()) {
26887
+ return false;
26888
+ }
26889
+ const firstChildBlock = getFirstChildBlock(editor.rootContainer);
26890
+ const lastChildBlock = getLastChildBlock(editor.rootContainer);
26891
+ const { start, end } = range;
26892
+ return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
26893
+ }
26785
26894
  function updateSelectionBackground(editor) {
26786
26895
  clearAllSelection(editor);
26787
- editor.selection.range.getSelectedBlocks().forEach((s) => updateBlockSelection(editor, s.block, s.start, s.end));
26896
+ const { range } = editor.selection;
26897
+ const cssSelection = hasClass(editor.rootContainer, "select-all") && range.isSimple() && allSelected(editor, range);
26898
+ range.getSelectedBlocks().forEach((s) => {
26899
+ if (cssSelection && isTextKindBlock(editor, s.block) && !s.block.hasAttribute("data-document-title")) {
26900
+ return;
26901
+ }
26902
+ updateBlockSelection(editor, s.block, s.start, s.end);
26903
+ });
26788
26904
  }
26789
26905
  const logger$3T = getLogger("editor-dom");
26790
26906
  function editorGetClientHeight(editor) {
@@ -26933,15 +27049,6 @@ var __publicField = (obj, key, value) => {
26933
27049
  anchorElem.remove();
26934
27050
  }, 200);
26935
27051
  }
26936
- function allSelected(editor, range) {
26937
- if (range.isCollapsed()) {
26938
- return false;
26939
- }
26940
- const firstChildBlock = getFirstChildBlock(editor.rootContainer);
26941
- const lastChildBlock = getLastChildBlock(editor.rootContainer);
26942
- const { start, end } = range;
26943
- return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
26944
- }
26945
27052
  const logger$3S = getLogger("range-in-block");
26946
27053
  function rangeInBlock(block, range) {
26947
27054
  const editor = range.getEditor();
@@ -27708,14 +27815,14 @@ var __publicField = (obj, key, value) => {
27708
27815
  }
27709
27816
  function mergeDocs(docs) {
27710
27817
  const rootBlocks = [];
27711
- let childContainers = {};
27818
+ const childContainers = /* @__PURE__ */ Object.create(null);
27712
27819
  docs.forEach((doc2) => {
27713
27820
  rootBlocks.push(...doc2.blocks.root);
27714
- const { root: root2, ...subContainers } = doc2.blocks;
27715
- childContainers = {
27716
- ...childContainers,
27717
- ...subContainers
27718
- };
27821
+ Object.entries(doc2.blocks).forEach(([containerId, blocks]) => {
27822
+ if (containerId !== "root") {
27823
+ childContainers[containerId] = blocks;
27824
+ }
27825
+ });
27719
27826
  });
27720
27827
  return {
27721
27828
  blocks: {
@@ -29025,10 +29132,10 @@ var __publicField = (obj, key, value) => {
29025
29132
  doc2.blocks[childContainerId] = cloneDeep__default.default(childBlocks);
29026
29133
  });
29027
29134
  }
29028
- function selectedBlockToDoc(editor, selectedBlock) {
29135
+ function selectedBlockToDoc(editor, selectedBlock, getSourceDoc) {
29029
29136
  const blockClass = getBlockClass(editor, selectedBlock.block);
29030
29137
  if (blockClass.selectionToDoc) {
29031
- return blockClass.selectionToDoc(editor, selectedBlock);
29138
+ return blockClass.selectionToDoc(editor, selectedBlock, getSourceDoc);
29032
29139
  }
29033
29140
  const data2 = cloneDeep__default.default(editorGetBlockData(editor, selectedBlock.block));
29034
29141
  if (isTextKindBlock(editor, selectedBlock.block)) {
@@ -29095,7 +29202,12 @@ var __publicField = (obj, key, value) => {
29095
29202
  }
29096
29203
  function selectionToDoc$2(editor) {
29097
29204
  const selectedBlocks = editor.selection.range.getSelectedBlocks();
29098
- const docs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s));
29205
+ let sourceDoc;
29206
+ const getSourceDoc = () => {
29207
+ sourceDoc != null ? sourceDoc : sourceDoc = editor.doc.toJSON();
29208
+ return sourceDoc;
29209
+ };
29210
+ const docs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s, getSourceDoc));
29099
29211
  return mergeDocs(docs);
29100
29212
  }
29101
29213
  function containerToDoc(editor, containerId) {
@@ -32523,7 +32635,11 @@ ${codeText}
32523
32635
  return this.selection.getFocusedBlock();
32524
32636
  }
32525
32637
  findBlockById(id) {
32526
- const block = this.rootContainer.querySelector(`#${id}`);
32638
+ let block = this.rootContainer.querySelector(`#${id}`);
32639
+ if (!block) {
32640
+ renderDeferredId(this, id);
32641
+ block = this.rootContainer.querySelector(`#${id}`);
32642
+ }
32527
32643
  if (block) {
32528
32644
  assert(logger$3a, isBlock$1(block), "not an valid block element");
32529
32645
  }
@@ -41160,9 +41276,31 @@ ${codeText}
41160
41276
  class ChildBlockEventTracker extends tinyTypedEmitter.TypedEmitter {
41161
41277
  constructor(editor) {
41162
41278
  super();
41279
+ __publicField(this, "trackedListeners", /* @__PURE__ */ new Map());
41163
41280
  this.editor = editor;
41164
41281
  this.editor.doc.registerCallback(this);
41165
41282
  }
41283
+ track(callback) {
41284
+ var _a;
41285
+ const count = (_a = this.trackedListeners.get(callback)) != null ? _a : 0;
41286
+ this.trackedListeners.set(callback, count + 1);
41287
+ if (count === 0) {
41288
+ this.addListener("change", callback);
41289
+ this.addListener("insert", callback);
41290
+ }
41291
+ }
41292
+ untrack(callback) {
41293
+ const count = this.trackedListeners.get(callback);
41294
+ if (!count)
41295
+ return;
41296
+ if (count > 1) {
41297
+ this.trackedListeners.set(callback, count - 1);
41298
+ } else {
41299
+ this.trackedListeners.delete(callback);
41300
+ this.removeListener("change", callback);
41301
+ this.removeListener("insert", callback);
41302
+ }
41303
+ }
41166
41304
  handleChild(containerId, blockIndex, action) {
41167
41305
  if (isRootContainer(getContainerById(this.editor, containerId))) {
41168
41306
  return;
@@ -41190,6 +41328,8 @@ ${codeText}
41190
41328
  }
41191
41329
  destroy() {
41192
41330
  this.editor.doc.unregisterCallback(this);
41331
+ this.trackedListeners.clear();
41332
+ this.removeAllListeners();
41193
41333
  }
41194
41334
  }
41195
41335
  function trackChildBlockEvent(editor, callback) {
@@ -41197,16 +41337,14 @@ ${codeText}
41197
41337
  "child-block-tracker",
41198
41338
  () => new ChildBlockEventTracker(editor)
41199
41339
  );
41200
- handler.addListener("change", callback);
41201
- handler.addListener("insert", callback);
41340
+ handler.track(callback);
41202
41341
  }
41203
41342
  function untrackChildBlockEvent(editor, callback) {
41204
41343
  const handler = editor.addCustom(
41205
41344
  "child-block-tracker",
41206
41345
  () => new ChildBlockEventTracker(editor)
41207
41346
  );
41208
- handler.removeListener("change", callback);
41209
- handler.removeListener("insert", callback);
41347
+ handler.untrack(callback);
41210
41348
  }
41211
41349
  const style$e = "";
41212
41350
  const zhCN$x = {
@@ -45594,6 +45732,7 @@ ${codeText}
45594
45732
  return `${getBlockId(block)}_scroll`;
45595
45733
  }
45596
45734
  function getBlockTable(block) {
45735
+ renderDeferredBlock(block);
45597
45736
  const table = block.querySelector("div[data-type=table-content] >table");
45598
45737
  assert(logger$2D, table instanceof HTMLTableElement, "invalid table");
45599
45738
  return table;
@@ -48677,13 +48816,22 @@ ${codeText}
48677
48816
  class ContainerIntersectionObserver {
48678
48817
  constructor(scrollCore, callback) {
48679
48818
  __publicField(this, "intersectionObserver");
48819
+ __publicField(this, "intersecting", /* @__PURE__ */ new WeakSet());
48680
48820
  __publicField(this, "handleIntersection", (entries) => {
48681
48821
  entries.forEach((entry) => {
48682
48822
  const container = this.containers.get(getContainer(entry.target));
48683
48823
  if (container) {
48684
- this.handleIntersectionEntry(entry);
48824
+ if (entry.isIntersecting || this.intersecting.has(entry.target)) {
48825
+ this.handleIntersectionEntry(entry);
48826
+ }
48827
+ if (entry.isIntersecting) {
48828
+ this.intersecting.add(entry.target);
48829
+ } else {
48830
+ this.intersecting.delete(entry.target);
48831
+ }
48685
48832
  this.callback(entry);
48686
48833
  } else {
48834
+ this.intersecting.delete(entry.target);
48687
48835
  this.intersectionObserver.unobserve(entry.target);
48688
48836
  }
48689
48837
  });
@@ -48712,9 +48860,11 @@ ${codeText}
48712
48860
  this.intersectionObserver.observe(scrollContainer);
48713
48861
  }
48714
48862
  unbind(scrollContainer) {
48863
+ this.intersecting.delete(scrollContainer);
48715
48864
  this.intersectionObserver.unobserve(scrollContainer);
48716
48865
  }
48717
48866
  destroy() {
48867
+ this.intersecting = /* @__PURE__ */ new WeakSet();
48718
48868
  this.intersectionObserver.disconnect();
48719
48869
  }
48720
48870
  }
@@ -49053,11 +49203,17 @@ ${codeText}
49053
49203
  __publicField(this, "scrollWrapResizeObserve", null);
49054
49204
  __publicField(this, "locatingContainerResizeObserver", null);
49055
49205
  __publicField(this, "isWindowEventBind", false);
49206
+ __publicField(this, "boundContainers", /* @__PURE__ */ new WeakSet());
49056
49207
  __publicField(this, "containers", /* @__PURE__ */ new Map());
49208
+ __publicField(this, "containerCallbacks", /* @__PURE__ */ new Map());
49057
49209
  __publicField(this, "handleScrollContainerScroll", (scrollContainerElement) => {
49210
+ var _a;
49211
+ (_a = this.containerCallbacks.get(getContainer(scrollContainerElement))) == null ? void 0 : _a.scroll(this, scrollContainerElement);
49058
49212
  this.emit("scroll", this, scrollContainerElement);
49059
49213
  });
49060
49214
  __publicField(this, "handleResize", (scrollContainerElement) => {
49215
+ var _a;
49216
+ (_a = this.containerCallbacks.get(getContainer(scrollContainerElement))) == null ? void 0 : _a.resize(this, scrollContainerElement);
49061
49217
  this.emit("resize", this, scrollContainerElement);
49062
49218
  });
49063
49219
  __publicField(this, "handleIntersection", (entry) => {
@@ -49110,6 +49266,8 @@ ${codeText}
49110
49266
  }
49111
49267
  unbindCore(scrollContainer, scrollWrap) {
49112
49268
  var _a, _b, _c, _d, _e, _f;
49269
+ if (!this.boundContainers.delete(scrollContainer))
49270
+ return;
49113
49271
  const scrollbarContainer = getScrollbarContainer(scrollContainer);
49114
49272
  (_a = this.containerScrollObserver) == null ? void 0 : _a.unbindContentScroll(scrollContainer);
49115
49273
  (_b = this.containerScrollObserver) == null ? void 0 : _b.unbind(scrollbarContainer);
@@ -49134,8 +49292,11 @@ ${codeText}
49134
49292
  (_e = this.parentContainerScrollObserver) == null ? void 0 : _e.bindScrollContainer(scrollContainer);
49135
49293
  }
49136
49294
  (_f = this.locatingContainerResizeObserver) == null ? void 0 : _f.bind(scrollContainer);
49295
+ this.boundContainers.add(scrollContainer);
49137
49296
  }
49138
- bind(container, option) {
49297
+ bind(container, option, callbacks) {
49298
+ if (callbacks)
49299
+ this.containerCallbacks.set(container, callbacks);
49139
49300
  this.containers.set(container, option);
49140
49301
  const scrollContainer = container.firstElementChild;
49141
49302
  if (!this.containerIntersectionObserver) {
@@ -49149,6 +49310,7 @@ ${codeText}
49149
49310
  const scrollWrap = getContainerScrollArea(scrollContainer);
49150
49311
  this.unbindCore(scrollContainer, scrollWrap);
49151
49312
  this.containers.delete(container);
49313
+ this.containerCallbacks.delete(container);
49152
49314
  (_a = this.containerIntersectionObserver) == null ? void 0 : _a.unbind(scrollContainer);
49153
49315
  if (!this.containers.size) {
49154
49316
  this.destroy();
@@ -49197,9 +49359,10 @@ ${codeText}
49197
49359
  rootScrollMap.set(parentContainer, this.scrollListener);
49198
49360
  }
49199
49361
  this.scrollListener.unbind(container);
49200
- this.scrollListener.bind(container, options);
49201
- this.scrollListener.on("scroll", this.handleContainerScroll);
49202
- this.scrollListener.on("resize", this.handleResize);
49362
+ this.scrollListener.bind(container, options, {
49363
+ scroll: this.handleContainerScroll,
49364
+ resize: this.handleResize
49365
+ });
49203
49366
  this.scrollContainerElement = scrollContainerElement;
49204
49367
  });
49205
49368
  __publicField(this, "handleContainerScroll", (scrollListener, scrollContainerElement) => {
@@ -49228,8 +49391,6 @@ ${codeText}
49228
49391
  baseListener.destroy();
49229
49392
  }
49230
49393
  destroy() {
49231
- var _a;
49232
- (_a = this.scrollListener) == null ? void 0 : _a.off("scroll", this.handleContainerScroll);
49233
49394
  const container = getContainer(this.contentElement);
49234
49395
  if (container) {
49235
49396
  rootScrollMap.forEach((baseListener, parentContainer) => {
@@ -74825,6 +74986,7 @@ ${codeText}
74825
74986
  return table;
74826
74987
  }
74827
74988
  function createBlockContent$2(editor, path, container, blockElement, blockData) {
74989
+ var _a, _b;
74828
74990
  assert(logger$_, blockData.type === "table", "not table data");
74829
74991
  assert(logger$_, getContainerId(container) === path[path.length - 1].containerId, "invalid path");
74830
74992
  const tableData = blockData;
@@ -74832,9 +74994,40 @@ ${codeText}
74832
74994
  try {
74833
74995
  const tableContent = createElement("div", [], null);
74834
74996
  tableContent.setAttribute("data-type", "table-content");
74835
- const table = createTable(editor, path, tableData);
74836
- table.classList.add("drag-preview-element");
74837
- tableContent.appendChild(table);
74997
+ if (isRootContainer(container)) {
74998
+ addClass(tableContent, "deferred-table-content");
74999
+ }
75000
+ let placeholder2;
75001
+ const renderTable = () => {
75002
+ try {
75003
+ const table = createTable(editor, path, tableData);
75004
+ table.classList.add("drag-preview-element");
75005
+ tableContent.appendChild(table);
75006
+ } catch (err) {
75007
+ const message = `invalid table data: ${JSON.stringify(tableData)}`;
75008
+ logger$_.error(message);
75009
+ createElement("div", ["error"], tableContent).innerText = message;
75010
+ }
75011
+ placeholder2 == null ? void 0 : placeholder2.remove();
75012
+ tableContent.style.minHeight = "";
75013
+ };
75014
+ 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) => {
75015
+ var _a2;
75016
+ return block.type === "text" && !block.heading && !block.children && ((_a2 = block.text) == null ? void 0 : _a2.every((op) => {
75017
+ var _a3, _b2;
75018
+ return !((_a3 = op.attributes) == null ? void 0 : _a3.box) && !((_b2 = op.attributes) == null ? void 0 : _b2.insertion);
75019
+ }));
75020
+ }));
75021
+ if (defer) {
75022
+ tableContent.style.minHeight = "400px";
75023
+ placeholder2 = createElement("table", [], tableContent);
75024
+ placeholder2.style.minWidth = `${((_b = tableData.colsWidth) != null ? _b : []).reduce((sum, width) => sum + width, 0)}px`;
75025
+ placeholder2.setAttribute("aria-hidden", "true");
75026
+ const ids = tableData.children.flatMap((id) => [id, ...editor.doc.getContainerBlocks(id).map((block) => block.id)]);
75027
+ deferBlockContent(editor, blockElement, ids, renderTable);
75028
+ } else {
75029
+ renderTable();
75030
+ }
74838
75031
  const options = editor.getComponentOptions("table");
74839
75032
  if (!clientType.isMobile) {
74840
75033
  handleTableResizeMouseEvent(editor);
@@ -74847,15 +75040,16 @@ ${codeText}
74847
75040
  }
74848
75041
  trackChildBlockEvent(editor, handleChartDebounceUpdate);
74849
75042
  const scrollContainer = editor.addCustom(getTableScrollKey(blockElement), () => createScrollContainer());
74850
- const overflowY = window.getComputedStyle(container).overflowY;
75043
+ const rootContainer = isRootContainer(container);
75044
+ const overflowY = rootContainer ? "" : window.getComputedStyle(container).overflowY;
74851
75045
  const containerScrollable = overflowY === "auto" || overflowY === "scroll";
74852
75046
  scrollContainer.init({
74853
75047
  parentElement: content,
74854
75048
  childElement: tableContent,
74855
75049
  safeRightSpace: clientType.isMobile ? 20 : 50,
74856
75050
  safeLeftSpace: 40,
74857
- parentContainer: isRootContainer(container) || !containerScrollable ? editor.scrollContainer : container,
74858
- locatingContainer: isRootContainer(container) ? (options == null ? void 0 : options.locatingContainer) || editor.parent : container,
75051
+ parentContainer: rootContainer || !containerScrollable ? editor.scrollContainer : container,
75052
+ locatingContainer: rootContainer ? (options == null ? void 0 : options.locatingContainer) || editor.parent : container,
74859
75053
  paddingLeft: TABLE_BAR_WIDTH + INSERT_BUTTON_SIZE,
74860
75054
  paddingTop: TABLE_BAR_WIDTH + INSERT_BUTTON_SIZE,
74861
75055
  paddingBottom: INSERT_BUTTON_SIZE / 2,
@@ -74867,9 +75061,11 @@ ${codeText}
74867
75061
  const tableScrollEvents = handleTableScrollEvents(editor);
74868
75062
  scrollContainer.on("scroll", tableScrollEvents.handleReset);
74869
75063
  scrollContainer.on("resize", tableScrollEvents.handleReset);
74870
- setTimeout(() => {
74871
- handleChartUpdate(editor, blockElement);
74872
- });
75064
+ if (tableData.chart) {
75065
+ setTimeout(() => {
75066
+ handleChartUpdate(editor, blockElement);
75067
+ });
75068
+ }
74873
75069
  } catch (err) {
74874
75070
  const message = `invalid table data: ${JSON.stringify(tableData)}`;
74875
75071
  logger$_.error(message);
@@ -75024,13 +75220,14 @@ ${codeText}
75024
75220
  return acc;
75025
75221
  }, {});
75026
75222
  }
75027
- function selectionToDoc(editor, selectedBlock) {
75223
+ function selectionToDoc(editor, selectedBlock, getSourceDoc) {
75028
75224
  const { start, end, block } = selectedBlock;
75029
75225
  const blockType = getBlockType(block);
75030
75226
  assert(logger$Y, blockType === "table", `invalid block type: ${blockType}`);
75031
75227
  const blockData = editor.getBlockData(block);
75228
+ const oldDoc = getSourceDoc ? getSourceDoc() : editor.doc.toJSON();
75032
75229
  if (start.isSimple() && end.isSimple()) {
75033
- const doc2 = cloneBlock(editor.editorBlocks, editor.doc.toJSON(), blockData);
75230
+ const doc2 = cloneBlock(editor.editorBlocks, oldDoc, blockData);
75034
75231
  return doc2;
75035
75232
  }
75036
75233
  assert(logger$Y, !start.isSimple() && !end.isSimple(), "invalid block pos type");
@@ -75038,7 +75235,6 @@ ${codeText}
75038
75235
  const { fromCol, toCol, fromRow, toRow } = getTableSelectionRange(block, start, end);
75039
75236
  const spanData = {};
75040
75237
  const children = [];
75041
- const oldDoc = editor.doc.toJSON();
75042
75238
  let childContainers = {};
75043
75239
  const subGrid = grid.sub({ row: fromRow, col: fromCol }, { row: toRow, col: toCol });
75044
75240
  subGrid.forEach((row, rowIndex) => {
@@ -75692,13 +75888,14 @@ ${codeText}
75692
75888
  return new DOMRect(clientRect.left, clientRect.top + offset, clientRect.width, Math.max(clientRect.height - offset * 2, 0));
75693
75889
  }
75694
75890
  function handleDeleteBlock$4(editor, block) {
75891
+ removeDeferredBlock(editor, block);
75695
75892
  untrackChildBlockEvent(editor, handleChartDebounceUpdate);
75696
75893
  const scrollContent = editor.findCustom(getTableScrollKey(block));
75697
75894
  if (scrollContent) {
75698
75895
  const tableScrollEvents = handleTableScrollEvents(editor);
75699
75896
  scrollContent.off("scroll", tableScrollEvents.handleReset);
75700
75897
  scrollContent.off("resize", tableScrollEvents.handleReset);
75701
- scrollContent.destroy();
75898
+ editor.destroyCustom(getTableScrollKey(block));
75702
75899
  }
75703
75900
  }
75704
75901
  function getBlockProperties$9() {
@@ -79835,7 +80032,11 @@ ${docStr}
79835
80032
  const eleRect = firstChild.getBoundingClientRect();
79836
80033
  offsetTop = eleRect.y;
79837
80034
  }
79838
- scrollIntoView(editor, firstChild, { animation: true });
80035
+ if (editor.readonly) {
80036
+ firstChild.scrollIntoView({ block: "center", inline: "nearest" });
80037
+ } else {
80038
+ scrollIntoView(editor, firstChild, { animation: true });
80039
+ }
79839
80040
  }
79840
80041
  function getCurrentHighligh(editor) {
79841
80042
  const elem = editor.rootContainer.querySelector(".editor-highlight.active");
@@ -80102,6 +80303,7 @@ ${docStr}
80102
80303
  if (!find) {
80103
80304
  return;
80104
80305
  }
80306
+ renderDeferredContents(editor);
80105
80307
  const blocks = getAllChildBlocks(editor, {
80106
80308
  simpleBlockOnly: true,
80107
80309
  visibleOnly: true
@@ -80430,6 +80632,7 @@ ${docStr}
80430
80632
  this.components.statusContainer.style.display = "flex";
80431
80633
  }
80432
80634
  show(options) {
80635
+ this.editor.rootElement.classList.add("find-dialog-open");
80433
80636
  document.addEventListener("keydown", this.handleDocumentKeyDown);
80434
80637
  const text2 = this.editor.getSelectedText();
80435
80638
  if (text2.length > 0 && text2.length < 50) {
@@ -80482,6 +80685,7 @@ ${docStr}
80482
80685
  }
80483
80686
  hide() {
80484
80687
  var _a;
80688
+ this.editor.rootElement.classList.remove("find-dialog-open");
80485
80689
  (_a = this.dialog) == null ? void 0 : _a.close("cancelBar");
80486
80690
  clearAllHighlights(this.editor);
80487
80691
  document.removeEventListener("keydown", this.handleDocumentKeyDown);
@@ -80496,6 +80700,7 @@ ${docStr}
80496
80700
  }
80497
80701
  destroy() {
80498
80702
  var _a;
80703
+ this.editor.rootElement.classList.remove("find-dialog-open");
80499
80704
  (_a = this.dialog) == null ? void 0 : _a.destroy();
80500
80705
  }
80501
80706
  }
@@ -97342,7 +97547,7 @@ ${JSON.stringify(error2, null, 2)}`);
97342
97547
  }
97343
97548
  }
97344
97549
  });
97345
- editor.version = "4.0.4";
97550
+ editor.version = "4.0.5-beta.ONES22302330.1";
97346
97551
  return editor;
97347
97552
  }
97348
97553
  function isDoc(doc2) {
@@ -97478,7 +97683,7 @@ ${JSON.stringify(error2, null, 2)}`);
97478
97683
  OnesEditorDropTarget.register(editor);
97479
97684
  OnesEditorTocProvider.register(editor);
97480
97685
  OnesEditorExclusiveBlock.register(editor);
97481
- editor.version = "4.0.4";
97686
+ editor.version = "4.0.5-beta.ONES22302330.1";
97482
97687
  return editor;
97483
97688
  } catch (error2) {
97484
97689
  try {
@@ -97621,7 +97826,7 @@ ${JSON.stringify(error2, null, 2)}`);
97621
97826
  }
97622
97827
  }
97623
97828
  });
97624
- editor.version = "4.0.4";
97829
+ editor.version = "4.0.5-beta.ONES22302330.1";
97625
97830
  return editor;
97626
97831
  }
97627
97832
  const emojis$1 = {
@@ -143752,6 +143957,7 @@ ${JSON.stringify(error2, null, 2)}`);
143752
143957
  exports2.createTextWithReplaceSoftReturn = createTextWithReplaceSoftReturn;
143753
143958
  exports2.dataURLToBlob = dataURLToBlob;
143754
143959
  exports2.daysAfter = daysAfter;
143960
+ exports2.deferBlockContent = deferBlockContent;
143755
143961
  exports2.deleteColor = deleteColor;
143756
143962
  exports2.deleteText = deleteText;
143757
143963
  exports2.diffDays = diffDays;
@@ -144116,9 +144322,13 @@ ${JSON.stringify(error2, null, 2)}`);
144116
144322
  exports2.registerDragDrop = registerDragDrop;
144117
144323
  exports2.removeAttribute = removeAttribute;
144118
144324
  exports2.removeClass = removeClass;
144325
+ exports2.removeDeferredBlock = removeDeferredBlock;
144119
144326
  exports2.removeLastBr = removeLastBr;
144120
144327
  exports2.removePlaceholderFromBlock = removePlaceholderFromBlock;
144121
144328
  exports2.removeStyle = removeStyle;
144329
+ exports2.renderDeferredBlock = renderDeferredBlock;
144330
+ exports2.renderDeferredContents = renderDeferredContents;
144331
+ exports2.renderDeferredId = renderDeferredId;
144122
144332
  exports2.repairDuplicatedBlockIds = repairDuplicatedBlockIds;
144123
144333
  exports2.replaceAll = replaceAll$1;
144124
144334
  exports2.replaceAllCaseInsensitive = replaceAllCaseInsensitive;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "4.0.4",
3
+ "version": "4.0.5-beta.ONES22302330.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {