@ones-editor/editor 2.9.8-beta.25 → 2.9.8-beta.27

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
@@ -26431,6 +26431,10 @@ var __publicField = (obj, key, value) => {
26431
26431
  if (isNodeRemoved(this.editor.rootElement)) {
26432
26432
  return;
26433
26433
  }
26434
+ const rootRect = this.editor.rootElement.getBoundingClientRect();
26435
+ if (rootRect.width === 0 || rootRect.height === 0) {
26436
+ return;
26437
+ }
26434
26438
  const cursor = this.caretElem;
26435
26439
  if (this.hasCaret()) {
26436
26440
  cursor.style.display = "";
@@ -26439,42 +26443,46 @@ var __publicField = (obj, key, value) => {
26439
26443
  moveInputToScreenCenter(this.editor);
26440
26444
  return;
26441
26445
  }
26442
- const { range } = this.editor.selection;
26443
- assert(logger$3S, range.isCollapsed, "range is not collapsed");
26444
- const pos = range.start;
26445
- assert(logger$3S, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26446
- const block = this.editor.getBlockById(pos.blockId);
26447
- assert(logger$3S, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26448
- let rect;
26449
- const compositionSpan = block.querySelector("span.inputting-insertion");
26450
- if (compositionSpan) {
26451
- rect = getLastClientRect(compositionSpan);
26452
- rect = new DOMRect(rect.right, rect.top, 1, rect.height);
26453
- } else {
26454
- rect = getTextCaretRect(block, pos);
26455
- }
26456
- const editorRect = this.editor.contentElement.getBoundingClientRect();
26457
- const x = rect.left - editorRect.left;
26458
- const y = rect.top - editorRect.top;
26459
- cursor.style.left = `${x}px`;
26460
- cursor.style.top = `${y}px`;
26461
- cursor.style.height = `${rect.height}px`;
26462
- const input2 = this.editor.input.inputElement;
26463
- input2.style.left = `${x}px`;
26464
- input2.style.top = `${y + rect.height - 24}px`;
26465
- if (clientType.isMobileSafari) {
26466
- input2.style.left = `${x - 4}px`;
26467
- input2.style.height = `${rect.height}px`;
26468
- }
26469
- const scrollContainer = getScrollContainer$1(block, { horizontal: true });
26470
- const scrollRect = scrollContainer.getBoundingClientRect();
26471
- const scrollLeft = scrollRect.left - editorRect.left;
26472
- const scrollRight = scrollLeft + scrollRect.width;
26473
- if (x < scrollLeft || x > scrollRight) {
26474
- moveInputToScreenCenter(this.editor);
26475
- cursor.style.display = "none";
26476
- } else {
26477
- cursor.style.display = "";
26446
+ try {
26447
+ const { range } = this.editor.selection;
26448
+ assert(logger$3S, range.isCollapsed, "range is not collapsed");
26449
+ const pos = range.start;
26450
+ assert(logger$3S, pos instanceof EditorSimpleBlockPosition, "only simple block position can has caret");
26451
+ const block = this.editor.getBlockById(pos.blockId);
26452
+ assert(logger$3S, isTextKindBlock(this.editor, block), "only text kind block can has caret");
26453
+ let rect;
26454
+ const compositionSpan = block.querySelector("span.inputting-insertion");
26455
+ if (compositionSpan) {
26456
+ rect = getLastClientRect(compositionSpan);
26457
+ rect = new DOMRect(rect.right, rect.top, 1, rect.height);
26458
+ } else {
26459
+ rect = getTextCaretRect(block, pos);
26460
+ }
26461
+ const editorRect = this.editor.contentElement.getBoundingClientRect();
26462
+ const x = rect.left - editorRect.left;
26463
+ const y = rect.top - editorRect.top;
26464
+ cursor.style.left = `${x}px`;
26465
+ cursor.style.top = `${y}px`;
26466
+ cursor.style.height = `${rect.height}px`;
26467
+ const input2 = this.editor.input.inputElement;
26468
+ input2.style.left = `${x}px`;
26469
+ input2.style.top = `${y + rect.height - 24}px`;
26470
+ if (clientType.isMobileSafari) {
26471
+ input2.style.left = `${x - 4}px`;
26472
+ input2.style.height = `${rect.height}px`;
26473
+ }
26474
+ const scrollContainer = getScrollContainer$1(block, { horizontal: true });
26475
+ const scrollRect = scrollContainer.getBoundingClientRect();
26476
+ const scrollLeft = scrollRect.left - editorRect.left;
26477
+ const scrollRight = scrollLeft + scrollRect.width;
26478
+ if (x < scrollLeft || x > scrollRight) {
26479
+ moveInputToScreenCenter(this.editor);
26480
+ cursor.style.display = "none";
26481
+ } else {
26482
+ cursor.style.display = "";
26483
+ }
26484
+ } catch (err) {
26485
+ logger$3S.error(err);
26478
26486
  }
26479
26487
  }
26480
26488
  }
@@ -85717,7 +85725,6 @@ ${docStr}
85717
85725
  });
85718
85726
  setTimeout(() => {
85719
85727
  textarea2.setSelectionRange(0, 0);
85720
- textarea2.focus();
85721
85728
  textarea2.scrollTop = 0;
85722
85729
  textarea2.style.height = `${textarea2.scrollHeight}px`;
85723
85730
  }, 20);
@@ -85728,6 +85735,9 @@ ${docStr}
85728
85735
  assert(logger$n, textarea2 instanceof HTMLTextAreaElement, "Textarea is not HTMLTextAreaElement");
85729
85736
  return textarea2;
85730
85737
  };
