@manuscripts/transform 2.3.5-LEAN-3608.2 → 2.3.5-LEAN-3608.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.
@@ -15,11 +15,10 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.hasGroup = exports.GROUP_SECTION = exports.GROUP_LIST = exports.GROUP_EXECUTABLE = exports.GROUP_ELEMENT = exports.GROUP_BLOCK = void 0;
18
+ exports.hasGroup = exports.GROUP_SECTION = exports.GROUP_EXECUTABLE = exports.GROUP_ELEMENT = exports.GROUP_BLOCK = void 0;
19
19
  exports.GROUP_BLOCK = 'block';
20
20
  exports.GROUP_ELEMENT = 'element';
21
21
  exports.GROUP_EXECUTABLE = 'executable';
22
- exports.GROUP_LIST = 'list';
23
22
  exports.GROUP_SECTION = 'sections';
24
23
  const hasGroup = (nodeType, groupName) => {
25
24
  const { group } = nodeType.spec;
@@ -1,32 +1,29 @@
1
1
  "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.isListNode = exports.listItem = exports.list = exports.JATS_HTML_LIST_STYLE_MAPPING = void 0;
3
+ exports.isListNode = exports.listItem = exports.list = exports.getListType = void 0;
19
4
  const json_schema_1 = require("@manuscripts/json-schema");
20
5
  const attributes_1 = require("../../lib/attributes");
21
- exports.JATS_HTML_LIST_STYLE_MAPPING = {
22
- simple: { style: 'none', type: 'ul' },
23
- bullet: { style: 'disc', type: 'ul' },
24
- order: { style: 'decimal', type: 'ol' },
25
- 'alpha-lower': { style: 'lower-alpha', type: 'ol' },
26
- 'alpha-upper': { style: 'upper-alpha', type: 'ol' },
27
- 'roman-lower': { style: 'lower-roman', type: 'ol' },
28
- 'roman-upper': { style: 'upper-roman', type: 'ol' },
6
+ const getListType = (style) => {
7
+ switch (style) {
8
+ case 'simple':
9
+ return { type: 'ul', style: 'none' };
10
+ case 'bullet':
11
+ return { type: 'ul', style: 'disc' };
12
+ case 'order':
13
+ return { type: 'ol', style: 'decimal' };
14
+ case 'alpha-lower':
15
+ return { type: 'ol', style: 'lower-alpha' };
16
+ case 'alpha-upper':
17
+ return { type: 'ol', style: 'upper-alpha' };
18
+ case 'roman-lower':
19
+ return { type: 'ol', style: 'lower-roman' };
20
+ case 'roman-upper':
21
+ return { type: 'ol', style: 'upper-roman' };
22
+ default:
23
+ throw new Error(`Unsupported style type: ${style}`);
24
+ }
29
25
  };
26
+ exports.getListType = getListType;
30
27
  exports.list = {
31
28
  content: 'list_item+',
32
29
  group: 'block list element',
@@ -59,28 +56,18 @@ exports.list = {
59
56
  },
60
57
  ],
61
58
  toDOM: (node) => {
62
- const ListNode = node;
63
- return exports.JATS_HTML_LIST_STYLE_MAPPING[ListNode.attrs.listStyleType].type === 'ul'
64
- ? [
65
- 'ul',
66
- {
67
- id: ListNode.attrs.id,
68
- 'list-type': ListNode.attrs.listStyleType,
69
- class: (0, attributes_1.buildElementClass)(ListNode.attrs),
70
- 'data-object-type': json_schema_1.ObjectTypes.ListElement,
71
- },
72
- 0,
73
- ]
74
- : [
75
- 'ol',
76
- {
77
- id: ListNode.attrs.id,
78
- 'list-type': ListNode.attrs.listStyleType,
79
- class: (0, attributes_1.buildElementClass)(ListNode.attrs),
80
- 'data-object-type': json_schema_1.ObjectTypes.ListElement,
81
- },
82
- 0,
83
- ];
59
+ const list = node;
60
+ const { type } = (0, exports.getListType)(list.attrs.listStyleType);
61
+ return [
62
+ type,
63
+ {
64
+ id: list.attrs.id,
65
+ 'list-type': list.attrs.listStyleType,
66
+ class: (0, attributes_1.buildElementClass)(list.attrs),
67
+ 'data-object-type': json_schema_1.ObjectTypes.ListElement,
68
+ },
69
+ 0,
70
+ ];
84
71
  },
85
72
  };
86
73
  exports.listItem = {
@@ -392,7 +392,7 @@ class Decoder {
392
392
  return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
393
393
  topNode: schema_1.schema.nodes.list.create({
394
394
  id: model._id,
395
- listStyleType: model.listStyleType,
395
+ listStyleType: model.listStyleType || 'order',
396
396
  paragraphStyle: model.paragraphStyle,
397
397
  comments: comments.map((c) => c.attrs.id),
398
398
  }),
@@ -401,7 +401,7 @@ class Decoder {
401
401
  return this.parseContents(model.contents || '<ul></ul>', undefined, this.getComments(model), {
402
402
  topNode: schema_1.schema.nodes.list.create({
403
403
  id: model._id,
404
- listStyleType: model.listStyleType,
404
+ listStyleType: model.listStyleType || 'bullet',
405
405
  paragraphStyle: model.paragraphStyle,
406
406
  }),
407
407
  });
@@ -327,7 +327,7 @@ const encoders = {
327
327
  quoteType: 'block',
328
328
  }),
329
329
  list: (node) => ({
330
- elementType: schema_1.JATS_HTML_LIST_STYLE_MAPPING[node.attrs.listStyleType].type,
330
+ elementType: (0, schema_1.getListType)(node.attrs.listStyleType).type,
331
331
  contents: listContents(node),
332
332
  listStyleType: node.attrs.listStyleType,
333
333
  paragraphStyle: node.attrs.paragraphStyle || undefined,
@@ -16,7 +16,6 @@
16
16
  export const GROUP_BLOCK = 'block';
17
17
  export const GROUP_ELEMENT = 'element';
18
18
  export const GROUP_EXECUTABLE = 'executable';
19
- export const GROUP_LIST = 'list';
20
19
  export const GROUP_SECTION = 'sections';
21
20
  export const hasGroup = (nodeType, groupName) => {
22
21
  const { group } = nodeType.spec;
@@ -1,28 +1,24 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
1
  import { ObjectTypes } from '@manuscripts/json-schema';
17
2
  import { buildElementClass } from '../../lib/attributes';
18
- export const JATS_HTML_LIST_STYLE_MAPPING = {
19
- simple: { style: 'none', type: 'ul' },
20
- bullet: { style: 'disc', type: 'ul' },
21
- order: { style: 'decimal', type: 'ol' },
22
- 'alpha-lower': { style: 'lower-alpha', type: 'ol' },
23
- 'alpha-upper': { style: 'upper-alpha', type: 'ol' },
24
- 'roman-lower': { style: 'lower-roman', type: 'ol' },
25
- 'roman-upper': { style: 'upper-roman', type: 'ol' },
3
+ export const getListType = (style) => {
4
+ switch (style) {
5
+ case 'simple':
6
+ return { type: 'ul', style: 'none' };
7
+ case 'bullet':
8
+ return { type: 'ul', style: 'disc' };
9
+ case 'order':
10
+ return { type: 'ol', style: 'decimal' };
11
+ case 'alpha-lower':
12
+ return { type: 'ol', style: 'lower-alpha' };
13
+ case 'alpha-upper':
14
+ return { type: 'ol', style: 'upper-alpha' };
15
+ case 'roman-lower':
16
+ return { type: 'ol', style: 'lower-roman' };
17
+ case 'roman-upper':
18
+ return { type: 'ol', style: 'upper-roman' };
19
+ default:
20
+ throw new Error(`Unsupported style type: ${style}`);
21
+ }
26
22
  };
27
23
  export const list = {
28
24
  content: 'list_item+',
@@ -56,28 +52,18 @@ export const list = {
56
52
  },
57
53
  ],
58
54
  toDOM: (node) => {
59
- const ListNode = node;
60
- return JATS_HTML_LIST_STYLE_MAPPING[ListNode.attrs.listStyleType].type === 'ul'
61
- ? [
62
- 'ul',
63
- {
64
- id: ListNode.attrs.id,
65
- 'list-type': ListNode.attrs.listStyleType,
66
- class: buildElementClass(ListNode.attrs),
67
- 'data-object-type': ObjectTypes.ListElement,
68
- },
69
- 0,
70
- ]
71
- : [
72
- 'ol',
73
- {
74
- id: ListNode.attrs.id,
75
- 'list-type': ListNode.attrs.listStyleType,
76
- class: buildElementClass(ListNode.attrs),
77
- 'data-object-type': ObjectTypes.ListElement,
78
- },
79
- 0,
80
- ];
55
+ const list = node;
56
+ const { type } = getListType(list.attrs.listStyleType);
57
+ return [
58
+ type,
59
+ {
60
+ id: list.attrs.id,
61
+ 'list-type': list.attrs.listStyleType,
62
+ class: buildElementClass(list.attrs),
63
+ 'data-object-type': ObjectTypes.ListElement,
64
+ },
65
+ 0,
66
+ ];
81
67
  },
82
68
  };
83
69
  export const listItem = {
@@ -383,7 +383,7 @@ export class Decoder {
383
383
  return this.parseContents(model.contents || '<ol></ol>', undefined, this.getComments(model), {
384
384
  topNode: schema.nodes.list.create({
385
385
  id: model._id,
386
- listStyleType: model.listStyleType,
386
+ listStyleType: model.listStyleType || 'order',
387
387
  paragraphStyle: model.paragraphStyle,
388
388
  comments: comments.map((c) => c.attrs.id),
389
389
  }),
@@ -392,7 +392,7 @@ export class Decoder {
392
392
  return this.parseContents(model.contents || '<ul></ul>', undefined, this.getComments(model), {
393
393
  topNode: schema.nodes.list.create({
394
394
  id: model._id,
395
- listStyleType: model.listStyleType,
395
+ listStyleType: model.listStyleType || 'bullet',
396
396
  paragraphStyle: model.paragraphStyle,
397
397
  }),
398
398
  });
@@ -16,7 +16,7 @@
16
16
  import { DOMSerializer } from 'prosemirror-model';
17
17
  import serializeToXML from 'w3c-xmlserializer';
18
18
  import { iterateChildren } from '../lib/utils';
19
- import { hasGroup, isHighlightMarkerNode, isManuscriptNode, isSectionNode, JATS_HTML_LIST_STYLE_MAPPING, schema, } from '../schema';
19
+ import { getListType, hasGroup, isHighlightMarkerNode, isManuscriptNode, isSectionNode, schema, } from '../schema';
20
20
  import { auxiliaryObjectTypes, buildAttribution, buildElementsOrder, buildFootnotesOrder, } from './builders';
21
21
  import { extractCommentMarkers } from './highlight-markers';
22
22
  import { nodeTypesMap } from './node-types';
@@ -319,7 +319,7 @@ const encoders = {
319
319
  quoteType: 'block',
320
320
  }),
321
321
  list: (node) => ({
322
- elementType: JATS_HTML_LIST_STYLE_MAPPING[node.attrs.listStyleType].type,
322
+ elementType: getListType(node.attrs.listStyleType).type,
323
323
  contents: listContents(node),
324
324
  listStyleType: node.attrs.listStyleType,
325
325
  paragraphStyle: node.attrs.paragraphStyle || undefined,
@@ -17,6 +17,5 @@ import { ManuscriptNodeType } from './types';
17
17
  export declare const GROUP_BLOCK = "block";
18
18
  export declare const GROUP_ELEMENT = "element";
19
19
  export declare const GROUP_EXECUTABLE = "executable";
20
- export declare const GROUP_LIST = "list";
21
20
  export declare const GROUP_SECTION = "sections";
22
21
  export declare const hasGroup: (nodeType: ManuscriptNodeType, groupName: string) => boolean;
@@ -1,28 +1,11 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { ListElement } from '@manuscripts/json-schema';
17
1
  import { NodeSpec } from 'prosemirror-model';
18
2
  import { ManuscriptNode } from '../types';
19
- export type JatsStyleType = NonNullable<ListElement['listStyleType']>;
20
- export declare const JATS_HTML_LIST_STYLE_MAPPING: {
21
- [key in JatsStyleType]: {
22
- style: string;
23
- type: string;
24
- };
25
- };
3
+ export type JatsStyleType = 'simple' | 'bullet' | 'order' | 'alpha-lower' | 'alpha-upper' | 'roman-lower' | 'roman-upper';
4
+ interface ListTypeInfo {
5
+ type: 'ul' | 'ol';
6
+ style: string;
7
+ }
8
+ export declare const getListType: (style: JatsStyleType) => ListTypeInfo;
26
9
  export interface ListNode extends ManuscriptNode {
27
10
  attrs: {
28
11
  id: string;
@@ -38,3 +21,4 @@ export interface ListItemNode extends ManuscriptNode {
38
21
  }
39
22
  export declare const listItem: NodeSpec;
40
23
  export declare const isListNode: (node: ManuscriptNode) => node is ListNode;
24
+ export {};
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": "2.3.5-LEAN-3608.2",
4
+ "version": "2.3.5-LEAN-3608.5",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-transform",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",