@manuscripts/transform 1.5.5 → 1.5.6

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.
@@ -573,7 +573,8 @@ const modelFromNode = (node, parent, path, priority) => {
573
573
  if ((0, highlight_markers_1.isHighlightableModel)(model)) {
574
574
  (0, highlight_markers_1.extractHighlightMarkers)(model, commentAnnotationsMap);
575
575
  }
576
- return { model, commentAnnotationsMap };
576
+ const comments = [...commentAnnotationsMap.values()];
577
+ return { model, comments };
577
578
  };
578
579
  exports.modelFromNode = modelFromNode;
579
580
  const encode = (node) => {
@@ -595,10 +596,18 @@ const encode = (node) => {
595
596
  if (placeholders.includes(child.type.name)) {
596
597
  return;
597
598
  }
598
- const { model } = (0, exports.modelFromNode)(child, parent, path, priority);
599
+ const { model, comments } = (0, exports.modelFromNode)(child, parent, path, priority);
599
600
  if (models.has(model._id)) {
600
601
  throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
601
602
  }
603
+ comments.forEach((comment) => {
604
+ const proseMirrorComment = models.get(comment._id);
605
+ if (proseMirrorComment) {
606
+ ;
607
+ proseMirrorComment.selector = comment.selector;
608
+ models.set(comment._id, proseMirrorComment);
609
+ }
610
+ });
602
611
  models.set(model._id, model);
603
612
  child.forEach(addModel(path.concat(child.attrs.id), child));
604
613
  };
@@ -565,7 +565,8 @@ export const modelFromNode = (node, parent, path, priority) => {
565
565
  if (isHighlightableModel(model)) {
566
566
  extractHighlightMarkers(model, commentAnnotationsMap);
567
567
  }
568
- return { model, commentAnnotationsMap };
568
+ const comments = [...commentAnnotationsMap.values()];
569
+ return { model, comments };
569
570
  };
570
571
  export const encode = (node) => {
571
572
  const models = new Map();
@@ -586,10 +587,18 @@ export const encode = (node) => {
586
587
  if (placeholders.includes(child.type.name)) {
587
588
  return;
588
589
  }
589
- const { model } = modelFromNode(child, parent, path, priority);
590
+ const { model, comments } = modelFromNode(child, parent, path, priority);
590
591
  if (models.has(model._id)) {
591
592
  throw Error(`Encountered duplicate ids in models map while encoding: ${model._id}`);
592
593
  }
594
+ comments.forEach((comment) => {
595
+ const proseMirrorComment = models.get(comment._id);
596
+ if (proseMirrorComment) {
597
+ ;
598
+ proseMirrorComment.selector = comment.selector;
599
+ models.set(comment._id, proseMirrorComment);
600
+ }
601
+ });
593
602
  models.set(model._id, model);
594
603
  child.forEach(addModel(path.concat(child.attrs.id), child));
595
604
  };
@@ -20,7 +20,7 @@ export declare const inlineContents: (node: ManuscriptNode) => string;
20
20
  export declare const inlineText: (node: ManuscriptNode) => string;
21
21
  export declare const modelFromNode: (node: ManuscriptNode, parent: ManuscriptNode, path: string[], priority: PrioritizedValue) => {
22
22
  model: Model;
23
- commentAnnotationsMap: Map<string, Build<CommentAnnotation>>;
23
+ comments: Build<CommentAnnotation>[];
24
24
  };
25
25
  interface PrioritizedValue {
26
26
  value: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/transform",
3
3
  "description": "ProseMirror transformer for Manuscripts applications",
4
- "version": "1.5.5",
4
+ "version": "1.5.6",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",