@ones-editor/editor 2.9.8-beta.3 → 2.9.8-beta.30

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.
Files changed (32) hide show
  1. package/@ones-editor/cke-html/package.json +7 -0
  2. package/@ones-editor/cke-html/src/html/cke-html.d.ts +4 -0
  3. package/@ones-editor/cke-html/src/html/combine-html.d.ts +2 -0
  4. package/@ones-editor/cke-html/src/html/comment.d.ts +6 -0
  5. package/@ones-editor/cke-html/src/html/converter.d.ts +7 -0
  6. package/@ones-editor/cke-html/src/html/data-helper/link-data.d.ts +0 -0
  7. package/@ones-editor/cke-html/src/html/image.d.ts +4 -0
  8. package/@ones-editor/cke-html/src/html/link.d.ts +2 -0
  9. package/@ones-editor/cke-html/src/html/markdown.d.ts +2 -0
  10. package/@ones-editor/cke-html/src/html/mention.d.ts +4 -0
  11. package/@ones-editor/cke-html/src/index.d.ts +2 -0
  12. package/@ones-editor/core/src/core/doc/doc.d.ts +2 -1
  13. package/@ones-editor/core/src/core/editor-doc/editor-doc.d.ts +1 -0
  14. package/@ones-editor/core/src/core/selection/actions/index.d.ts +2 -2
  15. package/@ones-editor/core/src/core/selection/actions/select-all.d.ts +1 -0
  16. package/@ones-editor/core/src/core/types.d.ts +2 -0
  17. package/@ones-editor/core/src/local-doc/index.d.ts +1 -0
  18. package/@ones-editor/core/src/users/remote-users.d.ts +1 -1
  19. package/@ones-editor/graph-embed/src/helper/graph-dom/code-editor.d.ts +1 -0
  20. package/@ones-editor/list-block/src/index.d.ts +2 -0
  21. package/@ones-editor/main-toolbar/src/items/insert.d.ts +3 -0
  22. package/@ones-editor/server-tools/src/index.d.ts +4 -1
  23. package/@ones-editor/sharedb-doc/src/doc/sharedb-doc.d.ts +2 -0
  24. package/@ones-editor/tsconfig.tsbuildinfo +1 -1
  25. package/@ones-editor/ui/src/providers/list.d.ts +1 -1
  26. package/@ones-editor/ui-base/src/command-bar/command-bar.d.ts +1 -0
  27. package/@ones-editor/ui-base/src/command-bar/fixed-toolbar.d.ts +1 -0
  28. package/@ones-editor/ui-base/src/command-bar/types.d.ts +5 -0
  29. package/@ones-editor/versions/src/history-doc/history-doc.d.ts +1 -0
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +651 -128
  32. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1914,6 +1914,10 @@ div.tippy-box[data-theme=menu] .tippy-content .editor-command-bar.menu .menu-ite
1914
1914
  }.editor-command-bar.toolbar .command-item[data-dropdown=true][data-id=text-color-item] {
1915
1915
  padding-left: 0;
1916
1916
  padding-right: 0;
1917
+ }
1918
+ .command-item[data-button-id=text-color-item].disabled .color-button {
1919
+ cursor: not-allowed;
1920
+ opacity: 0.5;
1917
1921
  }.editor-input-wrap .editor-input-label {
1918
1922
  margin-top: 8px;
1919
1923
  margin-bottom: 8px;
@@ -3190,11 +3194,9 @@ div.editor-root div.editor-content div[data-type=editor-block] div[data-type=blo
3190
3194
  }
3191
3195
  div.editor-root div.editor-content div[data-type=editor-block] div[data-type=block-content] > span.status-box .box-status-common {
3192
3196
  max-width: 100%;
3193
- line-height: 20px;
3194
3197
  padding: 0px 5px;
3195
3198
  border-radius: 3px;
3196
- font-size: 12px;
3197
- height: 20px;
3199
+ font-size: 0.8em;
3198
3200
  cursor: pointer;
3199
3201
  white-space: nowrap;
3200
3202
  text-overflow: ellipsis;
@@ -8809,7 +8811,31 @@ div.editor-root div.editor-content div[data-type=editor-container].root.select-a
8809
8811
  margin-left: 5px;
8810
8812
  margin-right: 5px;
8811
8813
  }div.editor-root.compact div.editor-content div[data-type=editor-container].root > .container-blocks > * + * {
8812
- margin: 0.2em 0;
8814
+ margin-top: 0.2em;
8815
+ }
8816
+ div.editor-root.compact div.editor-content div[data-type=editor-block][data-style-quoted] + div[data-type=editor-block][data-style-quoted] {
8817
+ margin-top: 0;
8818
+ }
8819
+ div.editor-root.compact div.editor-content div[data-type=editor-block].layout-block .container-blocks > * + * {
8820
+ margin-top: 0.2em;
8821
+ }
8822
+ div.editor-root.compact div.editor-content div[data-type=editor-block][data-style-heading="1"]:not(:first-child) {
8823
+ margin-top: 0.5em !important;
8824
+ }
8825
+ div.editor-root.compact div.editor-content div[data-type=editor-block][data-style-heading="2"]:not(:first-child) {
8826
+ margin-top: 0.5em !important;
8827
+ }
8828
+ div.editor-root.compact div.editor-content div[data-type=editor-block][data-style-heading="3"]:not(:first-child) {
8829
+ margin-top: 0.5em !important;
8830
+ }
8831
+ div.editor-root.compact div.editor-content div[data-type=editor-block][data-style-heading="4"]:not(:first-child) {
8832
+ margin-top: 0.4em !important;
8833
+ }
8834
+ div.editor-root.compact div.editor-content div[data-type=editor-block][data-style-heading="5"]:not(:first-child) {
8835
+ margin-top: 0.3em !important;
8836
+ }
8837
+ div.editor-root.compact div.editor-content div[data-type=editor-block][data-style-heading="6"]:not(:first-child) {
8838
+ margin-top: 0.2em !important;
8813
8839
  }
8814
8840
  div.editor-root.compact.no-heading-collapse.no-block-menu > .editor-content {
8815
8841
  padding-left: 10px;
@@ -9958,6 +9984,9 @@ var __publicField = (obj, key, value) => {
9958
9984
  setDataset(elem, dataset);
9959
9985
  }
9960
9986
  }
9987
+ if (tagName === "button") {
9988
+ elem.type = "button";
9989
+ }
9961
9990
  return elem;
9962
9991
  }
9963
9992
  function createIconButton(svg, classes, parent) {
@@ -24898,18 +24927,11 @@ var __publicField = (obj, key, value) => {
24898
24927
  };
24899
24928
  }
24900
24929
  function isEmptyDoc(doc2) {
24901
- const root2 = doc2.blocks.root;
24902
- if (root2.length !== 1) {
24903
- return false;
24904
- }
24905
- const block = root2[0];
24906
- if (!block.text) {
24907
- return false;
24908
- }
24909
- if (getTextLength(block.text)) {
24910
- return false;
24911
- }
24912
- return true;
24930
+ const blocks = doc2.blocks.root;
24931
+ const ret = blocks.every((block) => {
24932
+ return block.type === "text" && getTextLength(block.text || []) === 0;
24933
+ });
24934
+ return ret;
24913
24935
  }
