@ones-editor/editor 2.1.1-beta.1 → 2.1.1-beta.3

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
@@ -11326,6 +11326,7 @@ var __publicField = (obj, key, value) => {
11326
11326
  }
11327
11327
  toDocRange() {
11328
11328
  return {
11329
+ reverse: this.reverse,
11329
11330
  anchor: this.anchor,
11330
11331
  focus: this.focus
11331
11332
  };
@@ -11818,6 +11819,24 @@ var __publicField = (obj, key, value) => {
11818
11819
  focus
11819
11820
  };
11820
11821
  }
11822
+ function isFullSelectedOneComplexBlock(editor, complexRange) {
11823
+ const range = complexRange || editor.selection.range;
11824
+ const { start, end } = range;
11825
+ const startBlock = editor.getBlockById(start.blockId);
11826
+ const endBlock = editor.getBlockById(end.blockId);
11827
+ if (startBlock !== endBlock) {
11828
+ return false;
11829
+ }
11830
+ if (!isComplexKindBlock(editor, startBlock)) {
11831
+ return false;
11832
+ }
11833
+ if (isSimpleBlockPosition(start)) {
11834
+ return true;
11835
+ }
11836
+ const containers = complexBlockGetSelectedContainers(editor, startBlock, start, end);
11837
+ const allContainers = complexBlockGetAllChildContainers(editor, startBlock);
11838
+ return containers.length === allContainers.length;
11839
+ }
11821
11840
  class EditorComplexSelectionRange {
11822
11841
  constructor(editor, pos) {
11823
11842
  __publicField(this, "editor");
@@ -11886,6 +11905,7 @@ var __publicField = (obj, key, value) => {
11886
11905
  }
11887
11906
  toDocRange() {
11888
11907
  return {
11908
+ reverse: this.reverse,
11889
11909
  anchor: this._anchor,
11890
11910
  focus: this._focus
11891
11911
  };
@@ -27037,24 +27057,6 @@ var __publicField = (obj, key, value) => {
27037
27057
  editor.deleteBlock(block);
27038
27058
  }
27039
27059
  }
27040
- function isFullSelectedOneComplexBlock(editor) {
27041
- const { range } = editor.selection;
27042
- const { start, end } = range;
27043
- const startBlock = editor.getBlockById(start.blockId);
27044
- const endBlock = editor.getBlockById(end.blockId);
27045
- if (startBlock !== endBlock) {
27046
- return false;
27047
- }
27048
- if (!isComplexKindBlock(editor, startBlock)) {
27049
- return false;
27050
- }
27051
- if (isSimpleBlockPosition(start)) {
27052
- return true;
27053
- }
27054
- const containers = complexBlockGetSelectedContainers(editor, startBlock, start, end);
27055
- const allContainers = complexBlockGetAllChildContainers(editor, startBlock);
27056
- return containers.length === allContainers.length;
27057
- }
27058
27060
  function handleEditorEnterEvent$1(editor, event) {
27059
27061
  if (isFullSelectedOneComplexBlock(editor)) {
27060
27062
  const focusedBlock2 = editor.getFocusedBlock();
@@ -45030,7 +45032,7 @@ ${codeText}
45030
45032
  const logger$1$ = getLogger("object-commands");
45031
45033
  function getObjectCommands(editor, block, child) {
45032
45034
  const result = getSpecialBlockCommands(editor, block, child, "hovering-toolbar");
45033
- const { boxCommands, blockCommands } = result;
45035
+ const { element: targetElement, boxCommands, blockCommands } = result;
45034
45036
  let element = null;
45035
45037
  const commands = [];
45036
45038
  if (boxCommands.length > 0) {
@@ -45046,7 +45048,7 @@ ${codeText}
45046
45048
  if (blockCommands.length > 0) {
45047
45049
  for (let i = 0; i < blockCommands.length; i++) {
45048
45050
  const blockCommand = blockCommands[i];
45049
- element = element || blockCommand.element || null;
45051
+ element = element || targetElement || null;
45050
45052
  if (blockCommand.startGroup) {
45051
45053
  commands.push({ id: "separator", name: "", type: "separator" });
45052
45054
  }
@@ -65218,9 +65220,26 @@ ${codeText}
65218
65220
  abstract
65219
65221
  });
65220
65222
  editor.undoManager.runInGroup(() => {
65221
- const selectedBlocks2 = getAllSelectedBlocks(editor, { simpleBlockOnly: true, range });
65223
+ let selectedBlocks2 = [];
65224
+ if (range.isSimple()) {
65225
+ selectedBlocks2 = range.getSelectedBlocks();
65226
+ } else {
65227
+ range.getSelectedContainers().forEach((container) => {
65228
+ const blocks = getChildBlocks(container);
65229
+ selectedBlocks2.push(...blocks.map((block) => {
65230
+ const range2 = createBlockSimpleRange(editor, block, 0, getBlockTextLength$6(editor, block));
65231
+ const selectedBlock = {
65232
+ block,
65233
+ start: range2.start,
65234
+ end: range2.end
65235
+ };
65236
+ return selectedBlock;
65237
+ }));
65238
+ });
65239
+ }
65222
65240
  selectedBlocks2.forEach((selectedBlock) => {
65223
65241
  if (!isTextKindBlock(editor, selectedBlock.block)) {
65242
+ updateCommentToBlock(editor, selectedBlock.block, comment);
65224
65243
  return;
65225
65244
  }
65226
65245
  addCommentToSelectedTextBlock(editor, selectedBlock, comment);
@@ -65568,17 +65587,18 @@ ${codeText}
65568
65587
  var _a, _b;
65569
65588
  const user = editor.doc.getUser();
65570
65589
  const startBlock = editor.getBlockById(range.start.blockId);
65571
- const endBlock = editor.getBlockById(range.end.blockId);
65572
- const startOffset = range.start.offset;
65573
- const endOffset = range.end.offset;
65574
65590
  const containerId = docObjectContainerId2EditorDocContainerId(getContainerId(getParentContainer(startBlock)));
65591
+ let selectedContainers = [];
65592
+ if (!range.isSimple()) {
65593
+ const complexRange = range;
65594
+ selectedContainers = complexBlockGetSelectedContainers(editor, startBlock, complexRange.start, complexRange.end).map((c) => getContainerId(c));
65595
+ }
65575
65596
  const body = {
65576
65597
  avatarUrl: user.avatarUrl,
65577
65598
  containerId,
65578
- startBlockId: getBlockId(startBlock),
65579
- startOffset,
65580
- endBlockId: getBlockId(endBlock),
65581
- endOffset,
65599
+ rangeType: range.isSimple() ? "simple" : "complex",
65600
+ range: range.toDocRange(),
65601
+ selectedContainers,
65582
65602
  commentId: comment.id,
65583
65603
  commentGroupId: comment.groupId,
65584
65604
  comment: commentDoc
@@ -65674,9 +65694,6 @@ ${codeText}
65674
65694
  const range = this.localCreatedComments.get(commentId);
65675
65695
  if (range) {
65676
65696
  this.localCreatedComments.delete(commentId);
65677
- if (!range.isSimple()) {
65678
- return;
65679
- }
65680
65697
  const comments = this.editor.getCustom("editor-comments");
65681
65698
  const provider = comments.commentProvider;
65682
65699
  const comment = provider.getComment(commentId);
@@ -65735,8 +65752,9 @@ ${codeText}
65735
65752
  };
65736
65753
  }
65737
65754
  }
65755
+ const types2 = ["embed", "code", "callout"];
65738
65756
  const type = getBlockType(blockElement);
65739
- if (type !== "embed" && type !== "code") {
65757
+ if (!types2.includes(type)) {
65740
65758
  return void 0;
65741
65759
  }
65742
65760
  return {
@@ -65763,11 +65781,25 @@ ${codeText}
65763
65781
  };
65764
65782
  }
65765
65783
  getTextCommands(editor, range) {
65766
- return [{
65767
- id: "add-comment-to-old-doc/text",
65768
- name: i18n$1.t("comment.quickMenuCommand"),
65769
- icon: CommentIcon$1
65770
- }];
65784
+ if (range.isCollapsed()) {
65785
+ return [];
65786
+ }
65787
+ if (range.isSimple()) {
65788
+ return [{
65789
+ id: "add-comment-to-old-doc/text",
65790
+ name: i18n$1.t("comment.quickMenuCommand"),
65791
+ icon: CommentIcon$1
65792
+ }];
65793
+ }
65794
+ const selectedBlock = range.getSelectedBlocks()[0];
65795
+ if (selectedBlock && getBlockType(selectedBlock.block) === "table") {
65796
+ return [{
65797
+ id: "add-comment-to-old-doc/text",
65798
+ name: i18n$1.t("comment.quickMenuCommand"),
65799
+ icon: CommentIcon$1
65800
+ }];
65801
+ }
65802
+ return [];
65771
65803
  }
65772
65804
  executeCommand(editor, command, options) {
65773
65805
  if (command.id === "add-comment-to-old-doc/text") {
@@ -65775,11 +65807,21 @@ ${codeText}
65775
65807
  if (!comments) {
65776
65808
  return;
65777
65809
  }
65810
+ comments.showCommentList();
65778
65811
  const range = editor.selection.range;
65779
65812
  if (!range.isSimple()) {
65780
- return;
65813
+ if (isFullSelectedOneComplexBlock(editor, range)) {
65814
+ const selectedBlock = range.getSelectedBlocks()[0];
65815
+ if (selectedBlock) {
65816
+ editor.readonly = false;
65817
+ addCommentToBlock(editor, selectedBlock.block);
65818
+ setTimeout(() => {
65819
+ editor.readonly = true;
65820
+ }, 100);
65821
+ }
65822
+ return;
65823
+ }
65781
65824
  }
65782
- comments.showCommentList();
65783
65825
  editor.readonly = false;
65784
65826
  addCommentToTextBlocks(editor, range, comments.commentProvider);
65785
65827
  setTimeout(() => {
@@ -67925,7 +67967,9 @@ ${codeText}
67925
67967
  const { fromCol: startCol, toCol: endCol } = getTableSelectionRange(complexBlock, editor.selection.range.start, editor.selection.range.end);
67926
67968
  const grid = TableGrid.fromBlock(complexBlock);
67927
67969
  if (startCol !== 0 || endCol !== grid.colCount - 1) {
67928
- offset = 60;
67970
+ if (!editor.readonly) {
67971
+ offset = 60;
67972
+ }
67929
67973
  }
67930
67974
  }
67931
67975
  const clientRect = getClientRects(editor, complexBlock, editor.selection.range)[0];
@@ -83086,7 +83130,7 @@ ${data2.flowchartText}
83086
83130
  }
83087
83131
  }
83088
83132
  });
83089
- editor.version = "2.1.1-beta.1";
83133
+ editor.version = "2.1.1-beta.3";
83090
83134
  if (Logger$2.level === LogLevel.DEBUG) {
83091
83135
  window.setReauthFail = (fail) => {
83092
83136
  window.isReauthError = fail;
@@ -83181,7 +83225,7 @@ ${data2.flowchartText}
83181
83225
  if (!clientType.isMobile) {
83182
83226
  OnesEditorToolbar.register(editor);
83183
83227
  }
83184
- editor.version = "2.1.1-beta.1";
83228
+ editor.version = "2.1.1-beta.3";
83185
83229
  return editor;
83186
83230
  }
83187
83231
  async function showDocVersions(editor, options, serverUrl) {
@@ -129364,6 +129408,7 @@ ${data2.flowchartText}
129364
129408
  exports2.isExpandedHeadingBlock = isExpandedHeadingBlock;
129365
129409
  exports2.isFirefox = isFirefox;
129366
129410
  exports2.isFirstChildBlockInComplexBlock = isFirstChildBlockInComplexBlock;
129411
+ exports2.isFullSelectedOneComplexBlock = isFullSelectedOneComplexBlock;
129367
129412
  exports2.isHeadingBlock = isHeadingBlock$1;
129368
129413
  exports2.isHighSurrogate = t$7;
129369
129414
  exports2.isInBlock = isInBlock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.1.1-beta.1",
3
+ "version": "2.1.1-beta.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",