85738
+ function focusToCodeEditor(block) {
85739
+ getCodeEditor(block).focus();
85740
+ }
85731
85741
  const logger$m = getLogger("graph-dom/view-select");
85732
85742
  var ViewId = /* @__PURE__ */ ((ViewId2) => {
85733
85743
  ViewId2["Both"] = "both";
@@ -87753,7 +87763,10 @@ ${data2.plantumlText}
87753
87763
  subText: `/${base.graphType}`,
87754
87764
  name: i18n$1.t(`graph.${base.graphType}`),
87755
87765
  execute: (editor, containerId, blockIndex) => {
87756
- editor.insertEmbed(containerId, blockIndex, base.graphType, base.createEmptyEmbedData());
87766
+ const block = editor.insertEmbed(containerId, blockIndex, base.graphType, base.createEmptyEmbedData());
87767
+ setTimeout(() => {
87768
+ focusToCodeEditor(block);
87769
+ });
87757
87770
  }
87758
87771
  }];
87759
87772
  };
@@ -90313,9 +90326,6 @@ ${data2.plantumlText}
90313
90326
  super.destroy();
90314
90327
  }
90315
90328
  }
90316
- const ErrCode = {
90317
- ANALYZER_UNKNOWN_URL: "analyzer cannot recognize this url"
90318
- };
90319
90329
  class FigmaAnalyzer {
90320
90330
  constructor() {
90321
90331
  __publicField(this, "regex", /https:\/\/([\w.-]+\.)?figma.com\/.*$/i);
@@ -90481,10 +90491,17 @@ ${data2.plantumlText}
90481
90491
  return ret;
90482
90492
  }
90483
90493
  }
90484
- throw new Error(ErrCode.ANALYZER_UNKNOWN_URL);
90494
+ return {
90495
+ providerName: "unknown",
90496
+ type: "iframe",
90497
+ url
90498
+ };
90485
90499
  }
90486
90500
  }
90487
90501
  const urlAnalyzer = new URLAnalyzer();
90502
+ const ErrCode = {
90503
+ ANALYZER_UNKNOWN_URL: "analyzer cannot recognize this url"
90504
+ };
90488
90505
  const getCommandItems = () => [
90489
90506
  {
90490
90507
  name: i18n$1.t("webpage.bilibili"),
@@ -94387,6 +94404,8 @@ ${JSON.stringify(error2, null, 2)}`);
94387
94404
  __publicField(this, "manualShowChildren", true);
94388
94405
  __publicField(this, "childrenPlacement", "bottom-start");
94389
94406
  __publicField(this, "children", []);
94407
+ __publicField(this, "allChildren", []);
94408
+ this.editor = editor;
94390
94409
  const provider = new InsertMenuProvider(editor);
94391
94410
  const startBlock = editor.getBlockById(editor.selection.range.start.blockId);
94392
94411
  const container = getParentContainer(startBlock);
@@ -94396,6 +94415,31 @@ ${JSON.stringify(error2, null, 2)}`);
94396
94415
  commands = commands.slice(index2);
94397
94416
  }
94398
94417
  this.children = commands;
94418
+ this.allChildren = commands;
94419
+ }
94420
+ beforePopup(subBar) {
94421
+ const focusBlock = this.editor.selection.focusedBlock;
94422
+ if (focusBlock.closest('[data-block-type="callout"]')) {
94423
+ const children = this.allChildren.filter((c) => {
94424
+ const textOnlyCommands = [
94425
+ "insert-emoji",
94426
+ "insert-link",
94427
+ "insert-date",
94428
+ "insert-status",
94429
+ "insert-math",
94430
+ "insert-task"
94431
+ ];
94432
+ if (textOnlyCommands.includes(c.id)) {
94433
+ return true;
94434
+ }
94435
+ return false;
94436
+ });
94437
+ this.children = children;
94438
+ subBar.updateItems(this.children);
94439
+ } else {
94440
+ this.children = this.allChildren;
94441
+ subBar.updateItems(this.children);
94442
+ }
94399
94443
  }
94400
94444
  onClick(editor, item, commandBar2) {
94401
94445
  const provider = new InsertMenuProvider(editor);
@@ -94807,6 +94851,9 @@ ${JSON.stringify(error2, null, 2)}`);
94807
94851
  }
94808
94852
  const parent = findParent(child, id);
94809
94853
  if (parent) {
94854
+ if (!parent.onClick) {
94855
+ return item2;
94856
+ }
94810
94857
  return parent;
94811
94858
  }
94812
94859
  }
@@ -95468,7 +95515,7 @@ ${JSON.stringify(error2, null, 2)}`);
95468
95515
  }
95469
95516
  }
95470
95517
  });
95471
- editor.version = "2.9.8-beta.25";
95518
+ editor.version = "2.9.8-beta.27";
95472
95519
  return editor;
95473
95520
  }
95474
95521
  function isDoc(doc2) {
@@ -95600,7 +95647,7 @@ ${JSON.stringify(error2, null, 2)}`);
95600
95647
  OnesEditorDropTarget.register(editor);
95601
95648
  OnesEditorTocProvider.register(editor);
95602
95649
  OnesEditorExclusiveBlock.register(editor);
95603
- editor.version = "2.9.8-beta.25";
95650
+ editor.version = "2.9.8-beta.27";
95604
95651
  return editor;
95605
95652
  }
95606
95653
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.9.8-beta.25",
3
+ "version": "2.9.8-beta.27",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {