@ones-editor/editor 2.8.40 → 2.8.42

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
@@ -52634,59 +52634,57 @@ ${codeText}
52634
52634
  async handleBeforePasteDoc(editor, doc2) {
52635
52635
  const groupIds = /* @__PURE__ */ new Map();
52636
52636
  const startIds = /* @__PURE__ */ new Map();
52637
- Object.values(doc2.blocks).forEach((blocks) => {
52638
- blocks.forEach((block, index2) => {
52639
- if (block.type === "list") {
52640
- if (index2 === 0) {
52641
- const startBlock = editor.selection.startBlock;
52642
- if (isListBlock(startBlock)) {
52643
- const { start, groupId: groupId2, level, type } = getListBlockProperties(startBlock);
52644
- const newType = getListType(block);
52637
+ doc2.blocks.root.forEach((block, index2) => {
52638
+ if (block.type === "list") {
52639
+ if (index2 === 0) {
52640
+ const startBlock = editor.selection.startBlock;
52641
+ if (isListBlock(startBlock)) {
52642
+ const { start, groupId: groupId2, level, type } = getListBlockProperties(startBlock);
52643
+ const newType = getListType(block);
52644
+ const oldGroupId = block.groupId;
52645
+ block.groupId = groupId2;
52646
+ block.start = start;
52647
+ block.level = level;
52648
+ const data2 = makeListBlockTypeData(type);
52649
+ Object.assign(block, data2);
52650
+ if (level === block.level && type === newType) {
52651
+ groupIds.set(oldGroupId, groupId2);
52652
+ startIds.set(groupId2, start);
52653
+ }
52654
+ this.fixStartByList = new FixStartByWillDeletedList(editor, startBlock);
52655
+ return;
52656
+ }
52657
+ const preBlock = getPrevBlock(startBlock);
52658
+ if (preBlock && isListBlock(preBlock)) {
52659
+ const { start, groupId: groupId2, level, type } = getListBlockProperties(preBlock);
52660
+ const newType = getListType(block);
52661
+ if (level === block.level && type === newType) {
52645
52662
  const oldGroupId = block.groupId;
52646
52663
  block.groupId = groupId2;
52647
- block.start = start;
52664
+ block.start = start + 1;
52648
52665
  block.level = level;
52649
- const data2 = makeListBlockTypeData(type);
52650
- Object.assign(block, data2);
52651
- if (level === block.level && type === newType) {
52652
- groupIds.set(oldGroupId, groupId2);
52653
- startIds.set(groupId2, start);
52654
- }
52655
- this.fixStartByList = new FixStartByWillDeletedList(editor, startBlock);
52666
+ groupIds.set(oldGroupId, groupId2);
52667
+ startIds.set(groupId2, start + 1);
52668
+ this.fixStartByList = new FixStartByWillDeletedList(editor, preBlock);
52656
52669
  return;
52657
52670
  }
52658
- const preBlock = getPrevBlock(startBlock);
52659
- if (preBlock && isListBlock(preBlock)) {
52660
- const { start, groupId: groupId2, level, type } = getListBlockProperties(preBlock);
52661
- const newType = getListType(block);
52662
- if (level === block.level && type === newType) {
52663
- const oldGroupId = block.groupId;
52664
- block.groupId = groupId2;
52665
- block.start = start + 1;
52666
- block.level = level;
52667
- groupIds.set(oldGroupId, groupId2);
52668
- startIds.set(groupId2, start + 1);
52669
- this.fixStartByList = new FixStartByWillDeletedList(editor, preBlock);
52670
- return;
52671
- }
52672
- }
52673
- }
52674
- const groupId = groupIds.get(block.groupId);
52675
- if (!groupId) {
52676
- const newGroupId = genId();
52677
- groupIds.set(block.groupId, newGroupId);
52678
- block.groupId = newGroupId;
52679
- block.start = 1;
52680
- startIds.set(newGroupId, 1);
52681
- } else {
52682
- const start = startIds.get(groupId);
52683
- assert(logger$20, start, "start is null");
52684
- block.start = start + 1;
52685
- block.groupId = groupId;
52686
- startIds.set(groupId, start + 1);
52687
52671
  }
52688
52672
  }
52689
- });
52673
+ const groupId = groupIds.get(block.groupId);
52674
+ if (!groupId) {
52675
+ const newGroupId = genId();
52676
+ groupIds.set(block.groupId, newGroupId);
52677
+ block.groupId = newGroupId;
52678
+ block.start = 1;
52679
+ startIds.set(newGroupId, 1);
52680
+ } else {
52681
+ const start = startIds.get(groupId);
52682
+ assert(logger$20, start, "start is null");
52683
+ block.start = start + 1;
52684
+ block.groupId = groupId;
52685
+ startIds.set(groupId, start + 1);
52686
+ }
52687
+ }
52690
52688
  });
52691
52689
  return false;
52692
52690
  }
@@ -92300,7 +92298,7 @@ ${JSON.stringify(error2, null, 2)}`);
92300
92298
  return;
92301
92299
  }
92302
92300
  }
92303
- if (block.type === "text" || block.textOnly === true) {
92301
+ if (block.type === "text" || block.type === "code-line" || block.textOnly === true) {
92304
92302
  const blockObj = await getBlockObject(block, md5HexFunc, getTextsByBox);
92305
92303
  await dbg.addTextBlock(blockObj);
92306
92304
  return;
@@ -93278,10 +93276,15 @@ ${JSON.stringify(error2, null, 2)}`);
93278
93276
  }
93279
93277
  this.children = commands;
93280
93278
  }
93281
- onClick(editor, item) {
93279
+ onClick(editor, item, commandBar2) {
93282
93280
  const provider = new InsertMenuProvider(editor);
93283
93281
  const startBlock = editor.getBlockById(editor.selection.range.start.blockId);
93284
93282
  provider.executeCommand(editor, startBlock, editor.selection.range, item, {});
93283
+ commandBar2.close("clickItem");
93284
+ const bar2 = commandBar2;
93285
+ if (bar2.closeable) {
93286
+ bar2.closeable.close("clickItem");
93287
+ }
93285
93288
  }
93286
93289
  }
93287
93290
  const FindIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<circle cx="11.5" cy="11.5" r="2.5" stroke="currentColor"></circle>\n<path d="M13.3542 13.3542L15 15" stroke="currentColor"></path>\n<path d="M13.5 8V5.41421C13.5 5.149 13.3946 4.89464 13.2071 4.70711L10.2929 1.79289C10.1054 1.60536 9.851 1.5 9.58579 1.5H3.5C2.94772 1.5 2.5 1.94772 2.5 2.5V13.5C2.5 14.0523 2.94772 14.5 3.5 14.5H8" stroke="currentColor" stroke-linejoin="round"></path>\n<path d="M9.5 1.5V4.5C9.5 5.05228 9.94772 5.5 10.5 5.5H13.5" stroke="currentColor" stroke-linejoin="round"></path>\n</svg>';
@@ -93474,6 +93477,11 @@ ${JSON.stringify(error2, null, 2)}`);
93474
93477
  moreItems.push(item);
93475
93478
  }
93476
93479
  });
93480
+ if (moreItems.length > 0) {
93481
+ if (moreItems[moreItems.length - 1].type === "separator") {
93482
+ moreItems.pop();
93483
+ }
93484
+ }
93477
93485
  this.hidden = moreItems.length === 0;
93478
93486
  this.children = moreItems;
93479
93487
  toolbar2.updateItems(items);
@@ -93583,7 +93591,7 @@ ${JSON.stringify(error2, null, 2)}`);
93583
93591
  __publicField(this, "handleClick", (bar2, item) => {
93584
93592
  const command = item;
93585
93593
  if (command.onClick) {
93586
- command.onClick(this.editor, command);
93594
+ command.onClick(this.editor, command, bar2);
93587
93595
  this.handleSelectionChanged();
93588
93596
  return;
93589
93597
  }
@@ -93605,7 +93613,7 @@ ${JSON.stringify(error2, null, 2)}`);
93605
93613
  const parent = findParent(i, item.id);
93606
93614
  if (parent) {
93607
93615
  if (parent.onClick) {
93608
- parent.onClick(this.editor, item);
93616
+ parent.onClick(this.editor, item, bar2);
93609
93617
  this.handleSelectionChanged();
93610
93618
  return;
93611
93619
  }
@@ -93922,7 +93930,7 @@ ${JSON.stringify(error2, null, 2)}`);
93922
93930
  }
93923
93931
  }
93924
93932
  });
93925
- editor.version = "2.8.40";
93933
+ editor.version = "2.8.42";
93926
93934
  return editor;
93927
93935
  }
93928
93936
  function isDoc(doc2) {
@@ -94035,7 +94043,7 @@ ${JSON.stringify(error2, null, 2)}`);
94035
94043
  }
94036
94044
  });
94037
94045
  OnesEditorToolbar.register(editor);
94038
- editor.version = "2.8.40";
94046
+ editor.version = "2.8.42";
94039
94047
  return editor;
94040
94048
  }
94041
94049
  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.8.40",
3
+ "version": "2.8.42",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {