@ones-editor/editor 2.8.25-beta.3 → 2.8.25-beta.5

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.d.ts CHANGED
@@ -45,6 +45,7 @@ export * from 'tiny-typed-emitter';
45
45
  export { ShareDBDocVersionsProvider, OnesEditorIcons, isLayoutBlock, LayoutQuickMenuItemFilter, CalloutQuickMenuItemFilter, MobileCommandHandler, PasteSpecialHandler };
46
46
  export type { FileBoxData, FileEmbedData } from '../@ones-editor/file';
47
47
  export * from './helper';
48
+ export { OnesEditorComments, OnesEditorCommentsRender } from '../@ones-editor/comments';
48
49
  export { type DocListBlock } from '../@ones-editor/list-block';
49
50
  export declare function getDefaultOnesEditorOptions(options: CreateOnesEditorOptions): {
50
51
  id: string | undefined;
package/dist/index.js CHANGED
@@ -70224,6 +70224,16 @@ ${codeText}
70224
70224
  });
70225
70225
  return resultMap;
70226
70226
  }
70227
+ function getBlocksByCommentId(doc2, commentId) {
70228
+ const result = [];
70229
+ const resultMap = getBlockCommentsFromDoc(doc2);
70230
+ resultMap.forEach((commentIds, blockId) => {
70231
+ if (commentIds.has(commentId)) {
70232
+ result.push(blockId);
70233
+ }
70234
+ });
70235
+ return result;
70236
+ }
70227
70237
  class OnesEditorCommentsRender {
70228
70238
  constructor(type = "current") {
70229
70239
  __publicField(this, "updateUnknownCommentsDelayed", debounce__default.default((editor) => {
@@ -70482,40 +70492,51 @@ ${codeText}
70482
70492
  }
70483
70493
  onUpdateCommentResolver(commentId, local) {
70484
70494
  const comment = this.commentsProvider.getComment(commentId);
70485
- const groupItem = this.list.findGroupItem(comment.groupId);
70486
- if (!groupItem) {
70495
+ if (!comment) {
70487
70496
  return;
70488
70497
  }
70489
- setTimeout(() => {
70490
- if (this.listType === "current") {
70491
- if (comment.resolver) {
70492
- this.list.handleDeleteComment(commentId);
70493
- } else {
70494
- this.list.handleCreateComment(comment, local);
70495
- }
70496
- } else {
70497
- if (comment.resolver) {
70498
- this.list.handleCreateComment(comment, local);
70499
- } else {
70500
- this.list.handleDeleteComment(commentId);
70501
- }
70498
+ let type = "add";
70499
+ if (this.listType === "current") {
70500
+ if (comment.resolver) {
70501
+ type = "remove";
70502
70502
  }
70503
- }, 300);
70504
- this.updateCommentCount();
70503
+ } else {
70504
+ if (!comment.resolver) {
70505
+ type = "remove";
70506
+ }
70507
+ }
70505
70508
  const blocks = /* @__PURE__ */ new Set();
70506
- getElementsByCommentId(this.editor, groupItem.comment.id).forEach((element) => {
70507
- if (isBlock$1(element)) {
70508
- blocks.add(element);
70509
- } else {
70510
- const block = getParentBlock(element);
70509
+ if (type === "remove") {
70510
+ getElementsByCommentId(this.editor, commentId).forEach((element) => {
70511
+ if (isBlock$1(element)) {
70512
+ blocks.add(element);
70513
+ } else {
70514
+ const block = getParentBlock(element);
70515
+ if (block) {
70516
+ blocks.add(block);
70517
+ }
70518
+ }
70519
+ });
70520
+ } else {
70521
+ const blockIds = getBlocksByCommentId(this.editor.doc.toJSON(), commentId);
70522
+ blockIds.forEach((blockId) => {
70523
+ const block = this.editor.findBlockById(blockId);
70511
70524
  if (block) {
70512
70525
  blocks.add(block);
70513
70526
  }
70514
- }
70515
- });
70527
+ });
70528
+ }
70516
70529
  blocks.forEach((block) => {
70517
70530
  this.editor.reloadBlock(block);
70518
70531
  });
70532
+ setTimeout(() => {
70533
+ if (type === "add") {
70534
+ this.list.handleCreateComment(comment, local);
70535
+ } else {
70536
+ this.list.handleDeleteComment(commentId);
70537
+ }
70538
+ this.updateCommentCount();
70539
+ }, 300);
70519
70540
  }
70520
70541
  createList() {
70521
70542
  return new CommentGroupList(this.editor, this.commentsProvider, this.groupsContainer, this.listType);
@@ -71336,6 +71357,15 @@ ${codeText}
71336
71357
  get isMobile() {
71337
71358
  return clientType.isMobile;
71338
71359
  }
71360
+ getCommentList() {
71361
+ return this.commentList;
71362
+ }
71363
+ getMobileCommentList() {
71364
+ return this.mobileCommentList;
71365
+ }
71366
+ getMiniCommentList() {
71367
+ return this.miniCommentList;
71368
+ }
71339
71369
  destroy() {
71340
71370
  var _a, _b;
71341
71371
  (_a = this.commentList) == null ? void 0 : _a.destroy();
@@ -71607,6 +71637,19 @@ ${codeText}
71607
71637
  method: "delete"
71608
71638
  });
71609
71639
  }
71640
+ function updateCommentResolverToOldDoc(editor, version, commentId, resolver) {
71641
+ var _a, _b;
71642
+ const doc2 = editor.doc;
71643
+ const server = (_b = (_a = doc2.getServerMeta) == null ? void 0 : _a.call(doc2)) == null ? void 0 : _b.apiServer;
71644
+ assert(logger$16, server, "apiServer is not set");
71645
+ const api = `${server}/${version}/comments/${commentId}/resolver`;
71646
+ return doc2.request(api, {
71647
+ method: "put",
71648
+ data: {
71649
+ resolver
71650
+ }
71651
+ });
71652
+ }
71610
71653
  getLogger("resolved-comment-item");
71611
71654
  const styles = "";
71612
71655
  const isAllContainersSelected = (editor) => {
@@ -71684,6 +71727,14 @@ ${codeText}
71684
71727
  }
71685
71728
  }
71686
71729
  onUpdateCommentResolver(commentId, local) {
71730
+ const comments = this.editor.getCustom("editor-comments");
71731
+ const provider = comments.commentProvider;
71732
+ const comment = provider.getComment(commentId);
71733
+ if (!comment) {
71734
+ return;
71735
+ }
71736
+ const resolver = comment.resolver;
71737
+ updateCommentResolverToOldDoc(this.editor, this.version, commentId, resolver);
71687
71738
  }
71688
71739
  hideToolbar(editor) {
71689
71740
  const toolbar2 = editor.findCustom("toolbar-handler");
@@ -90883,8 +90934,12 @@ ${data2.plantumlText}
90883
90934
  localUpdateCommentResolver(commentId, resolver) {
90884
90935
  const comment = this.getComment(commentId);
90885
90936
  if (comment) {
90886
- comment.resolver = resolver;
90887
- this.localUpdateComment(comment, this.getCommentDoc(commentId));
90937
+ if (resolver) {
90938
+ comment.resolver = resolver;
90939
+ } else {
90940
+ delete comment.resolver;
90941
+ }
90942
+ Array.from(this._listeners.values()).forEach((listener) => listener.onUpdateCommentResolver(commentId, true));
90888
90943
  }
90889
90944
  }
90890
90945
  createCommentEditor(parent, childDoc) {
@@ -93678,7 +93733,7 @@ ${data2.plantumlText}
93678
93733
  }
93679
93734
  }
93680
93735
  });
93681
- editor.version = "2.8.25-beta.3";
93736
+ editor.version = "2.8.25-beta.5";
93682
93737
  return editor;
93683
93738
  }
93684
93739
  function isDoc(doc2) {
@@ -93791,7 +93846,7 @@ ${data2.plantumlText}
93791
93846
  }
93792
93847
  });
93793
93848
  OnesEditorToolbar.register(editor);
93794
- editor.version = "2.8.25-beta.3";
93849
+ editor.version = "2.8.25-beta.5";
93795
93850
  return editor;
93796
93851
  }
93797
93852
  async function showDocVersions(editor, options, serverUrl) {
@@ -139761,6 +139816,8 @@ ${data2.plantumlText}
139761
139816
  exports2.MoreItem = MoreItem;
139762
139817
  exports2.NextIcon = NextIcon;
139763
139818
  exports2.OnesEditorAutoSuggest = OnesEditorAutoSuggest;
139819
+ exports2.OnesEditorComments = OnesEditorComments;
139820
+ exports2.OnesEditorCommentsRender = OnesEditorCommentsRender;
139764
139821
  exports2.OnesEditorCustomDataWrapper = OnesEditorCustomDataWrapper;
139765
139822
  exports2.OnesEditorExclusiveBlock = OnesEditorExclusiveBlock;
139766
139823
  exports2.OnesEditorHoveringBlock = OnesEditorHoveringBlock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.8.25-beta.3",
3
+ "version": "2.8.25-beta.5",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {