@manuscripts/transform 4.3.51 → 4.3.52

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.
@@ -626,6 +626,46 @@ exports.v2_3_20 = {
626
626
  },
627
627
  ],
628
628
  },
629
+ {
630
+ type: 'figure_element',
631
+ attrs: {
632
+ id: 'MPFigureElement:ca6dac1a-b6ae-4227-be6e-75119186224b',
633
+ label: '',
634
+ sizeFraction: 0,
635
+ suppressCaption: true,
636
+ suppressTitle: true,
637
+ dataTracked: null,
638
+ },
639
+ content: [
640
+ {
641
+ type: 'figure',
642
+ attrs: {
643
+ id: 'MPFigure:d377ead2-6849-4597-9caa-f3e6b73bb629',
644
+ src: 'chemoji/chemoji8.png',
645
+ contentType: 'image/png',
646
+ dataTracked: null,
647
+ },
648
+ },
649
+ {
650
+ type: 'figcaption',
651
+ attrs: {
652
+ dataTracked: null,
653
+ },
654
+ },
655
+ {
656
+ type: 'listing',
657
+ attrs: {
658
+ id: '',
659
+ contents: '',
660
+ language: '',
661
+ languageKey: 'null',
662
+ isExpanded: false,
663
+ isExecuting: false,
664
+ dataTracked: null,
665
+ },
666
+ },
667
+ ],
668
+ },
629
669
  {
630
670
  type: 'table_element',
631
671
  attrs: {
@@ -22,6 +22,24 @@ const CONFIG = {
22
22
  location: { pos: 'start' },
23
23
  },
24
24
  };
25
+ const getCaptionNode = (nodes, isRequired) => {
26
+ if (nodes.length === 0) {
27
+ return isRequired
28
+ ? {
29
+ type: 'caption',
30
+ content: [{ type: 'text_block', attrs: {} }],
31
+ attrs: {},
32
+ }
33
+ : undefined;
34
+ }
35
+ return nodes.reduce((caption, { content }) => ({
36
+ ...caption,
37
+ content: [
38
+ ...(caption.content || []),
39
+ { type: 'text_block', content, attrs: {} },
40
+ ],
41
+ }), { type: 'caption', content: [], attrs: {} });
42
+ };
25
43
  class Migration4334 {
26
44
  constructor() {
27
45
  this.fromVersion = '4.3.33';
@@ -34,14 +52,8 @@ class Migration4334 {
34
52
  }
35
53
  const figCaption = node.content.find((n) => n.type === 'figcaption');
36
54
  const foundTitle = (figCaption?.content || []).find((n) => n.type === 'caption_title');
37
- const foundCaption = (figCaption?.content || []).filter((node) => node.type === 'caption')
38
- .reduce((caption, { content }) => ({
39
- ...caption,
40
- content: [
41
- ...(caption.content || []),
42
- { type: 'text_block', content, attrs: {} },
43
- ],
44
- }), { type: 'caption', content: [], attrs: {} });
55
+ const captionNodes = (figCaption?.content || []).filter((node) => node.type === 'caption');
56
+ const foundCaption = getCaptionNode(captionNodes, config.caption === 'required');
45
57
  const cleanContent = node.content.filter((n) => n.type !== 'figcaption');
46
58
  const placeholderTitle = index_1.schema.nodes.caption_title.create().toJSON();
47
59
  const placeholderCaption = index_1.schema.nodes.caption.create().toJSON();
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "4.3.51";
4
+ exports.VERSION = "4.3.52";
@@ -623,6 +623,46 @@ export const v2_3_20 = {
623
623
  },
624
624
  ],
625
625
  },
626
+ {
627
+ type: 'figure_element',
628
+ attrs: {
629
+ id: 'MPFigureElement:ca6dac1a-b6ae-4227-be6e-75119186224b',
630
+ label: '',
631
+ sizeFraction: 0,
632
+ suppressCaption: true,
633
+ suppressTitle: true,
634
+ dataTracked: null,
635
+ },
636
+ content: [
637
+ {
638
+ type: 'figure',
639
+ attrs: {
640
+ id: 'MPFigure:d377ead2-6849-4597-9caa-f3e6b73bb629',
641
+ src: 'chemoji/chemoji8.png',
642
+ contentType: 'image/png',
643
+ dataTracked: null,
644
+ },
645
+ },
646
+ {
647
+ type: 'figcaption',
648
+ attrs: {
649
+ dataTracked: null,
650
+ },
651
+ },
652
+ {
653
+ type: 'listing',
654
+ attrs: {
655
+ id: '',
656
+ contents: '',
657
+ language: '',
658
+ languageKey: 'null',
659
+ isExpanded: false,
660
+ isExecuting: false,
661
+ dataTracked: null,
662
+ },
663
+ },
664
+ ],
665
+ },
626
666
  {
627
667
  type: 'table_element',
628
668
  attrs: {
@@ -20,6 +20,24 @@ const CONFIG = {
20
20
  location: { pos: 'start' },
21
21
  },
22
22
  };
23
+ const getCaptionNode = (nodes, isRequired) => {
24
+ if (nodes.length === 0) {
25
+ return isRequired
26
+ ? {
27
+ type: 'caption',
28
+ content: [{ type: 'text_block', attrs: {} }],
29
+ attrs: {},
30
+ }
31
+ : undefined;
32
+ }
33
+ return nodes.reduce((caption, { content }) => ({
34
+ ...caption,
35
+ content: [
36
+ ...(caption.content || []),
37
+ { type: 'text_block', content, attrs: {} },
38
+ ],
39
+ }), { type: 'caption', content: [], attrs: {} });
40
+ };
23
41
  class Migration4334 {
24
42
  constructor() {
25
43
  this.fromVersion = '4.3.33';
@@ -32,14 +50,8 @@ class Migration4334 {
32
50
  }
33
51
  const figCaption = node.content.find((n) => n.type === 'figcaption');
34
52
  const foundTitle = (figCaption?.content || []).find((n) => n.type === 'caption_title');
35
- const foundCaption = (figCaption?.content || []).filter((node) => node.type === 'caption')
36
- .reduce((caption, { content }) => ({
37
- ...caption,
38
- content: [
39
- ...(caption.content || []),
40
- { type: 'text_block', content, attrs: {} },
41
- ],
42
- }), { type: 'caption', content: [], attrs: {} });
53
+ const captionNodes = (figCaption?.content || []).filter((node) => node.type === 'caption');
54
+ const foundCaption = getCaptionNode(captionNodes, config.caption === 'required');
43
55
  const cleanContent = node.content.filter((n) => n.type !== 'figcaption');
44
56
  const placeholderTitle = schema.nodes.caption_title.create().toJSON();
45
57
  const placeholderCaption = schema.nodes.caption.create().toJSON();
@@ -1 +1 @@
1
- export const VERSION = "4.3.51";
1
+ export const VERSION = "4.3.52";
@@ -1 +1 @@
1
- export declare const VERSION = "4.3.51";
1
+ export declare const VERSION = "4.3.52";
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": "4.3.51",
4
+ "version": "4.3.52",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",