@ones-editor/editor 5.0.4 → 5.0.5-beta.ONES22302330.2
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/@ones-editor/child-block-tracker/src/event-tracker.d.ts +4 -0
- package/@ones-editor/child-block-tracker/src/index.d.ts +4 -3
- package/@ones-editor/core/src/core/converter/selected-block-to-doc.d.ts +1 -1
- package/@ones-editor/core/src/core/selection/selection-background.d.ts +1 -1
- package/@ones-editor/core/src/core/types.d.ts +1 -1
- package/@ones-editor/core/src/helper/deferred-content.d.ts +6 -0
- package/@ones-editor/core/src/helper/index.d.ts +1 -0
- package/@ones-editor/scroll-container/src/observer/container-intersection-observer.d.ts +1 -0
- package/@ones-editor/scroll-container/src/scroll-listener.d.ts +3 -1
- package/@ones-editor/table-block/src/table-block/selection-to-doc.d.ts +1 -1
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +259 -49
- package/package.json +1 -1
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
|
}
|
|
@@ -11888,6 +11896,94 @@ var __publicField = (obj, key, value) => {
|
|
|
11888
11896
|
const colorIndex = Math.abs(typeof content === "string" && content.trim() ? hashCode(content.trim()) : 0) % ColorNames.length;
|
|
11889
11897
|
return ColorNames[colorIndex];
|
|
11890
11898
|
}
|
|
11899
|
+
const renderers = /* @__PURE__ */ new WeakMap();
|
|
11900
|
+
const pendingEditors = /* @__PURE__ */ new WeakMap();
|
|
11901
|
+
function renderDeferredBlock(block) {
|
|
11902
|
+
var _a;
|
|
11903
|
+
(_a = renderers.get(block)) == null ? void 0 : _a();
|
|
11904
|
+
}
|
|
11905
|
+
class DeferredContents {
|
|
11906
|
+
constructor(editor) {
|
|
11907
|
+
__publicField(this, "pending", /* @__PURE__ */ new Map());
|
|
11908
|
+
__publicField(this, "owners", /* @__PURE__ */ new Map());
|
|
11909
|
+
__publicField(this, "observer");
|
|
11910
|
+
__publicField(this, "renderAll", () => {
|
|
11911
|
+
this.pending.forEach((ids, block) => renderDeferredBlock(block));
|
|
11912
|
+
});
|
|
11913
|
+
__publicField(this, "handleReadonlyChanged", () => {
|
|
11914
|
+
if (!this.editor.readonly)
|
|
11915
|
+
this.renderAll();
|
|
11916
|
+
});
|
|
11917
|
+
__publicField(this, "handleKeyDown", (event) => {
|
|
11918
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "f")
|
|
11919
|
+
this.renderAll();
|
|
11920
|
+
});
|
|
11921
|
+
var _a;
|
|
11922
|
+
this.editor = editor;
|
|
11923
|
+
this.observer = new IntersectionObserver((entries) => {
|
|
11924
|
+
entries.forEach((entry) => {
|
|
11925
|
+
if (entry.isIntersecting)
|
|
11926
|
+
renderDeferredBlock(entry.target);
|
|
11927
|
+
});
|
|
11928
|
+
}, { root: (_a = editor.options.scrollContainer) != null ? _a : null, rootMargin: "1000px 0px" });
|
|
11929
|
+
editor.on("readonlyChanged", this.handleReadonlyChanged);
|
|
11930
|
+
window.addEventListener("beforeprint", this.renderAll);
|
|
11931
|
+
window.addEventListener("keydown", this.handleKeyDown, true);
|
|
11932
|
+
}
|
|
11933
|
+
add(block, ids, render) {
|
|
11934
|
+
this.pending.set(block, ids);
|
|
11935
|
+
ids.forEach((id) => this.owners.set(id, block));
|
|
11936
|
+
renderers.set(block, () => {
|
|
11937
|
+
this.remove(block);
|
|
11938
|
+
render();
|
|
11939
|
+
});
|
|
11940
|
+
block.setAttribute("data-deferred-content", "true");
|
|
11941
|
+
this.observer.observe(block);
|
|
11942
|
+
}
|
|
11943
|
+
remove(block) {
|
|
11944
|
+
var _a;
|
|
11945
|
+
(_a = this.pending.get(block)) == null ? void 0 : _a.forEach((id) => this.owners.delete(id));
|
|
11946
|
+
this.pending.delete(block);
|
|
11947
|
+
renderers.delete(block);
|
|
11948
|
+
block.removeAttribute("data-deferred-content");
|
|
11949
|
+
this.observer.unobserve(block);
|
|
11950
|
+
}
|
|
11951
|
+
renderId(id) {
|
|
11952
|
+
const block = this.owners.get(id);
|
|
11953
|
+
if (block)
|
|
11954
|
+
renderDeferredBlock(block);
|
|
11955
|
+
}
|
|
11956
|
+
destroy() {
|
|
11957
|
+
this.observer.disconnect();
|
|
11958
|
+
this.pending.forEach((ids, block) => renderers.delete(block));
|
|
11959
|
+
this.owners.clear();
|
|
11960
|
+
this.pending.clear();
|
|
11961
|
+
this.editor.off("readonlyChanged", this.handleReadonlyChanged);
|
|
11962
|
+
window.removeEventListener("beforeprint", this.renderAll);
|
|
11963
|
+
window.removeEventListener("keydown", this.handleKeyDown, true);
|
|
11964
|
+
pendingEditors.delete(this.editor);
|
|
11965
|
+
}
|
|
11966
|
+
}
|
|
11967
|
+
function deferBlockContent(editor, block, ids, render) {
|
|
11968
|
+
let pending = pendingEditors.get(editor);
|
|
11969
|
+
if (!pending) {
|
|
11970
|
+
pending = editor.addCustom("deferred-contents", () => new DeferredContents(editor));
|
|
11971
|
+
pendingEditors.set(editor, pending);
|
|
11972
|
+
}
|
|
11973
|
+
pending.add(block, ids, render);
|
|
11974
|
+
}
|
|
11975
|
+
function renderDeferredContents(editor) {
|
|
11976
|
+
var _a;
|
|
11977
|
+
(_a = pendingEditors.get(editor)) == null ? void 0 : _a.renderAll();
|
|
11978
|
+
}
|
|
11979
|
+
function removeDeferredBlock(editor, block) {
|
|
11980
|
+
var _a;
|
|
11981
|
+
(_a = pendingEditors.get(editor)) == null ? void 0 : _a.remove(block);
|
|
11982
|
+
}
|
|
11983
|
+
function renderDeferredId(editor, id) {
|
|
11984
|
+
var _a;
|
|
11985
|
+
(_a = pendingEditors.get(editor)) == null ? void 0 : _a.renderId(id);
|
|
11986
|
+
}
|
|
11891
11987
|
const logger$4Q = getLogger("container");
|
|
11892
11988
|
function isContainer(elem) {
|
|
11893
11989
|
return elem.getAttribute("data-type") === "editor-container";
|
|
@@ -11923,7 +12019,11 @@ var __publicField = (obj, key, value) => {
|
|
|
11923
12019
|
return container;
|
|
11924
12020
|
}
|
|
11925
12021
|
function getContainerById(editor, containerId) {
|
|
11926
|
-
|
|
12022
|
+
let container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
|
|
12023
|
+
if (!container) {
|
|
12024
|
+
renderDeferredId(editor, containerId);
|
|
12025
|
+
container = editor.rootElement.querySelector(`[data-container-id=${containerId}]`);
|
|
12026
|
+
}
|
|
11927
12027
|
assert(logger$4P, container, `no container: ${containerId}`);
|
|
11928
12028
|
return container;
|
|
11929
12029
|
}
|
|
@@ -26786,9 +26886,25 @@ var __publicField = (obj, key, value) => {
|
|
|
26786
26886
|
}
|
|
26787
26887
|
}
|
|
26788
26888
|
}
|
|
26889
|
+
function allSelected(editor, range) {
|
|
26890
|
+
if (range.isCollapsed()) {
|
|
26891
|
+
return false;
|
|
26892
|
+
}
|
|
26893
|
+
const firstChildBlock = getFirstChildBlock(editor.rootContainer);
|
|
26894
|
+
const lastChildBlock = getLastChildBlock(editor.rootContainer);
|
|
26895
|
+
const { start, end } = range;
|
|
26896
|
+
return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
|
|
26897
|
+
}
|
|
26789
26898
|
function updateSelectionBackground(editor) {
|
|
26790
26899
|
clearAllSelection(editor);
|
|
26791
|
-
|
|
26900
|
+
const { range } = editor.selection;
|
|
26901
|
+
const cssSelection = hasClass(editor.rootContainer, "select-all") && range.isSimple() && allSelected(editor, range);
|
|
26902
|
+
range.getSelectedBlocks().forEach((s) => {
|
|
26903
|
+
if (cssSelection && isTextKindBlock(editor, s.block) && !s.block.hasAttribute("data-document-title")) {
|
|
26904
|
+
return;
|
|
26905
|
+
}
|
|
26906
|
+
updateBlockSelection(editor, s.block, s.start, s.end);
|
|
26907
|
+
});
|
|
26792
26908
|
}
|
|
26793
26909
|
const logger$3U = getLogger("editor-dom");
|
|
26794
26910
|
function editorGetClientHeight(editor) {
|
|
@@ -26937,15 +27053,6 @@ var __publicField = (obj, key, value) => {
|
|
|
26937
27053
|
anchorElem.remove();
|
|
26938
27054
|
}, 200);
|
|
26939
27055
|
}
|
|
26940
|
-
function allSelected(editor, range) {
|
|
26941
|
-
if (range.isCollapsed()) {
|
|
26942
|
-
return false;
|
|
26943
|
-
}
|
|
26944
|
-
const firstChildBlock = getFirstChildBlock(editor.rootContainer);
|
|
26945
|
-
const lastChildBlock = getLastChildBlock(editor.rootContainer);
|
|
26946
|
-
const { start, end } = range;
|
|
26947
|
-
return start.blockId === getBlockId(firstChildBlock) && start.offset === 0 && end.blockId === getBlockId(lastChildBlock) && end.offset === getBlockTextLength$6(editor, lastChildBlock);
|
|
26948
|
-
}
|
|
26949
27056
|
const logger$3T = getLogger("range-in-block");
|
|
26950
27057
|
function rangeInBlock(block, range) {
|
|
26951
27058
|
const editor = range.getEditor();
|
|
@@ -27712,14 +27819,14 @@ var __publicField = (obj, key, value) => {
|
|
|
27712
27819
|
}
|
|
27713
27820
|
function mergeDocs(docs) {
|
|
27714
27821
|
const rootBlocks = [];
|
|
27715
|
-
|
|
27822
|
+
const childContainers = /* @__PURE__ */ Object.create(null);
|
|
27716
27823
|
docs.forEach((doc2) => {
|
|
27717
27824
|
rootBlocks.push(...doc2.blocks.root);
|
|
27718
|
-
|
|
27719
|
-
|
|
27720
|
-
|
|
27721
|
-
|
|
27722
|
-
};
|
|
27825
|
+
Object.entries(doc2.blocks).forEach(([containerId, blocks]) => {
|
|
27826
|
+
if (containerId !== "root") {
|
|
27827
|
+
childContainers[containerId] = blocks;
|
|
27828
|
+
}
|
|
27829
|
+
});
|
|
27723
27830
|
});
|
|
27724
27831
|
return {
|
|
27725
27832
|
blocks: {
|
|
@@ -29029,10 +29136,10 @@ var __publicField = (obj, key, value) => {
|
|
|
29029
29136
|
doc2.blocks[childContainerId] = cloneDeep__default.default(childBlocks);
|
|
29030
29137
|
});
|
|
29031
29138
|
}
|
|
29032
|
-
function selectedBlockToDoc(editor, selectedBlock) {
|
|
29139
|
+
function selectedBlockToDoc(editor, selectedBlock, getSourceDoc) {
|
|
29033
29140
|
const blockClass = getBlockClass(editor, selectedBlock.block);
|
|
29034
29141
|
if (blockClass.selectionToDoc) {
|
|
29035
|
-
return blockClass.selectionToDoc(editor, selectedBlock);
|
|
29142
|
+
return blockClass.selectionToDoc(editor, selectedBlock, getSourceDoc);
|
|
29036
29143
|
}
|
|
29037
29144
|
const data2 = cloneDeep__default.default(editorGetBlockData(editor, selectedBlock.block));
|
|
29038
29145
|
if (isTextKindBlock(editor, selectedBlock.block)) {
|
|
@@ -29099,7 +29206,12 @@ var __publicField = (obj, key, value) => {
|
|
|
29099
29206
|
}
|
|
29100
29207
|
function selectionToDoc$2(editor) {
|
|
29101
29208
|
const selectedBlocks = editor.selection.range.getSelectedBlocks();
|
|
29102
|
-
|
|
29209
|
+
let sourceDoc;
|
|
29210
|
+
const getSourceDoc = () => {
|
|
29211
|
+
sourceDoc != null ? sourceDoc : sourceDoc = editor.doc.toJSON();
|
|
29212
|
+
return sourceDoc;
|
|
29213
|
+
};
|
|
29214
|
+
const docs = selectedBlocks.map((s) => selectedBlockToDoc(editor, s, getSourceDoc));
|
|
29103
29215
|
return mergeDocs(docs);
|
|
29104
29216
|
}
|
|
29105
29217
|
function containerToDoc(editor, containerId) {
|
|
@@ -32527,7 +32639,11 @@ ${codeText}
|
|
|
32527
32639
|
return this.selection.getFocusedBlock();
|
|
32528
32640
|
}
|
|
32529
32641
|
findBlockById(id) {
|
|
32530
|
-
|
|
32642
|
+
let block = this.rootContainer.querySelector(`#${id}`);
|
|
32643
|
+
if (!block) {
|
|
32644
|
+
renderDeferredId(this, id);
|
|
32645
|
+
block = this.rootContainer.querySelector(`#${id}`);
|
|
32646
|
+
}
|
|
32531
32647
|
if (block) {
|
|
32532
32648
|
assert(logger$3b, isBlock$1(block), "not an valid block element");
|
|
32533
32649
|
}
|
|
@@ -41171,9 +41287,31 @@ ${codeText}
|
|
|
41171
41287
|
class ChildBlockEventTracker extends tinyTypedEmitter.TypedEmitter {
|
|
41172
41288
|
constructor(editor) {
|
|
41173
41289
|
super();
|
|
41290
|
+
__publicField(this, "trackedListeners", /* @__PURE__ */ new Map());
|
|
41174
41291
|
this.editor = editor;
|
|
41175
41292
|
this.editor.doc.registerCallback(this);
|
|
41176
41293
|
}
|
|
41294
|
+
track(callback) {
|
|
41295
|
+
var _a;
|
|
41296
|
+
const count = (_a = this.trackedListeners.get(callback)) != null ? _a : 0;
|
|
41297
|
+
this.trackedListeners.set(callback, count + 1);
|
|
41298
|
+
if (count === 0) {
|
|
41299
|
+
this.addListener("change", callback);
|
|
41300
|
+
this.addListener("insert", callback);
|
|
41301
|
+
}
|
|
41302
|
+
}
|
|
41303
|
+
untrack(callback) {
|
|
41304
|
+
const count = this.trackedListeners.get(callback);
|
|
41305
|
+
if (!count)
|
|
41306
|
+
return;
|
|
41307
|
+
if (count > 1) {
|
|
41308
|
+
this.trackedListeners.set(callback, count - 1);
|
|
41309
|
+
} else {
|
|
41310
|
+
this.trackedListeners.delete(callback);
|
|
41311
|
+
this.removeListener("change", callback);
|
|
41312
|
+
this.removeListener("insert", callback);
|
|
41313
|
+
}
|
|
41314
|
+
}
|
|
41177
41315
|
handleChild(containerId, blockIndex, action) {
|
|
41178
41316
|
if (isRootContainer(getContainerById(this.editor, containerId))) {
|
|
41179
41317
|
return;
|
|
@@ -41201,6 +41339,8 @@ ${codeText}
|
|
|
41201
41339
|
}
|
|
41202
41340
|
destroy() {
|
|
41203
41341
|
this.editor.doc.unregisterCallback(this);
|
|
41342
|
+
this.trackedListeners.clear();
|
|
41343
|
+
this.removeAllListeners();
|
|
41204
41344
|
}
|
|
41205
41345
|
}
|
|
41206
41346
|
function trackChildBlockEvent(editor, callback) {
|
|
@@ -41208,16 +41348,14 @@ ${codeText}
|
|
|
41208
41348
|
"child-block-tracker",
|
|
41209
41349
|
() => new ChildBlockEventTracker(editor)
|
|
41210
41350
|
);
|
|
41211
|
-
handler.
|
|
41212
|
-
handler.addListener("insert", callback);
|
|
41351
|
+
handler.track(callback);
|
|
41213
41352
|
}
|
|
41214
41353
|
function untrackChildBlockEvent(editor, callback) {
|
|
41215
41354
|
const handler = editor.addCustom(
|
|
41216
41355
|
"child-block-tracker",
|
|
41217
41356
|
() => new ChildBlockEventTracker(editor)
|
|
41218
41357
|
);
|
|
41219
|
-
handler.
|
|
41220
|
-
handler.removeListener("insert", callback);
|
|
41358
|
+
handler.untrack(callback);
|
|
41221
41359
|
}
|
|
41222
41360
|
const style$e = "";
|
|
41223
41361
|
const zhCN$x = {
|
|
@@ -45605,6 +45743,7 @@ ${codeText}
|
|
|
45605
45743
|
return `${getBlockId(block)}_scroll`;
|
|
45606
45744
|
}
|
|
45607
45745
|
function getBlockTable(block) {
|
|
45746
|
+
renderDeferredBlock(block);
|
|
45608
45747
|
const table = block.querySelector("div[data-type=table-content] >table");
|
|
45609
45748
|
assert(logger$2E, table instanceof HTMLTableElement, "invalid table");
|
|
45610
45749
|
return table;
|
|
@@ -48688,13 +48827,22 @@ ${codeText}
|
|
|
48688
48827
|
class ContainerIntersectionObserver {
|
|
48689
48828
|
constructor(scrollCore, callback) {
|
|
48690
48829
|
__publicField(this, "intersectionObserver");
|
|
48830
|
+
__publicField(this, "intersecting", /* @__PURE__ */ new WeakSet());
|
|
48691
48831
|
__publicField(this, "handleIntersection", (entries) => {
|
|
48692
48832
|
entries.forEach((entry) => {
|
|
48693
48833
|
const container = this.containers.get(getContainer(entry.target));
|
|
48694
48834
|
if (container) {
|
|
48695
|
-
this.
|
|
48835
|
+
if (entry.isIntersecting || this.intersecting.has(entry.target)) {
|
|
48836
|
+
this.handleIntersectionEntry(entry);
|
|
48837
|
+
}
|
|
48838
|
+
if (entry.isIntersecting) {
|
|
48839
|
+
this.intersecting.add(entry.target);
|
|
48840
|
+
} else {
|
|
48841
|
+
this.intersecting.delete(entry.target);
|
|
48842
|
+
}
|
|
48696
48843
|
this.callback(entry);
|
|
48697
48844
|
} else {
|
|
48845
|
+
this.intersecting.delete(entry.target);
|
|
48698
48846
|
this.intersectionObserver.unobserve(entry.target);
|
|
48699
48847
|
}
|
|
48700
48848
|
});
|
|
@@ -48723,9 +48871,11 @@ ${codeText}
|
|
|
48723
48871
|
this.intersectionObserver.observe(scrollContainer);
|
|
48724
48872
|
}
|
|
48725
48873
|
unbind(scrollContainer) {
|
|
48874
|
+
this.intersecting.delete(scrollContainer);
|
|
48726
48875
|
this.intersectionObserver.unobserve(scrollContainer);
|
|
48727
48876
|
}
|
|
48728
48877
|
destroy() {
|
|
48878
|
+
this.intersecting = /* @__PURE__ */ new WeakSet();
|
|
48729
48879
|
this.intersectionObserver.disconnect();
|
|
48730
48880
|
}
|
|
48731
48881
|
}
|
|
@@ -49064,11 +49214,17 @@ ${codeText}
|
|
|
49064
49214
|
__publicField(this, "scrollWrapResizeObserve", null);
|
|
49065
49215
|
__publicField(this, "locatingContainerResizeObserver", null);
|
|
49066
49216
|
__publicField(this, "isWindowEventBind", false);
|
|
49217
|
+
__publicField(this, "boundContainers", /* @__PURE__ */ new WeakSet());
|
|
49067
49218
|
__publicField(this, "containers", /* @__PURE__ */ new Map());
|
|
49219
|
+
__publicField(this, "containerCallbacks", /* @__PURE__ */ new Map());
|
|
49068
49220
|
__publicField(this, "handleScrollContainerScroll", (scrollContainerElement) => {
|
|
49221
|
+
var _a;
|
|
49222
|
+
(_a = this.containerCallbacks.get(getContainer(scrollContainerElement))) == null ? void 0 : _a.scroll(this, scrollContainerElement);
|
|
49069
49223
|
this.emit("scroll", this, scrollContainerElement);
|
|
49070
49224
|
});
|
|
49071
49225
|
__publicField(this, "handleResize", (scrollContainerElement) => {
|
|
49226
|
+
var _a;
|
|
49227
|
+
(_a = this.containerCallbacks.get(getContainer(scrollContainerElement))) == null ? void 0 : _a.resize(this, scrollContainerElement);
|
|
49072
49228
|
this.emit("resize", this, scrollContainerElement);
|
|
49073
49229
|
});
|
|
49074
49230
|
__publicField(this, "handleIntersection", (entry) => {
|
|
@@ -49121,6 +49277,8 @@ ${codeText}
|
|
|
49121
49277
|
}
|
|
49122
49278
|
unbindCore(scrollContainer, scrollWrap) {
|
|
49123
49279
|
var _a, _b, _c, _d, _e, _f;
|
|
49280
|
+
if (!this.boundContainers.delete(scrollContainer))
|
|
49281
|
+
return;
|
|
49124
49282
|
const scrollbarContainer = getScrollbarContainer(scrollContainer);
|
|
49125
49283
|
(_a = this.containerScrollObserver) == null ? void 0 : _a.unbindContentScroll(scrollContainer);
|
|
49126
49284
|
(_b = this.containerScrollObserver) == null ? void 0 : _b.unbind(scrollbarContainer);
|
|
@@ -49145,8 +49303,11 @@ ${codeText}
|
|
|
49145
49303
|
(_e = this.parentContainerScrollObserver) == null ? void 0 : _e.bindScrollContainer(scrollContainer);
|
|
49146
49304
|
}
|
|
49147
49305
|
(_f = this.locatingContainerResizeObserver) == null ? void 0 : _f.bind(scrollContainer);
|
|
49306
|
+
this.boundContainers.add(scrollContainer);
|
|
49148
49307
|
}
|
|
49149
|
-
bind(container, option) {
|
|
49308
|
+
bind(container, option, callbacks) {
|
|
49309
|
+
if (callbacks)
|
|
49310
|
+
this.containerCallbacks.set(container, callbacks);
|
|
49150
49311
|
this.containers.set(container, option);
|
|
49151
49312
|
const scrollContainer = container.firstElementChild;
|
|
49152
49313
|
if (!this.containerIntersectionObserver) {
|
|
@@ -49160,6 +49321,7 @@ ${codeText}
|
|
|
49160
49321
|
const scrollWrap = getContainerScrollArea(scrollContainer);
|
|
49161
49322
|
this.unbindCore(scrollContainer, scrollWrap);
|
|
49162
49323
|
this.containers.delete(container);
|
|
49324
|
+
this.containerCallbacks.delete(container);
|
|
49163
49325
|
(_a = this.containerIntersectionObserver) == null ? void 0 : _a.unbind(scrollContainer);
|
|
49164
49326
|
if (!this.containers.size) {
|
|
49165
49327
|
this.destroy();
|
|
@@ -49208,9 +49370,10 @@ ${codeText}
|
|
|
49208
49370
|
rootScrollMap.set(parentContainer, this.scrollListener);
|
|
49209
49371
|
}
|
|
49210
49372
|
this.scrollListener.unbind(container);
|
|
49211
|
-
this.scrollListener.bind(container, options
|
|
49212
|
-
|
|
49213
|
-
|
|
49373
|
+
this.scrollListener.bind(container, options, {
|
|
49374
|
+
scroll: this.handleContainerScroll,
|
|
49375
|
+
resize: this.handleResize
|
|
49376
|
+
});
|
|
49214
49377
|
this.scrollContainerElement = scrollContainerElement;
|
|
49215
49378
|
});
|
|
49216
49379
|
__publicField(this, "handleContainerScroll", (scrollListener, scrollContainerElement) => {
|
|
@@ -49239,8 +49402,6 @@ ${codeText}
|
|
|
49239
49402
|
baseListener.destroy();
|
|
49240
49403
|
}
|
|
49241
49404
|
destroy() {
|
|
49242
|
-
var _a;
|
|
49243
|
-
(_a = this.scrollListener) == null ? void 0 : _a.off("scroll", this.handleContainerScroll);
|
|
49244
49405
|
const container = getContainer(this.contentElement);
|
|
49245
49406
|
if (container) {
|
|
49246
49407
|
rootScrollMap.forEach((baseListener, parentContainer) => {
|
|
@@ -74919,6 +75080,7 @@ ${codeText}
|
|
|
74919
75080
|
return table;
|
|
74920
75081
|
}
|
|
74921
75082
|
function createBlockContent$2(editor, path, container, blockElement, blockData) {
|
|
75083
|
+
var _a, _b;
|
|
74922
75084
|
assert(logger$_, blockData.type === "table", "not table data");
|
|
74923
75085
|
assert(logger$_, getContainerId(container) === path[path.length - 1].containerId, "invalid path");
|
|
74924
75086
|
const tableData = blockData;
|
|
@@ -74926,9 +75088,40 @@ ${codeText}
|
|
|
74926
75088
|
try {
|
|
74927
75089
|
const tableContent = createElement("div", [], null);
|
|
74928
75090
|
tableContent.setAttribute("data-type", "table-content");
|
|
74929
|
-
|
|
74930
|
-
|
|
74931
|
-
|
|
75091
|
+
if (isRootContainer(container)) {
|
|
75092
|
+
addClass(tableContent, "deferred-table-content");
|
|
75093
|
+
}
|
|
75094
|
+
let placeholder2;
|
|
75095
|
+
const renderTable = () => {
|
|
75096
|
+
try {
|
|
75097
|
+
const table = createTable(editor, path, tableData);
|
|
75098
|
+
table.classList.add("drag-preview-element");
|
|
75099
|
+
tableContent.appendChild(table);
|
|
75100
|
+
} catch (err) {
|
|
75101
|
+
const message = `invalid table data: ${JSON.stringify(tableData)}`;
|
|
75102
|
+
logger$_.error(message);
|
|
75103
|
+
createElement("div", ["error"], tableContent).innerText = message;
|
|
75104
|
+
}
|
|
75105
|
+
placeholder2 == null ? void 0 : placeholder2.remove();
|
|
75106
|
+
tableContent.style.minHeight = "";
|
|
75107
|
+
};
|
|
75108
|
+
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) => {
|
|
75109
|
+
var _a2;
|
|
75110
|
+
return block.type === "text" && !block.heading && !block.children && ((_a2 = block.text) == null ? void 0 : _a2.every((op) => {
|
|
75111
|
+
var _a3, _b2;
|
|
75112
|
+
return !((_a3 = op.attributes) == null ? void 0 : _a3.box) && !((_b2 = op.attributes) == null ? void 0 : _b2.insertion);
|
|
75113
|
+
}));
|
|
75114
|
+
}));
|
|
75115
|
+
if (defer) {
|
|
75116
|
+
tableContent.style.minHeight = "400px";
|
|
75117
|
+
placeholder2 = createElement("table", [], tableContent);
|
|
75118
|
+
placeholder2.style.minWidth = `${((_b = tableData.colsWidth) != null ? _b : []).reduce((sum, width) => sum + width, 0)}px`;
|
|
75119
|
+
placeholder2.setAttribute("aria-hidden", "true");
|
|
75120
|
+
const ids = tableData.children.flatMap((id) => [id, ...editor.doc.getContainerBlocks(id).map((block) => block.id)]);
|
|
75121
|
+
deferBlockContent(editor, blockElement, ids, renderTable);
|
|
75122
|
+
} else {
|
|
75123
|
+
renderTable();
|
|
75124
|
+
}
|
|
74932
75125
|
const options = editor.getComponentOptions("table");
|
|
74933
75126
|
if (!clientType.isMobile) {
|
|
74934
75127
|
handleTableResizeMouseEvent(editor);
|
|
@@ -74941,15 +75134,16 @@ ${codeText}
|
|
|
74941
75134
|
}
|
|
74942
75135
|
trackChildBlockEvent(editor, handleChartDebounceUpdate);
|
|
74943
75136
|
const scrollContainer = editor.addCustom(getTableScrollKey(blockElement), () => createScrollContainer());
|
|
74944
|
-
const
|
|
75137
|
+
const rootContainer = isRootContainer(container);
|
|
75138
|
+
const overflowY = rootContainer ? "" : window.getComputedStyle(container).overflowY;
|
|
74945
75139
|
const containerScrollable = overflowY === "auto" || overflowY === "scroll";
|
|
74946
75140
|
scrollContainer.init({
|
|
74947
75141
|
parentElement: content,
|
|
74948
75142
|
childElement: tableContent,
|
|
74949
75143
|
safeRightSpace: clientType.isMobile ? 20 : 50,
|
|
74950
75144
|
safeLeftSpace: 40,
|
|
74951
|
-
parentContainer:
|
|
74952
|
-
locatingContainer:
|
|
75145
|
+
parentContainer: rootContainer || !containerScrollable ? editor.scrollContainer : container,
|
|
75146
|
+
locatingContainer: rootContainer ? (options == null ? void 0 : options.locatingContainer) || editor.parent : container,
|
|
74953
75147
|
paddingLeft: TABLE_BAR_WIDTH + INSERT_BUTTON_SIZE,
|
|
74954
75148
|
paddingTop: TABLE_BAR_WIDTH + INSERT_BUTTON_SIZE,
|
|
74955
75149
|
paddingBottom: INSERT_BUTTON_SIZE / 2,
|
|
@@ -74961,9 +75155,11 @@ ${codeText}
|
|
|
74961
75155
|
const tableScrollEvents = handleTableScrollEvents(editor);
|
|
74962
75156
|
scrollContainer.on("scroll", tableScrollEvents.handleReset);
|
|
74963
75157
|
scrollContainer.on("resize", tableScrollEvents.handleReset);
|
|
74964
|
-
|
|
74965
|
-
|
|
74966
|
-
|
|
75158
|
+
if (tableData.chart) {
|
|
75159
|
+
setTimeout(() => {
|
|
75160
|
+
handleChartUpdate(editor, blockElement);
|
|
75161
|
+
});
|
|
75162
|
+
}
|
|
74967
75163
|
} catch (err) {
|
|
74968
75164
|
const message = `invalid table data: ${JSON.stringify(tableData)}`;
|
|
74969
75165
|
logger$_.error(message);
|
|
@@ -75118,13 +75314,14 @@ ${codeText}
|
|
|
75118
75314
|
return acc;
|
|
75119
75315
|
}, {});
|
|
75120
75316
|
}
|
|
75121
|
-
function selectionToDoc(editor, selectedBlock) {
|
|
75317
|
+
function selectionToDoc(editor, selectedBlock, getSourceDoc) {
|
|
75122
75318
|
const { start, end, block } = selectedBlock;
|
|
75123
75319
|
const blockType = getBlockType(block);
|
|
75124
75320
|
assert(logger$Y, blockType === "table", `invalid block type: ${blockType}`);
|
|
75125
75321
|
const blockData = editor.getBlockData(block);
|
|
75322
|
+
const oldDoc = getSourceDoc ? getSourceDoc() : editor.doc.toJSON();
|
|
75126
75323
|
if (start.isSimple() && end.isSimple()) {
|
|
75127
|
-
const doc2 = cloneBlock(editor.editorBlocks,
|
|
75324
|
+
const doc2 = cloneBlock(editor.editorBlocks, oldDoc, blockData);
|
|
75128
75325
|
return doc2;
|
|
75129
75326
|
}
|
|
75130
75327
|
assert(logger$Y, !start.isSimple() && !end.isSimple(), "invalid block pos type");
|
|
@@ -75132,7 +75329,6 @@ ${codeText}
|
|
|
75132
75329
|
const { fromCol, toCol, fromRow, toRow } = getTableSelectionRange(block, start, end);
|
|
75133
75330
|
const spanData = {};
|
|
75134
75331
|
const children = [];
|
|
75135
|
-
const oldDoc = editor.doc.toJSON();
|
|
75136
75332
|
let childContainers = {};
|
|
75137
75333
|
const subGrid = grid.sub({ row: fromRow, col: fromCol }, { row: toRow, col: toCol });
|
|
75138
75334
|
subGrid.forEach((row, rowIndex) => {
|
|
@@ -75786,13 +75982,14 @@ ${codeText}
|
|
|
75786
75982
|
return new DOMRect(clientRect.left, clientRect.top + offset, clientRect.width, Math.max(clientRect.height - offset * 2, 0));
|
|
75787
75983
|
}
|
|
75788
75984
|
function handleDeleteBlock$4(editor, block) {
|
|
75985
|
+
removeDeferredBlock(editor, block);
|
|
75789
75986
|
untrackChildBlockEvent(editor, handleChartDebounceUpdate);
|
|
75790
75987
|
const scrollContent = editor.findCustom(getTableScrollKey(block));
|
|
75791
75988
|
if (scrollContent) {
|
|
75792
75989
|
const tableScrollEvents = handleTableScrollEvents(editor);
|
|
75793
75990
|
scrollContent.off("scroll", tableScrollEvents.handleReset);
|
|
75794
75991
|
scrollContent.off("resize", tableScrollEvents.handleReset);
|
|
75795
|
-
|
|
75992
|
+
editor.destroyCustom(getTableScrollKey(block));
|
|
75796
75993
|
}
|
|
75797
75994
|
}
|
|
75798
75995
|
function getBlockProperties$9() {
|
|
@@ -79929,7 +80126,11 @@ ${docStr}
|
|
|
79929
80126
|
const eleRect = firstChild.getBoundingClientRect();
|
|
79930
80127
|
offsetTop = eleRect.y;
|
|
79931
80128
|
}
|
|
79932
|
-
|
|
80129
|
+
if (editor.readonly) {
|
|
80130
|
+
firstChild.scrollIntoView({ block: "center", inline: "nearest" });
|
|
80131
|
+
} else {
|
|
80132
|
+
scrollIntoView(editor, firstChild, { animation: true });
|
|
80133
|
+
}
|
|
79933
80134
|
}
|
|
79934
80135
|
function getCurrentHighligh(editor) {
|
|
79935
80136
|
const elem = editor.rootContainer.querySelector(".editor-highlight.active");
|
|
@@ -80196,6 +80397,7 @@ ${docStr}
|
|
|
80196
80397
|
if (!find) {
|
|
80197
80398
|
return;
|
|
80198
80399
|
}
|
|
80400
|
+
renderDeferredContents(editor);
|
|
80199
80401
|
const blocks = getAllChildBlocks(editor, {
|
|
80200
80402
|
simpleBlockOnly: true,
|
|
80201
80403
|
visibleOnly: true
|
|
@@ -80524,6 +80726,7 @@ ${docStr}
|
|
|
80524
80726
|
this.components.statusContainer.style.display = "flex";
|
|
80525
80727
|
}
|
|
80526
80728
|
show(options) {
|
|
80729
|
+
this.editor.rootElement.classList.add("find-dialog-open");
|
|
80527
80730
|
document.addEventListener("keydown", this.handleDocumentKeyDown);
|
|
80528
80731
|
const text2 = this.editor.getSelectedText();
|
|
80529
80732
|
if (text2.length > 0 && text2.length < 50) {
|
|
@@ -80576,6 +80779,7 @@ ${docStr}
|
|
|
80576
80779
|
}
|
|
80577
80780
|
hide() {
|
|
80578
80781
|
var _a;
|
|
80782
|
+
this.editor.rootElement.classList.remove("find-dialog-open");
|
|
80579
80783
|
(_a = this.dialog) == null ? void 0 : _a.close("cancelBar");
|
|
80580
80784
|
clearAllHighlights(this.editor);
|
|
80581
80785
|
document.removeEventListener("keydown", this.handleDocumentKeyDown);
|
|
@@ -80590,6 +80794,7 @@ ${docStr}
|
|
|
80590
80794
|
}
|
|
80591
80795
|
destroy() {
|
|
80592
80796
|
var _a;
|
|
80797
|
+
this.editor.rootElement.classList.remove("find-dialog-open");
|
|
80593
80798
|
(_a = this.dialog) == null ? void 0 : _a.destroy();
|
|
80594
80799
|
}
|
|
80595
80800
|
}
|
|
@@ -97661,7 +97866,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97661
97866
|
}
|
|
97662
97867
|
}
|
|
97663
97868
|
});
|
|
97664
|
-
editor.version = "5.0.
|
|
97869
|
+
editor.version = "5.0.5-beta.ONES22302330.2";
|
|
97665
97870
|
return editor;
|
|
97666
97871
|
}
|
|
97667
97872
|
function isDoc(doc2) {
|
|
@@ -97797,7 +98002,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97797
98002
|
OnesEditorDropTarget.register(editor);
|
|
97798
98003
|
OnesEditorTocProvider.register(editor);
|
|
97799
98004
|
OnesEditorExclusiveBlock.register(editor);
|
|
97800
|
-
editor.version = "5.0.
|
|
98005
|
+
editor.version = "5.0.5-beta.ONES22302330.2";
|
|
97801
98006
|
return editor;
|
|
97802
98007
|
} catch (error2) {
|
|
97803
98008
|
try {
|
|
@@ -97940,7 +98145,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
97940
98145
|
}
|
|
97941
98146
|
}
|
|
97942
98147
|
});
|
|
97943
|
-
editor.version = "5.0.
|
|
98148
|
+
editor.version = "5.0.5-beta.ONES22302330.2";
|
|
97944
98149
|
return editor;
|
|
97945
98150
|
}
|
|
97946
98151
|
const emojis$1 = {
|
|
@@ -144073,6 +144278,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144073
144278
|
exports2.createTextWithReplaceSoftReturn = createTextWithReplaceSoftReturn;
|
|
144074
144279
|
exports2.dataURLToBlob = dataURLToBlob;
|
|
144075
144280
|
exports2.daysAfter = daysAfter;
|
|
144281
|
+
exports2.deferBlockContent = deferBlockContent;
|
|
144076
144282
|
exports2.deleteColor = deleteColor;
|
|
144077
144283
|
exports2.deleteText = deleteText;
|
|
144078
144284
|
exports2.diffDays = diffDays;
|
|
@@ -144438,9 +144644,13 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
144438
144644
|
exports2.registerDragDrop = registerDragDrop;
|
|
144439
144645
|
exports2.removeAttribute = removeAttribute;
|
|
144440
144646
|
exports2.removeClass = removeClass;
|
|
144647
|
+
exports2.removeDeferredBlock = removeDeferredBlock;
|
|
144441
144648
|
exports2.removeLastBr = removeLastBr;
|
|
144442
144649
|
exports2.removePlaceholderFromBlock = removePlaceholderFromBlock;
|
|
144443
144650
|
exports2.removeStyle = removeStyle;
|
|
144651
|
+
exports2.renderDeferredBlock = renderDeferredBlock;
|
|
144652
|
+
exports2.renderDeferredContents = renderDeferredContents;
|
|
144653
|
+
exports2.renderDeferredId = renderDeferredId;
|
|
144444
144654
|
exports2.repairDuplicatedBlockIds = repairDuplicatedBlockIds;
|
|
144445
144655
|
exports2.replaceAll = replaceAll$1;
|
|
144446
144656
|
exports2.replaceAllCaseInsensitive = replaceAllCaseInsensitive;
|