24914
24936
  function createContainer$1(doc2, docsOrDocObject) {
24915
24937
  const containerId = genId();
@@ -26352,9 +26374,10 @@ var __publicField = (obj, key, value) => {
26352
26374
  const y2 = rect.bottom > windowHeight ? windowHeight : rect.bottom;
26353
26375
  const centerX = (x1 + x2) / 2;
26354
26376
  const centerY = (y1 + y2) / 2;
26355
- const x = 0 - rect.left + centerX;
26356
- const y = 0 - rect.top + centerY + container.scrollTop;
26357
26377
  const input2 = editor.input.inputElement;
26378
+ const inputHeight = input2.getBoundingClientRect().height;
26379
+ const x = 0 - rect.left + centerX;
26380
+ const y = 0 - rect.top + centerY + container.scrollTop - inputHeight / 2;
26358
26381
  input2.style.left = `${x / scale}px`;
26359
26382
  input2.style.top = `${y / scale}px`;
26360
26383
  }
@@ -26412,6 +26435,10 @@ var __publicField = (obj, key, value) => {
26412
26435
  if (isNodeRemoved(this.editor.rootElement)) {
26413
26436
  return;
26414
26437
  }
26438
+ const rootRect = this.editor.rootElement.getBoundingClientRect();
26439
+ if (rootRect.width === 0 || rootRect.height === 0) {
26440
+ return;
26441
+ }
26415
26442
  const cursor = this.caretElem;
26416
26443
  if (this.hasCaret()) {
26417
26444
  cursor.style.display = "";
@@ -26420,42 +26447,46 @@ var __publicField = (obj, key, value) => {
26420
26447
  moveInputToScreenCenter(this.editor);
26421
26448
  return;
26422
26449
  }
26423
- const { range } = this.editor.selection;
26424
- assert(logger$3S, range.isCollapsed, "range is not collapsed");
26425
- const pos = range.start;
26426
- assert(logger$3S, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26427
- const block = this.editor.getBlockById(pos.blockId);
26428
- assert(logger$3S, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26429
- let rect;
26430
- const compositionSpan = block.querySelector("span.inputting-insertion");
26431
- if (compositionSpan) {
26432
- rect = getLastClientRect(compositionSpan);
26433
- rect = new DOMRect(rect.right, rect.top, 1, rect.height);
26434
- } else {
26435
- rect = getTextCaretRect(block, pos);
26436
- }
26437
- const editorRect = this.editor.contentElement.getBoundingClientRect();
26438
- const x = rect.left - editorRect.left;
26439
- const y = rect.top - editorRect.top;
26440
- cursor.style.left = `${x}px`;
26441
- cursor.style.top = `${y}px`;
26442
- cursor.style.height = `${rect.height}px`;
26443
- const input2 = this.editor.input.inputElement;
26444
- input2.style.left = `${x}px`;
26445
- input2.style.top = `${y + rect.height - 24}px`;
26446
- if (clientType.isMobileSafari) {
26447
- input2.style.left = `${x - 4}px`;
26448
- input2.style.height = `${rect.height}px`;
26449
- }
26450
- const scrollContainer = getScrollContainer$1(block, { horizontal: true });
26451
- const scrollRect = scrollContainer.getBoundingClientRect();
26452
- const scrollLeft = scrollRect.left - editorRect.left;
26453
- const scrollRight = scrollLeft + scrollRect.width;
26454
- if (x < scrollLeft || x > scrollRight) {
26455
- moveInputToScreenCenter(this.editor);
26456
- cursor.style.display = "none";
26457
- } else {
26458
- cursor.style.display = "";
26450
+ try {
26451
+ const { range } = this.editor.selection;
26452
+ assert(logger$3S, range.isCollapsed, "range is not collapsed");
26453
+ const pos = range.start;
26454
+ assert(logger$3S, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26455
+ const block = this.editor.getBlockById(pos.blockId);
26456
+ assert(logger$3S, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26457
+ let rect;
26458
+ const compositionSpan = block.querySelector("span.inputting-insertion");
26459
+ if (compositionSpan) {
26460
+ rect = getLastClientRect(compositionSpan);
26461
+ rect = new DOMRect(rect.right, rect.top, 1, rect.height);
26462
+ } else {
26463
+ rect = getTextCaretRect(block, pos);
26464
+ }
26465
+ const editorRect = this.editor.contentElement.getBoundingClientRect();
26466
+ const x = rect.left - editorRect.left;
26467
+ const y = rect.top - editorRect.top;
26468
+ cursor.style.left = `${x}px`;
26469
+ cursor.style.top = `${y}px`;
26470
+ cursor.style.height = `${rect.height}px`;
26471
+ const input2 = this.editor.input.inputElement;
26472
+ input2.style.left = `${x}px`;
26473
+ input2.style.top = `${y + rect.height - 24}px`;
26474
+ if (clientType.isMobileSafari) {
26475
+ input2.style.left = `${x - 4}px`;
26476
+ input2.style.height = `${rect.height}px`;
26477
+ }
26478
+ const scrollContainer = getScrollContainer$1(block, { horizontal: true });
26479
+ const scrollRect = scrollContainer.getBoundingClientRect();
26480
+ const scrollLeft = scrollRect.left - editorRect.left;
26481
+ const scrollRight = scrollLeft + scrollRect.width;
26482
+ if (x < scrollLeft || x > scrollRight) {
26483
+ moveInputToScreenCenter(this.editor);
26484
+ cursor.style.display = "none";
26485
+ } else {
26486
+ cursor.style.display = "";
26487
+ }
26488
+ } catch (err) {
26489
+ logger$3S.error(err);
26459
26490
  }
26460
26491
  }
26461
26492
  }
@@ -26640,13 +26671,14 @@ var __publicField = (obj, key, value) => {
26640
26671
  while (prevBlock && !blocks.has(getBlockId(prevBlock))) {
26641
26672
  prevBlock = getPrevVisibleBlock(prevBlock);
26642
26673
  }
26643
- assert(logger$3Q, prevBlock, "no prev block while deleting a block");
26644
- newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
26645
- } else {
26646
- const nextBlock = getNextVisibleBlock(block);
26647
- assert(logger$3Q, nextBlock, "no prev and next block while deleting a block");
26648
- newRange = createBlockSimpleRange(editor, nextBlock, 0);
26674
+ if (prevBlock) {
26675
+ newRange = createBlockSimpleRange(editor, prevBlock, getBlockTextLength$6(editor, prevBlock));
26676
+ return newRange;
26677
+ }
26649
26678
  }
26679
+ const nextBlock = getNextVisibleBlock(block);
26680
+ assert(logger$3Q, nextBlock, "no prev and next block while deleting a block");
26681
+ newRange = createBlockSimpleRange(editor, nextBlock, 0);
26650
26682
  return newRange;
26651
26683
  }
26652
26684
  const logger$3P = getLogger("block-to-html");
@@ -28546,6 +28578,10 @@ var __publicField = (obj, key, value) => {
28546
28578
  const end = createSimpleBlockPosition(lastBlock2, getBlockTextLength$6(editor, lastBlock2), "end");
28547
28579
  editor.selection.setSelection(start, end, { noScroll: true });
28548
28580
  }
28581
+ function editorSelectAllBlocks(editor) {
28582
+ addClass(editor.rootContainer, "select-all");
28583
+ selectParentContainer(editor, getFirstChildBlock(editor.rootContainer));
28584
+ }
28549
28585
  function editorSelectWord(editor) {
28550
28586
  const old = editor.selection.range.focus;
28551
28587
  if (!old.isSimple())
@@ -28808,10 +28844,19 @@ var __publicField = (obj, key, value) => {
28808
28844
  });
28809
28845
  this.editor = editor;
28810
28846
  const block = editor.getFirstBlock();
28811
- const blockId = getBlockId(block);
28812
28847
  this.caret = new EditorCaret(editor);
28813
- const pos = createSimpleBlockPosition(blockId, 0, "normal");
28814
- this._range = createEditorSelectionRange(editor, { anchor: pos, focus: pos });
28848
+ if (isComplexKindBlock(editor, block)) {
28849
+ const simpleBlock = complexBlockGetFirstSimpleChild(editor, block, {
28850
+ visibleOnly: true
28851
+ }) || block;
28852
+ const blockId = getBlockId(simpleBlock);
28853
+ const pos = createSimpleBlockPosition(blockId, 0, "normal");
28854
+ this._range = createEditorSelectionRange(editor, { anchor: pos, focus: pos });
28855
+ } else {
28856
+ const blockId = getBlockId(block);
28857
+ const pos = createSimpleBlockPosition(blockId, 0, "normal");
28858
+ this._range = createEditorSelectionRange(editor, { anchor: pos, focus: pos });
28859
+ }
28815
28860
  this.lastCaretRect = null;
28816
28861
  this.editor.addListener("blockDeleted", this.handleBlockDelete);
28817
28862
  setTimeout(() => {
@@ -29912,7 +29957,7 @@ ${codeText}
29912
29957
  const remoteResourcesMap = /* @__PURE__ */ new Map();
29913
29958
  Object.entries(resources).forEach(([resourceId, resourceUrl]) => {
29914
29959
  if (localResourcesMap.get(resourceId) === void 0) {
29915
- if (resourceId !== resourceUrl) {
29960
+ if (resourceId !== resourceUrl && resourceId.indexOf(":") === -1) {
29916
29961
  remoteResourcesMap.set(resourceId, resourceUrl);
29917
29962
  }
29918
29963
  }
@@ -30570,6 +30615,10 @@ ${codeText}
30570
30615
  endBatchUpdate() {
30571
30616
  return this.externalDoc.endBatchUpdate();
30572
30617
  }
30618
+ applyingOps() {
30619
+ var _a, _b;
30620
+ return ((_b = (_a = this.externalDoc).applyingOps) == null ? void 0 : _b.call(_a)) || false;
30621
+ }
30573
30622
  registerLocalEvents(events2) {
30574
30623
  this.localEvents.push(events2);
30575
30624
  }
@@ -31795,11 +31844,16 @@ ${codeText}
31795
31844
  return rangeResult;
31796
31845
  }
31797
31846
  }
31798
- const blocks = range.getSelectedBlocks();
31799
- blocks.forEach((b) => {
31800
- const childRange = createEditorSelectionRange(editor, { anchor: b.start, focus: b.end });
31801
- this.executeBlockCommand(editor, b.block, childRange, command, params, rangeResult);
31802
- });
31847
+ editor.doc.beginBatchUpdate();
31848
+ try {
31849
+ const blocks = range.getSelectedBlocks();
31850
+ blocks.forEach((b) => {
31851
+ const childRange = createEditorSelectionRange(editor, { anchor: b.start, focus: b.end });
31852
+ this.executeBlockCommand(editor, b.block, childRange, command, params, rangeResult);
31853
+ });
31854
+ } finally {
31855
+ editor.doc.endBatchUpdate();
31856
+ }
31803
31857
  if (!clientType.isMobile) {
31804
31858
  editor.focus();
31805
31859
  }
@@ -31956,6 +32010,7 @@ ${codeText}
31956
32010
  __publicField(this, "settingsProvider");
31957
32011
  __publicField(this, "_readonly", false);
31958
32012
  __publicField(this, "_scrollable", true);
32013
+ __publicField(this, "_destroyed", false);
31959
32014
  __publicField(this, "getColor", (index2) => {
31960
32015
  const colors = this.options.colors;
31961
32016
  if (colors.length === 0) {
@@ -32095,6 +32150,10 @@ ${codeText}
32095
32150
  this.domEvents.destroy();
32096
32151
  this.removeAllListeners();
32097
32152
  this.inputHandlers.destroy();
32153
+ this._destroyed = true;
32154
+ }
32155
+ get destroyed() {
32156
+ return this._destroyed;
32098
32157
  }
32099
32158
  focus(options) {
32100
32159
  this.input.focus(options);
@@ -32386,11 +32445,17 @@ ${codeText}
32386
32445
  this.emit("change", Array.from(this.users.values()));
32387
32446
  }, 300);
32388
32447
  }
32389
- getSimpleCursors(blockId) {
32448
+ getSimpleCursors(blockId, excludeUserId) {
32390
32449
  const ret = /* @__PURE__ */ new Map();
32391
32450
  Array.from(this.cursors.values()).filter((message) => {
32392
32451
  const ret2 = message.range.anchor.blockId === blockId && isSimpleRange(message.range);
32393
- return ret2;
32452
+ if (!ret2) {
32453
+ return false;
32454
+ }
32455
+ if (excludeUserId && excludeUserId === message.user.userId) {
32456
+ return false;
32457
+ }
32458
+ return true;
32394
32459
  }).forEach((message) => {
32395
32460
  const offset = message.range.focus.offset;
32396
32461
  let users = ret.get(offset);
@@ -32471,6 +32536,9 @@ ${codeText}
32471
32536
  rawData() {
32472
32537
  return this.doc;
32473
32538
  }
32539
+ applyingOps() {
32540
+ return false;
32541
+ }
32474
32542
  getContainerBlocks(containerId) {
32475
32543
  const blocks = this.doc.blocks[containerId];
32476
32544
  return blocks;
@@ -39453,6 +39521,7 @@ ${codeText}
39453
39521
  __publicField(this, "disableLogout");
39454
39522
  __publicField(this, "destroyed", false);
39455
39523
  __publicField(this, "editStatus");
39524
+ __publicField(this, "_applyingOps", false);
39456
39525
  __publicField(this, "handleNothingPending", () => {
39457
39526
  this.setStatus("clean");
39458
39527
  });
@@ -39637,11 +39706,14 @@ ${codeText}
39637
39706
  return;
39638
39707
  }
39639
39708
  try {
39709
+ this._applyingOps = true;
39640
39710
  const local = !!source;
39641
39711
  parseOps(ops, this, local);
39642
39712
  } catch (err) {
39643
39713
  logger$2T.error(err);
39644
39714
  throw err;
39715
+ } finally {
39716
+ this._applyingOps = false;
39645
39717
  }
39646
39718
  });
39647
39719
  this.options = options;
@@ -39666,6 +39738,9 @@ ${codeText}
39666
39738
  }
39667
39739
  return this.batching;
39668
39740
  }
39741
+ applyingOps() {
39742
+ return this._applyingOps;
39743
+ }
39669
39744
  static async load(options) {
39670
39745
  try {
39671
39746
  const client = new ShareDBClient(options.auth, options.serverUrl, options.renewTokenFunc);
@@ -40162,7 +40237,7 @@ ${codeText}
40162
40237
  assert(logger$2S, typeof blockIndex === "number", "invalid path blockIndex");
40163
40238
  const blockData = editor.doc.getBlockData(containerId, blockIndex);
40164
40239
  const length = getTextLength(blockText);
40165
- const cursorMessages = remoteUsers.getSimpleCursors(blockData.id);
40240
+ const cursorMessages = remoteUsers.getSimpleCursors(blockData.id, editor.doc.getUser().userId);
40166
40241
  cursorMessages.forEach((messages, offset) => {
40167
40242
  if (offset > length) {
40168
40243
  offset = length;
@@ -41364,12 +41439,18 @@ ${codeText}
41364
41439
  return true;
41365
41440
  });
41366
41441
  __publicField(this, "handleDocumentMouseDown", (event) => {
41367
- var _a, _b;
41442
+ var _a, _b, _c;
41368
41443
  if (event.target instanceof Element) {
41369
41444
  if ((_b = (_a = this.options).beforeClose) == null ? void 0 : _b.call(_a, event)) {
41370
41445
  return;
41371
41446
  }
41372
41447
  if (!this.isInCommandBar(event.target)) {
41448
+ if (((_c = this.canClose) == null ? void 0 : _c.call(this)) === false) {
41449
+ return;
41450
+ }
41451
+ if (!this.isVisible) {
41452
+ return;
41453
+ }
41373
41454
  const events2 = this.listeners("closing");
41374
41455
  for (let i = 0; i < events2.length; i++) {
41375
41456
  if (events2[i](this, event) === false) {
@@ -41629,6 +41710,9 @@ ${codeText}
41629
41710
  this.content.appendChild(child);
41630
41711
  });
41631
41712
  }
41713
+ canClose() {
41714
+ return true;
41715
+ }
41632
41716
  get popper() {
41633
41717
  return this.content.closest("[data-tippy-root]");
41634
41718
  }
@@ -41987,7 +42071,7 @@ ${codeText}
41987
42071
  placement: (_a = options == null ? void 0 : options.placement) != null ? _a : "bottom-start",
41988
42072
  maxWidth: (_b = this.options.maxWidth) != null ? _b : 650,
41989
42073
  arrow: (_c = options == null ? void 0 : options.arrow) != null ? _c : this.options.tippyArrow,
41990
- appendTo: document.body,
42074
+ appendTo: this.options.appendTo || target.closest(".command-bar-container") || document.body,
41991
42075
  onShow: this.handleShow,
41992
42076
  onHidden: this.handleHidden,
41993
42077
  onShown: this.handleShown,
@@ -42553,7 +42637,7 @@ ${codeText}
42553
42637
  placement: (_a = options == null ? void 0 : options.placement) != null ? _a : "bottom-start",
42554
42638
  maxWidth: 500,
42555
42639
  arrow: this.options.tippyArrow,
42556
- appendTo: document.body,
42640
+ appendTo: this.options.appendTo || target.closest(".command-bar-container") || document.body,
42557
42641
  onShow: this.handleShow,
42558
42642
  onHidden: this.handleHidden,
42559
42643
  delay: options == null ? void 0 : options.delay,
@@ -42655,6 +42739,12 @@ ${codeText}
42655
42739
  initItemElement(item, elem) {
42656
42740
  initToolbarItem(item, elem, this.options);
42657
42741
  }
42742
+ canClose() {
42743
+ if (this.subBar) {
42744
+ return true;
42745
+ }
42746
+ return false;
42747
+ }
42658
42748
  close() {
42659
42749
  this.clearSelectedItem();
42660
42750
  if (this.subBar) {
@@ -43163,7 +43253,7 @@ ${codeText}
43163
43253
  placement: "bottom",
43164
43254
  maxWidth: 1e3,
43165
43255
  arrow: (_b = options == null ? void 0 : options.arrow) != null ? _b : this.options.tippyArrow,
43166
- appendTo: document.body,
43256
+ appendTo: this.options.appendTo || target.closest(".command-bar-container") || document.body,
43167
43257
  onShow: this.handleShow,
43168
43258
  onShown: this.handleShown,
43169
43259
  onHidden: this.handleHidden,
@@ -43824,6 +43914,9 @@ ${codeText}
43824
43914
  __publicField(this, "handlePaletteClick", (type, value) => {
43825
43915
  this.setLatestColors(type, value);
43826
43916
  this.emit("onClick", type, value);
43917
+ setTimeout(() => {
43918
+ this.editor.emit("textColorChanged", this.editor, this);
43919
+ }, 100);
43827
43920
  });
43828
43921
  __publicField(this, "handleButtonClick", () => {
43829
43922
  const [color, backgroundColor] = this.latestColors;
@@ -43849,6 +43942,9 @@ ${codeText}
43849
43942
  this.emit("onClick", "backgroundColor", backgroundColor);
43850
43943
  }
43851
43944
  this.currentTextColors = [color, backgroundColor];
43945
+ setTimeout(() => {
43946
+ this.editor.emit("textColorChanged", this.editor, this);
43947
+ }, 100);
43852
43948
  });
43853
43949
  __publicField(this, "setLatestColors", (type, value) => {
43854
43950
  var _a, _b;
@@ -43886,6 +43982,13 @@ ${codeText}
43886
43982
  this.element.addEventListener("click", this.handleButtonClick);
43887
43983
  this.bindColorButtonEvents();
43888
43984
  this.element.setAttribute(`data-editor-tooltip-${editor.clientId}`, this.name);
43985
+ this.editor.addListener("textColorChanged", (e2, sender) => {
43986
+ if (sender !== this) {
43987
+ this.latestColors = this.getColorsFromLocalStorage();
43988
+ this.setCurrentButtonColor(this.latestColors);
43989
+ this.updatePaletteColor();
43990
+ }
43991
+ });
43889
43992
  }
43890
43993
  bindColorButtonEvents() {
43891
43994
  if (clientType.isMobile) {
@@ -51475,23 +51578,28 @@ ${codeText}
51475
51578
  }
51476
51579
  function resetListStart(editor, brothers, start, options) {
51477
51580
  var _a;
51478
- const groupId = (_a = options == null ? void 0 : options.groupId) != null ? _a : genId();
51479
- brothers.forEach((block) => {
51480
- const oldData = editor.getBlockData(block);
51481
- if (oldData.start !== start || (options == null ? void 0 : options.resetGroupId)) {
51482
- const newData = {
51483
- ...oldData,
51484
- start
51485
- };
51486
- if (options == null ? void 0 : options.resetGroupId) {
51487
- newData.groupId = groupId;
51581
+ editor.doc.beginBatchUpdate();
51582
+ try {
51583
+ const groupId = (_a = options == null ? void 0 : options.groupId) != null ? _a : genId();
51584
+ brothers.forEach((block) => {
51585
+ const oldData = editor.getBlockData(block);
51586
+ if (oldData.start !== start || (options == null ? void 0 : options.resetGroupId)) {
51587
+ const newData = {
51588
+ ...oldData,
51589
+ start
51590
+ };
51591
+ if (options == null ? void 0 : options.resetGroupId) {
51592
+ newData.groupId = groupId;
51593
+ }
51594
+ editor.updateBlockData(block, newData);
51488
51595
  }
51489
- editor.updateBlockData(block, newData);
51490
- }
51491
- if (!oldData.textOnly) {
51492
- start += 1;
51493
- }
51494
- });
51596
+ if (!oldData.textOnly) {
51597
+ start += 1;
51598
+ }
51599
+ });
51600
+ } finally {
51601
+ editor.doc.endBatchUpdate();
51602
+ }
51495
51603
  }
51496
51604
  function resetListStartByBrother(editor, listBrother, start, options) {
51497
51605
  const allBrothers = getListAllBrothers(listBrother, { withSelf: true });
@@ -53110,7 +53218,11 @@ ${codeText}
53110
53218
  handleDrop: handleListDrop,
53111
53219
  notify,
53112
53220
  handleDeleteBlock: (editor, block) => {
53221
+ var _a, _b;
53113
53222
  if (isListBlock(block)) {
53223
+ if ((_b = (_a = editor.doc).applyingOps) == null ? void 0 : _b.call(_a)) {
53224
+ return;
53225
+ }
53114
53226
  const fixStart = new FixStartByWillDeletedList(editor, block);
53115
53227
  setTimeout(() => {
53116
53228
  fixStart.fix();
@@ -53141,15 +53253,15 @@ ${codeText}
53141
53253
  __publicField(this, "id", "ListProvider");
53142
53254
  __publicField(this, "executeInsertCommand", (editor, containerId, blockIndex, command) => {
53143
53255
  if (command.id === "unordered-list") {
53144
- this.insertList(editor, containerId, blockIndex, "unordered");
53256
+ this.insertList(editor, containerId, blockIndex, "unordered", command);
53145
53257
  return true;
53146
53258
  }
53147
53259
  if (command.id === "ordered-list") {
53148
- this.insertList(editor, containerId, blockIndex, "ordered");
53260
+ this.insertList(editor, containerId, blockIndex, "ordered", command);
53149
53261
  return true;
53150
53262
  }
53151
53263
  if (command.id === "check-list") {
53152
- this.insertList(editor, containerId, blockIndex, "unchecked");
53264
+ this.insertList(editor, containerId, blockIndex, "unchecked", command);
53153
53265
  return true;
53154
53266
  }
53155
53267
  return false;
@@ -53232,21 +53344,66 @@ ${codeText}
53232
53344
  });
53233
53345
  }
53234
53346
  }
53235
- insertList(editor, containerId, blockIndex, listType) {
53347
+ insertList(editor, containerId, blockIndex, listType, command) {
53236
53348
  var _a;
53237
- const blockList = editor.getChildContainerData(containerId);
53238
- const block = (_a = editor.findBlockByIndex(containerId, blockIndex)) != null ? _a : editor.getBlockById(blockList[blockList.length - 1].id);
53239
- const convertResult = convertBlockFrom(editor, block, "list", {
53349
+ editor.getChildContainerData(containerId);
53350
+ let sourceIndex = blockIndex;
53351
+ let insertBefore = true;
53352
+ if (((_a = command.source) == null ? void 0 : _a.indexOf("/insert-block-after")) !== -1) {
53353
+ insertBefore = false;
53354
+ if (blockIndex > 0) {
53355
+ sourceIndex = blockIndex - 1;
53356
+ }
53357
+ }
53358
+ const currentBlock = editor.findBlockByIndex(containerId, sourceIndex);
53359
+ if (!currentBlock) {
53360
+ return;
53361
+ }
53362
+ const convertResult = convertBlockFrom(editor, currentBlock, "list", {
53240
53363
  offset: 0,
53241
53364
  data: {
53242
53365
  listType
53243
53366
  }
53244
53367
  });
53245
- if (convertResult) {
53246
- editor.undoManager.runInGroup(() => {
53247
- editor.insertBlock(containerId, blockIndex, convertResult.blockData);
53248
- });
53368
+ const newData = convertResult == null ? void 0 : convertResult.blockData;
53369
+ if (!newData) {
53370
+ return;
53249
53371
  }
53372
+ const oldData = editor.getBlockData(currentBlock);
53373
+ const oldType = getListType(oldData);
53374
+ const newType = getListType(newData);
53375
+ if (oldType === newType) {
53376
+ if (typeof newData.start === "number") {
53377
+ if (typeof oldData.start === "number") {
53378
+ if (insertBefore) {
53379
+ newData.start = oldData.start - 1;
53380
+ } else {
53381
+ newData.start = oldData.start + 1;
53382
+ }
53383
+ } else {
53384
+ if (insertBefore) {
53385
+ newData.start -= 1;
53386
+ } else {
53387
+ newData.start += 1;
53388
+ }
53389
+ }
53390
+ }
53391
+ if (typeof newData.start === "number" && newData.start <= 0) {
53392
+ newData.start = 1;
53393
+ }
53394
+ newData.groupId = oldData.groupId;
53395
+ }
53396
+ newData.text = [];
53397
+ if (oldType === newType) {
53398
+ newData.heading = oldData.heading;
53399
+ } else {
53400
+ delete newData.heading;
53401
+ }
53402
+ editor.undoManager.runInGroup(() => {
53403
+ const newBlock = editor.insertBlock(containerId, blockIndex, newData);
53404
+ const fix = new FixStartByList(editor, newBlock);
53405
+ fix.fix();
53406
+ });
53250
53407
  }
53251
53408
  executeCommand(editor, block, range, command) {
53252
53409
  if (!isTextKindBlock(editor, block)) {
@@ -54589,6 +54746,7 @@ ${codeText}
54589
54746
  }, 50));
54590
54747
  this.editor = editor;
54591
54748
  const popover = editor.options.componentsOptions.popover;
54749
+ const objectToolbar = editor.options.componentsOptions.objectToolbar;
54592
54750
  this.toolbar = new ManualToolbar([], void 0, {
54593
54751
  tooltipId: editor.clientId,
54594
54752
  id: "editor-toolbar",
@@ -54596,7 +54754,8 @@ ${codeText}
54596
54754
  refuseOverflow: true,
54597
54755
  padding: 20,
54598
54756
  showName: clientType.isMobile,
54599
- autoClose: clientType.isMobile ? true : void 0
54757
+ autoClose: clientType.isMobile ? true : void 0,
54758
+ appendTo: (objectToolbar == null ? void 0 : objectToolbar.appendTo) || (popover == null ? void 0 : popover.appendTo)
54600
54759
  });
54601
54760
  this.toolbar.on("click", this.handleButtonClick);
54602
54761
  this.toolbar.on("close", this.handleClose);
@@ -64203,7 +64362,7 @@ $$${mathData.mathjaxText}$$
64203
64362
  const failedLoad = !!block.querySelector(".images > .image-container.error, .images > .image-container.empty ");
64204
64363
  const width = calImageBlockStyleWidth(editor, blockData, parentContainer, failedLoad);
64205
64364
  const height = calBlockHeight(editor, blockData, parentContainer, failedLoad);
64206
- if (width.startsWith("0") && height.startsWith("0")) {
64365
+ if (width.startsWith("0") || height.startsWith("0")) {
64207
64366
  const image = block.querySelector("img");
64208
64367
  if (image) {
64209
64368
  image.onload = () => {
@@ -65116,7 +65275,6 @@ $$${mathData.mathjaxText}$$
65116
65275
  if (insertPos === "before") {
65117
65276
  const beforeBlock = getPrevVisibleBlock(block);
65118
65277
  if (!beforeBlock) {
65119
- assert(logger$1z, isChildContainer(getParentContainer(block)), "block does not in a child container");
65120
65278
  const rect = block.getBoundingClientRect();
65121
65279
  const viewRect2 = this.getViewRect(block);
65122
65280
  return new DOMRect(viewRect2.x, rect.y, viewRect2.width, INDICATOR_SIZE$1);
@@ -67506,6 +67664,7 @@ ${codeText}
67506
67664
  const buttonElement = createElement("button", ["block-button"], null);
67507
67665
  buttonElement.setAttribute(`data-editor-tooltip-${this.editor.clientId}`, i18n$1.t("blockMenu.button.tips"));
67508
67666
  buttonElement.innerHTML = DragIcon;
67667
+ buttonElement.type = "button";
67509
67668
  return buttonElement;
67510
67669
  }
67511
67670
  setButtonType(type) {
@@ -68103,7 +68262,7 @@ ${codeText}
68103
68262
  return false;
68104
68263
  }
68105
68264
  if (isRootContainer(getParentContainer(block))) {
68106
- if (getBlockIndex(block) === 0) {
68265
+ if (getBlockIndex(block) === 0 && isTitleBlock$2(block)) {
68107
68266
  return false;
68108
68267
  }
68109
68268
  }
@@ -81831,6 +81990,9 @@ ${docStr}
81831
81990
  toJSON() {
81832
81991
  return cloneDeep__default.default(this.docObject);
81833
81992
  }
81993
+ applyingOps() {
81994
+ return false;
81995
+ }
81834
81996
  getContainerBlocks(containerId) {
81835
81997
  const blocks = this.docObject.blocks[containerId];
81836
81998
  return blocks;
@@ -83066,12 +83228,7 @@ ${docStr}
83066
83228
  }
83067
83229
  }
83068
83230
  function isTitleBlock$1(block) {
83069
- const prevBlock = getPrevBlock(block);
83070
- if (prevBlock) {
83071
- return false;
83072
- }
83073
- const container = getParentContainer(block);
83074
- return isRootContainer(container);
83231
+ return block.hasAttribute("data-document-title");
83075
83232
  }
83076
83233
  function canShowCollapseButtons(editor, hoverBlock) {
83077
83234
  var _a, _b;
@@ -85576,7 +85733,6 @@ ${docStr}
85576
85733
  });
85577
85734
  setTimeout(() => {
85578
85735
  textarea2.setSelectionRange(0, 0);
85579
- textarea2.focus();
85580
85736
  textarea2.scrollTop = 0;
85581
85737
  textarea2.style.height = `${textarea2.scrollHeight}px`;
85582
85738
  }, 20);
@@ -85587,6 +85743,9 @@ ${docStr}
85587
85743
  assert(logger$n, textarea2 instanceof HTMLTextAreaElement, "Textarea is not HTMLTextAreaElement");
85588
85744
  return textarea2;
85589
85745
  };
85746
+ function focusToCodeEditor(block) {
85747
+ getCodeEditor(block).focus();
85748
+ }
85590
85749
  const logger$m = getLogger("graph-dom/view-select");
85591
85750
  var ViewId = /* @__PURE__ */ ((ViewId2) => {
85592
85751
  ViewId2["Both"] = "both";
@@ -87612,7 +87771,10 @@ ${data2.plantumlText}
87612
87771
  subText: `/${base.graphType}`,
87613
87772
  name: i18n$1.t(`graph.${base.graphType}`),
87614
87773
  execute: (editor, containerId, blockIndex) => {
87615
- editor.insertEmbed(containerId, blockIndex, base.graphType, base.createEmptyEmbedData());
87774
+ const block = editor.insertEmbed(containerId, blockIndex, base.graphType, base.createEmptyEmbedData());
87775
+ setTimeout(() => {
87776
+ focusToCodeEditor(block);
87777
+ });
87616
87778
  }
87617
87779
  }];
87618
87780
  };
@@ -90172,9 +90334,6 @@ ${data2.plantumlText}
90172
90334
  super.destroy();
90173
90335
  }
90174
90336
  }
90175
- const ErrCode = {
90176
- ANALYZER_UNKNOWN_URL: "analyzer cannot recognize this url"
90177
- };
90178
90337
  class FigmaAnalyzer {
90179
90338
  constructor() {
90180
90339
  __publicField(this, "regex", /https:\/\/([\w.-]+\.)?figma.com\/.*$/i);
@@ -90340,10 +90499,17 @@ ${data2.plantumlText}
90340
90499
  return ret;
90341
90500
  }
90342
90501
  }
90343
- throw new Error(ErrCode.ANALYZER_UNKNOWN_URL);
90502
+ return {
90503
+ providerName: "unknown",
90504
+ type: "iframe",
90505
+ url
90506
+ };
90344
90507
  }
90345
90508
  }
90346
90509
  const urlAnalyzer = new URLAnalyzer();
90510
+ const ErrCode = {
90511
+ ANALYZER_UNKNOWN_URL: "analyzer cannot recognize this url"
90512
+ };
90347
90513
  const getCommandItems = () => [
90348
90514
  {
90349
90515
  name: i18n$1.t("webpage.bilibili"),
@@ -93841,8 +94007,23 @@ ${JSON.stringify(error2, null, 2)}`);
93841
94007
  this.id = id;
93842
94008
  }
93843
94009
  getCommand(editor) {
94010
+ var _a;
93844
94011
  const commands = editor.editorCommandProviders.getCommands(editor.selection.range);
93845
- return commands.find((c) => c.id === this.id);
94012
+ const command = commands.find((c) => c.id === this.id);
94013
+ if (command) {
94014
+ return command;
94015
+ }
94016
+ const moreCommand = commands.find((c) => c.id === "text/more");
94017
+ if (moreCommand) {
94018
+ const ret = (_a = moreCommand.children) == null ? void 0 : _a.find((c) => c.id === this.id);
94019
+ if (ret) {
94020
+ return {
94021
+ ...moreCommand,
94022
+ ...ret
94023
+ };
94024
+ }
94025
+ }
94026
+ return void 0;
93846
94027
  }
93847
94028
  onClick(editor) {
93848
94029
  const command = this.getCommand(editor);
@@ -93891,13 +94072,13 @@ ${JSON.stringify(error2, null, 2)}`);
93891
94072
  }
93892
94073
  class SuperscriptItem extends FontStyleBaseItem {
93893
94074
  constructor() {
93894
- super(i18n$1.t("commands.superscript"), "text/style-superscript");
94075
+ super(i18n$1.t("commands.superscript"), "text/style-super");
93895
94076
  __publicField(this, "icon", SuperscriptIcon);
93896
94077
  }
93897
94078
  }
93898
94079
  class SubscriptItem extends FontStyleBaseItem {
93899
94080
  constructor() {
93900
- super(i18n$1.t("commands.subscript"), "text/style-subscript");
94081
+ super(i18n$1.t("commands.subscript"), "text/style-sub");
93901
94082
  __publicField(this, "icon", SubscriptIcon);
93902
94083
  }
93903
94084
  }
@@ -94055,9 +94236,11 @@ ${JSON.stringify(error2, null, 2)}`);
94055
94236
  Heading3Icon,
94056
94237
  Heading4Icon,
94057
94238
  Heading5Icon,
94058
- Heading6Icon
94239
+ Heading6Icon,
94240
+ Heading7Icon,
94241
+ Heading8Icon
94059
94242
  ];
94060
- for (let i = 1; i <= 6; i++) {
94243
+ for (let i = 1; i <= 8; i++) {
94061
94244
  this.children.push({
94062
94245
  name: i18n$1.t("commands.heading", { name: `${i}` }),
94063
94246
  id: `heading-${i}`,
@@ -94229,6 +94412,8 @@ ${JSON.stringify(error2, null, 2)}`);
94229
94412
  __publicField(this, "manualShowChildren", true);
94230
94413
  __publicField(this, "childrenPlacement", "bottom-start");
94231
94414
  __publicField(this, "children", []);
94415
+ __publicField(this, "allChildren", []);
94416
+ this.editor = editor;
94232
94417
  const provider = new InsertMenuProvider(editor);
94233
94418
  const startBlock = editor.getBlockById(editor.selection.range.start.blockId);
94234
94419
  const container = getParentContainer(startBlock);
@@ -94238,6 +94423,32 @@ ${JSON.stringify(error2, null, 2)}`);
94238
94423
  commands = commands.slice(index2);
94239
94424
  }
94240
94425
  this.children = commands;
94426
+ this.allChildren = commands;
94427
+ }
94428
+ beforePopup(subBar) {
94429
+ const focusBlock = this.editor.selection.focusedBlock;
94430
+ if (focusBlock.closest('[data-block-type="callout"]')) {
94431
+ const children = this.allChildren.filter((c) => {
94432
+ const textOnlyCommands = [
94433
+ "insert-emoji",
94434
+ "insert-link",
94435
+ "DateBoxCommandProvider",
94436
+ "insert-status",
94437
+ "insert-math",
94438
+ "insert-known-link",
94439
+ "insert-task-link"
94440
+ ];
94441
+ if (textOnlyCommands.includes(c.id)) {
94442
+ return true;
94443
+ }
94444
+ return false;
94445
+ });
94446
+ this.children = children;
94447
+ subBar.updateItems(this.children);
94448
+ } else {
94449
+ this.children = this.allChildren;
94450
+ subBar.updateItems(this.children);
94451
+ }
94241
94452
  }
94242
94453
  onClick(editor, item, commandBar2) {
94243
94454
  const provider = new InsertMenuProvider(editor);
@@ -94292,6 +94503,8 @@ ${JSON.stringify(error2, null, 2)}`);
94292
94503
  event.stopPropagation();
94293
94504
  });
94294
94505
  this.provider = new ColorStyleProvider(editor);
94506
+ this.latestColors = this.getColorsFromLocalStorage();
94507
+ this.setCurrentButtonColor(this.latestColors);
94295
94508
  this.addListener("onClick", this.handleChangeColor);
94296
94509
  this.element.addEventListener("mousedown", this.handleMousedown);
94297
94510
  }
@@ -94459,7 +94672,7 @@ ${JSON.stringify(error2, null, 2)}`);
94459
94672
  async onClick(editor, item) {
94460
94673
  const block = editor.getBlockById(editor.selection.range.start.blockId);
94461
94674
  const container = editor.getParentContainer(block);
94462
- const index2 = editor.getBlockIndex(block);
94675
+ let index2 = editor.getBlockIndex(block);
94463
94676
  const file2 = await selectFile("*");
94464
94677
  if (!file2) {
94465
94678
  return;
@@ -94477,7 +94690,14 @@ ${JSON.stringify(error2, null, 2)}`);
94477
94690
  creator: editor.doc.getUser().displayName,
94478
94691
  previewType: FilePreviewType.Card
94479
94692
  };
94480
- editor.insertEmbed(getContainerId(container), index2 + 1, "office", data2);
94693
+ if (!isEmptyTextBlock(editor, block)) {
94694
+ index2 += 1;
94695
+ }
94696
+ const embedBlock = editor.insertEmbed(getContainerId(container), index2, "office", data2);
94697
+ const nextBlock = getNextBlock(embedBlock);
94698
+ if (nextBlock && isTextKindBlock(editor, nextBlock)) {
94699
+ editor.selection.selectBlock(nextBlock, 0);
94700
+ }
94481
94701
  }
94482
94702
  }
94483
94703
  class InsertMentionItem {
@@ -94640,6 +94860,9 @@ ${JSON.stringify(error2, null, 2)}`);
94640
94860
  }
94641
94861
  const parent = findParent(child, id);
94642
94862
  if (parent) {
94863
+ if (!parent.onClick) {
94864
+ return item2;
94865
+ }
94643
94866
  return parent;
94644
94867
  }
94645
94868
  }
@@ -94671,6 +94894,12 @@ ${JSON.stringify(error2, null, 2)}`);
94671
94894
  tooltipId: editor.clientId,
94672
94895
  id: "main-toolbar"
94673
94896
  });
94897
+ this.toolbar.addListener("closing", () => {
94898
+ setTimeout(() => {
94899
+ editor.focus();
94900
+ }, 100);
94901
+ return true;
94902
+ });
94674
94903
  this.toolbar.addListener("click", this.handleClick);
94675
94904
  this.editor.addListener("selectionChanged", this.handleSelectionChanged);
94676
94905
  this.updateState();
@@ -94749,6 +94978,294 @@ ${JSON.stringify(error2, null, 2)}`);
94749
94978
  }
94750
94979
  });
94751
94980
  }
94981
+ const CkeImageConverter = {
94982
+ filter: (node) => {
94983
+ if (node.nodeName !== "IMG") {
94984
+ return false;
94985
+ }
94986
+ const elem = node;
94987
+ const refId = elem.getAttribute("data-ref-id");
94988
+ const refType = elem.getAttribute("data-ref-type");
94989
+ const uuid = elem.getAttribute("data-uuid");
94990
+ return Boolean(refType === "task" && refId && uuid);
94991
+ },
94992
+ replacement: (content, node) => {
94993
+ const refType = node.getAttribute("data-ref-type");
94994
+ const refId = node.getAttribute("data-ref-id");
94995
+ const uuid = node.getAttribute("data-uuid");
94996
+ const src = `ones-file:${refType}/${refId}/${uuid}`;
94997
+ return `![${refType}](${src})`;
94998
+ }
94999
+ };
95000
+ const ckeHtmlConverters = /* @__PURE__ */ new Map();
95001
+ function registerCKEHtmlConvert(name, converter) {
95002
+ if (ckeHtmlConverters.has(name)) {
95003
+ return;
95004
+ }
95005
+ ckeHtmlConverters.set(name, converter);
95006
+ turndownService.use((ts) => {
95007
+ ts.addRule(name, converter);
95008
+ });
95009
+ }
95010
+ function getTurndownRootElement(node) {
95011
+ let parent = node;
95012
+ while (parent) {
95013
+ if (parent instanceof HTMLElement && parent.tagName === "BODY") {
95014
+ return parent;
95015
+ }
95016
+ if (!parent.parentNode) {
95017
+ return parent;
95018
+ }
95019
+ parent = parent.parentNode;
95020
+ }
95021
+ return node;
95022
+ }
95023
+ function patchForEmptyBlock(key, node, className) {
95024
+ const root2 = getTurndownRootElement(node);
95025
+ if (root2 && root2 instanceof HTMLElement) {
95026
+ const attributeKey = `data-${key}-processed`;
95027
+ if (!root2.getAttribute(attributeKey)) {
95028
+ root2.setAttribute(attributeKey, "true");
95029
+ const elements = root2.querySelectorAll(className);
95030
+ elements.forEach((elem) => {
95031
+ var _a;
95032
+ const text2 = (_a = elem.textContent) == null ? void 0 : _a.trim();
95033
+ if (!text2) {
95034
+ elem.innerText = "--temp-data--";
95035
+ }
95036
+ });
95037
+ }
95038
+ }
95039
+ }
95040
+ const CkeCommentConverter = {
95041
+ filter: (node) => {
95042
+ if (node.nodeName === "SPAN") {
95043
+ const span = node;
95044
+ const ref = span.getAttribute("data-annotate-ref");
95045
+ return Boolean(ref);
95046
+ }
95047
+ return false;
95048
+ },
95049
+ replacement: (content, node) => {
95050
+ var _a;
95051
+ const span = node;
95052
+ const ref = span.getAttribute("data-annotate-ref");
95053
+ const text2 = (_a = span.textContent) != null ? _a : "";
95054
+ return `[${text2}](comment://${ref})`;
95055
+ }
95056
+ };
95057
+ function processCkeCommentsLink(doc2) {
95058
+ const containers = doc2.blocks;
95059
+ Object.values(containers).forEach((blocks) => {
95060
+ blocks.forEach((block) => {
95061
+ const text2 = block.text;
95062
+ if (text2) {
95063
+ text2.forEach((op) => {
95064
+ if (op.attributes) {
95065
+ const attributes = op.attributes;
95066
+ const link2 = attributes.link;
95067
+ if (link2 == null ? void 0 : link2.startsWith("comment://")) {
95068
+ delete attributes.link;
95069
+ const commentId = link2.replace("comment://", "");
95070
+ const key = `comment-${commentId.toLocaleLowerCase()}`;
95071
+ attributes[key] = commentId;
95072
+ }
95073
+ }
95074
+ });
95075
+ }
95076
+ });
95077
+ });
95078
+ }
95079
+ const CkeMentionConverter = {
95080
+ filter: (node) => {
95081
+ patchForEmptyBlock("mention", node, ".ones-at-user-block");
95082
+ if (node.nodeName === "SPAN") {
95083
+ const span = node;
95084
+ if (hasClass(span, "ones-at-user-block")) {
95085
+ const name = span.getAttribute("data-default-name");
95086
+ const refId = span.getAttribute("data-ref-id");
95087
+ return Boolean(name) && Boolean(refId);
95088
+ }
95089
+ }
95090
+ return false;
95091
+ },
95092
+ replacement: (content, node) => {
95093
+ const span = node;
95094
+ const name = span.getAttribute("data-default-name") || "";
95095
+ const refId = span.getAttribute("data-ref-id") || "";
95096
+ if (name && refId) {
95097
+ const box = {
95098
+ id: genId(),
95099
+ type: "mention",
95100
+ box: true,
95101
+ created: Date.now(),
95102
+ iconUrl: "",
95103
+ text: name,
95104
+ mentionId: refId
95105
+ };
95106
+ const text2 = [
95107
+ {
95108
+ insert: " ",
95109
+ attributes: box
95110
+ }
95111
+ ];
95112
+ const obj = {
95113
+ text: text2
95114
+ };
95115
+ const base64 = toBase64URL(JSON.stringify(obj));
95116
+ return `[[${base64}]]`;
95117
+ }
95118
+ return name;
95119
+ }
95120
+ };
95121
+ function convertMentionToCkeMention(editor, boxData, doc2, type) {
95122
+ const data2 = boxData;
95123
+ if (type === "html") {
95124
+ return `<ones-at-user data-ref-name="${data2.text}" data-ref-id="${data2.mentionId}" data-default-name="${data2.text}" class="ones-at-user-block" data-viewer="1"><span>@${data2.text}</span></ones-at-user>`;
95125
+ }
95126
+ return `@${data2.text}`;
95127
+ }
95128
+ function patchMentionConverter(editor) {
95129
+ const mentionBox = editor.editorBoxes.getBoxClass("mention");
95130
+ if (mentionBox) {
95131
+ const oldConvertTo = mentionBox.convertTo;
95132
+ if (oldConvertTo !== convertMentionToCkeMention) {
95133
+ mentionBox.convertTo = convertMentionToCkeMention;
95134
+ }
95135
+ }
95136
+ }
95137
+ function processLinks(doc2) {
95138
+ const containers = doc2.blocks;
95139
+ Object.values(containers).forEach((blocks) => {
95140
+ blocks.forEach((block) => {
95141
+ if (block.text) {
95142
+ const text2 = block.text;
95143
+ text2.forEach((op) => {
95144
+ const attributes = op.attributes;
95145
+ if (attributes) {
95146
+ attributes.link;
95147
+ }
95148
+ });
95149
+ }
95150
+ });
95151
+ });
95152
+ }
95153
+ const CkeMarkdownConverter = {
95154
+ filter: (node) => {
95155
+ if (node.nodeName !== "DIV") {
95156
+ return false;
95157
+ }
95158
+ const div = node;
95159
+ return hasClass(div, "ones-marked-card");
95160
+ },
95161
+ replacement: (content, node) => {
95162
+ const textToCodeBlock2 = (text2, language) => {
95163
+ const codeBlocks = text2.split("\n").map((line) => {
95164
+ const block = {
95165
+ type: "text",
95166
+ id: genId(),
95167
+ text: createRichText(line)
95168
+ };
95169
+ return block;
95170
+ });
95171
+ const containerId = genId();
95172
+ const doc22 = {
95173
+ blocks: {
95174
+ root: [
95175
+ {
95176
+ id: genId(),
95177
+ type: "code",
95178
+ language,
95179
+ children: [containerId]
95180
+ }
95181
+ ],
95182
+ [containerId]: codeBlocks
95183
+ },
95184
+ meta: {},
95185
+ comments: {}
95186
+ };
95187
+ return toBase64URL(JSON.stringify(doc22));
95188
+ };
95189
+ const nodeToCodeBlock2 = (node2, lang) => {
95190
+ const text2 = node2.textContent || "";
95191
+ return textToCodeBlock2(text2, lang);
95192
+ };
95193
+ const doc2 = nodeToCodeBlock2(node, "markdown");
95194
+ const fence = "```";
95195
+ return "\n\n" + fence + "\n" + doc2 + "\n" + fence + "\n\n";
95196
+ }
95197
+ };
95198
+ registerCKEHtmlConvert("image", CkeImageConverter);
95199
+ registerCKEHtmlConvert("comment", CkeCommentConverter);
95200
+ registerCKEHtmlConvert("mention", CkeMentionConverter);
95201
+ registerCKEHtmlConvert("markdown", CkeMarkdownConverter);
95202
+ function ckeHtml2Doc(html) {
95203
+ const doc2 = htmlToDoc(html) || createEmptyDoc$1();
95204
+ processCkeCommentsLink(doc2);
95205
+ processLinks(doc2);
95206
+ return doc2;
95207
+ }
95208
+ function injectDocToCkeHtmlFragment(htmlFragment, doc2, text2) {
95209
+ const meta = `<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${toBase64URL(
95210
+ JSON.stringify(doc2)
95211
+ )}::ones-editor-doc" />`;
95212
+ let textMeta = "";
95213
+ if (text2) {
95214
+ textMeta = `<meta name="ones-editor-text" content="${toBase64URL(text2)}" />`;
95215
+ }
95216
+ const html = `<!doctype html><html><head>${meta}${textMeta}</head><body>${htmlFragment}</body></html>`;
95217
+ return html;
95218
+ }
95219
+ function editorToCKEHtml(editor) {
95220
+ patchMentionConverter(editor);
95221
+ const docObject = editor.doc.toJSON();
95222
+ if (isEmptyDoc(docObject)) {
95223
+ return "";
95224
+ }
95225
+ let html = docToHtmlFragment(editor, docObject);
95226
+ const text2 = docToText(editor, docObject);
95227
+ html = injectDocToCkeHtmlFragment(html, docObject, text2);
95228
+ return html;
95229
+ }
95230
+ function combineDoc(doc1, doc2) {
95231
+ if (isEmptyDoc(doc1)) {
95232
+ return doc2;
95233
+ }
95234
+ if (isEmptyDoc(doc2)) {
95235
+ return doc1;
95236
+ }
95237
+ const splitterDoc = createEmptyDoc$1("", {
95238
+ firstLineAsTitle: false
95239
+ });
95240
+ return mergeDocs([doc1, splitterDoc, doc2]);
95241
+ }
95242
+ function mergeHTMLBodiesOnly(htmlA, htmlB) {
95243
+ const parser = new DOMParser();
95244
+ const docA = parser.parseFromString(htmlA, "text/html");
95245
+ const docB = parser.parseFromString(htmlB, "text/html");
95246
+ const mergedDoc = document.implementation.createHTMLDocument("Merged");
95247
+ const bodyA = docA.body;
95248
+ const bodyB = docB.body;
95249
+ const mergedBody = mergedDoc.body;
95250
+ Array.from(bodyA.childNodes).forEach((node) => {
95251
+ mergedBody.appendChild(mergedDoc.importNode(node, true));
95252
+ });
95253
+ Array.from(bodyB.childNodes).forEach((node) => {
95254
+ mergedBody.appendChild(mergedDoc.importNode(node, true));
95255
+ });
95256
+ return mergedBody.innerHTML;
95257
+ }
95258
+ function combineCkeHtml(html1, html2) {
95259
+ const doc1 = ckeHtml2Doc(html1);
95260
+ const doc2 = ckeHtml2Doc(html2);
95261
+ const newDoc = combineDoc(doc1, doc2);
95262
+ const newHtml = mergeHTMLBodiesOnly(html1, html2);
95263
+ const ret = injectDocToCkeHtmlFragment(newHtml, newDoc);
95264
+ return ret;
95265
+ }
95266
+ function combineRichTextValue(value1, value2) {
95267
+ return combineCkeHtml(value1, value2);
95268
+ }
94752
95269
  const logger = getLogger("create-editor");
94753
95270
  function getHooks(options, local) {
94754
95271
  var _a;
@@ -95007,7 +95524,7 @@ ${JSON.stringify(error2, null, 2)}`);
95007
95524
  }
95008
95525
  }
95009
95526
  });
95010
- editor.version = "2.9.8-beta.3";
95527
+ editor.version = "2.9.8-beta.30";
95011
95528
  return editor;
95012
95529
  }
95013
95530
  function isDoc(doc2) {
@@ -95139,7 +95656,7 @@ ${JSON.stringify(error2, null, 2)}`);
95139
95656
  OnesEditorDropTarget.register(editor);
95140
95657
  OnesEditorTocProvider.register(editor);
95141
95658
  OnesEditorExclusiveBlock.register(editor);
95142
- editor.version = "2.9.8-beta.3";
95659
+ editor.version = "2.9.8-beta.30";
95143
95660
  return editor;
95144
95661
  }
95145
95662
  async function showDocVersions(editor, options, serverUrl) {
@@ -141241,12 +141758,15 @@ ${JSON.stringify(error2, null, 2)}`);
141241
141758
  exports2.blockToText = blockToText;
141242
141759
  exports2.blocksToDoc = blocksToDoc;
141243
141760
  exports2.changeButtonName = changeButtonName;
141761
+ exports2.ckeHtml2Doc = ckeHtml2Doc;
141244
141762
  exports2.clearAllSelection = clearAllSelection;
141245
141763
  exports2.clientType = clientType;
141246
141764
  exports2.cloneBlock = cloneBlock;
141247
141765
  exports2.cloneChildContainer = cloneChildContainer;
141248
141766
  exports2.cloneDoc = cloneDoc;
141249
141767
  exports2.cloneText = cloneText;
141768
+ exports2.combineCkeHtml = combineCkeHtml;
141769
+ exports2.combineRichTextValue = combineRichTextValue;
141250
141770
  exports2.commentToShareDbComment = commentToShareDbComment;
141251
141771
  exports2.compareElement = compareElement;
141252
141772
  exports2.comparePosition = comparePosition;
@@ -141386,6 +141906,7 @@ ${JSON.stringify(error2, null, 2)}`);
141386
141906
  exports2.editorRunOnce = editorRunOnce;
141387
141907
  exports2.editorScrollIntoView = editorScrollIntoView;
141388
141908
  exports2.editorSelectAll = editorSelectAll;
141909
+ exports2.editorSelectAllBlocks = editorSelectAllBlocks;
141389
141910
  exports2.editorSelectContainer = editorSelectContainer;
141390
141911
  exports2.editorSelectDown = editorSelectDown;
141391
141912
  exports2.editorSelectEnd = editorSelectEnd;
@@ -141402,6 +141923,7 @@ ${JSON.stringify(error2, null, 2)}`);
141402
141923
  exports2.editorSelectWordLeft = editorSelectWordLeft;
141403
141924
  exports2.editorSetTextColor = editorSetTextColor;
141404
141925
  exports2.editorShowFindDialog = editorShowFindDialog;
141926
+ exports2.editorToCKEHtml = editorToCKEHtml;
141405
141927
  exports2.editorToDocx = editorToDocx;
141406
141928
  exports2.editorUpdateBlockData = editorUpdateBlockData;
141407
141929
  exports2.editorUpdateCompositionText = editorUpdateCompositionText;
@@ -141568,6 +142090,7 @@ ${JSON.stringify(error2, null, 2)}`);
141568
142090
  exports2.i18n = i18n$1;
141569
142091
  exports2.includeBigTable = includeBigTable;
141570
142092
  exports2.injectBlockOptions = injectBlockOptions;
142093
+ exports2.injectDocToCkeHtmlFragment = injectDocToCkeHtmlFragment;
141571
142094
  exports2.injectDocToHtmlFragment = injectDocToHtmlFragment;
141572
142095
  exports2.injectSource = injectSource;
141573
142096
  exports2.injectStyle = injectStyle;