pro-editor-schema 0.2.1 → 0.2.21

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.mts CHANGED
@@ -22,7 +22,7 @@ type Schema<TRequiredAttributes = readonly AttributeDefinition[], TOptionalAttri
22
22
  };
23
23
  type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
24
24
  type ElementSchemaCode = "referenceBibliomixed" | "referenceBibliography" | "bibliodiv" | "degrees" | "email" | "equation" | "fignote" | "figsource" | "firstname" | "footnote" | "footnoteno" | "honorific" | "img" | "informalfigure" | "keyword" | "label1" | "li" | "line" | "lrh" | "math" | "mathphrase" | "merror" | "mfrac" | "mi" | "mmultiscripts" | "mn" | "mo" | "mover" | "mpadded" | "mphantom" | "mprescripts" | "mroot" | "mrow" | "ms" | "mspace" | "msqrt" | "mstyle" | "msub" | "msubsup" | "msup" | "mtable" | "mtd" | "mtext" | "mtr" | "munder" | "munderover" | "olink" | "org" | "orgname" | "para" | "punc" | "rrh" | "source1" | "speaker" | "subtitle1" | "surname" | "tag" | "tblfn" | "tblsource" | "thead" | "title1" | "token" | "tp" | "abstract1" | "affiliation" | "alttext" | "appendix" | "author" | "authorgroup" | "blockquote" | "caption1" | "chapter" | "dialogue" | "epigraph" | "figure1" | "footnoteSection" | "heading" | "imageobject" | "info1" | "keywordset" | "mediaobject" | "ol" | "personname" | "poem" | "sidebar" | "table" | "table1" | "tbody" | "td" | "tgroup" | "tr" | "ul";
25
- type AtomSchemaCode = "indexterm" | "primary" | "secondary" | "tertiary" | "quaternary" | "bookmark" | "see" | "commentQuerySection" | "comment" | "content" | "query" | "reply" | "deletion" | "emphasis" | "highlightmark" | "i" | "insertion" | "sc" | "strike" | "sub" | "sup" | "u" | "b" | "referenceMark";
25
+ type AtomSchemaCode = "indexterm" | "primary" | "secondary" | "tertiary" | "quaternary" | "bookmark" | "see" | "commentQuerySection" | "comment" | "content" | "query" | "reply" | "deletion" | "emphasis" | "highlightmark" | "i" | "insertion" | "sc" | "strike" | "sub" | "sup" | "u" | "b" | "referenceMark" | "abbreviation";
26
26
  type InlineSchemaCode = "footnote1" | "inlineequation" | "link" | "uri" | "phrase";
27
27
 
28
28
  declare const SCHEMAS: Record<SchemaCode, Schema>;
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ type Schema<TRequiredAttributes = readonly AttributeDefinition[], TOptionalAttri
22
22
  };
23
23
  type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
24
24
  type ElementSchemaCode = "referenceBibliomixed" | "referenceBibliography" | "bibliodiv" | "degrees" | "email" | "equation" | "fignote" | "figsource" | "firstname" | "footnote" | "footnoteno" | "honorific" | "img" | "informalfigure" | "keyword" | "label1" | "li" | "line" | "lrh" | "math" | "mathphrase" | "merror" | "mfrac" | "mi" | "mmultiscripts" | "mn" | "mo" | "mover" | "mpadded" | "mphantom" | "mprescripts" | "mroot" | "mrow" | "ms" | "mspace" | "msqrt" | "mstyle" | "msub" | "msubsup" | "msup" | "mtable" | "mtd" | "mtext" | "mtr" | "munder" | "munderover" | "olink" | "org" | "orgname" | "para" | "punc" | "rrh" | "source1" | "speaker" | "subtitle1" | "surname" | "tag" | "tblfn" | "tblsource" | "thead" | "title1" | "token" | "tp" | "abstract1" | "affiliation" | "alttext" | "appendix" | "author" | "authorgroup" | "blockquote" | "caption1" | "chapter" | "dialogue" | "epigraph" | "figure1" | "footnoteSection" | "heading" | "imageobject" | "info1" | "keywordset" | "mediaobject" | "ol" | "personname" | "poem" | "sidebar" | "table" | "table1" | "tbody" | "td" | "tgroup" | "tr" | "ul";
25
- type AtomSchemaCode = "indexterm" | "primary" | "secondary" | "tertiary" | "quaternary" | "bookmark" | "see" | "commentQuerySection" | "comment" | "content" | "query" | "reply" | "deletion" | "emphasis" | "highlightmark" | "i" | "insertion" | "sc" | "strike" | "sub" | "sup" | "u" | "b" | "referenceMark";
25
+ type AtomSchemaCode = "indexterm" | "primary" | "secondary" | "tertiary" | "quaternary" | "bookmark" | "see" | "commentQuerySection" | "comment" | "content" | "query" | "reply" | "deletion" | "emphasis" | "highlightmark" | "i" | "insertion" | "sc" | "strike" | "sub" | "sup" | "u" | "b" | "referenceMark" | "abbreviation";
26
26
  type InlineSchemaCode = "footnote1" | "inlineequation" | "link" | "uri" | "phrase";
27
27
 
28
28
  declare const SCHEMAS: Record<SchemaCode, Schema>;
package/dist/index.js CHANGED
@@ -127,11 +127,13 @@ var ATOM_CODES_ALLOWED_CHILDREN = [
127
127
  { code: "commentQuerySection", required: false },
128
128
  { code: "comment", required: false },
129
129
  { code: "query", required: false },
130
- { code: "referenceMark", required: false }
130
+ { code: "referenceMark", required: false },
131
+ { code: "abbreviation", required: false }
131
132
  ];
132
133
 
133
134
  // src/schema/elementSchemas/atoms/atomTags.ts
134
135
  var B_TAG = "B";
136
+ var ABBR_TAG = "ABBR";
135
137
  var I_TAG = "I";
136
138
  var U_TAG = "U";
137
139
  var SC_TAG = "SC";
@@ -536,6 +538,27 @@ var REFERENCE_MARK_SCHEMA = createSchema({
536
538
  allowedChildrenCodes: [...ATOM_CODES_ALLOWED_CHILDREN]
537
539
  });
538
540
 
541
+ // src/schema/elementSchemas/atoms/abbr.ts
542
+ var ABBR_SCHEMA = createSchema({
543
+ code: "abbreviation",
544
+ kind: "atom",
545
+ tag: ABBR_TAG,
546
+ requiredAttributes: [
547
+ ...ID_ATTRS,
548
+ "title",
549
+ TRACK_CHANGES_ATTR_DATA_TIME,
550
+ TRACK_CHANGES_ATTR_DATA_USERID,
551
+ TRACK_CHANGES_ATTR_DATA_USERNAME,
552
+ {
553
+ name: "data-abbr-action",
554
+ values: ["add", "edit"],
555
+ defaultValue: "add"
556
+ }
557
+ ],
558
+ optionalAttributes: [],
559
+ allowedChildrenCodes: [...ATOM_CODES_ALLOWED_CHILDREN]
560
+ });
561
+
539
562
  // src/schema/elementSchemas/atoms/index.ts
540
563
  var ATOM_SCHEMAS = {
541
564
  indexterm: INDEXTERM_SCHEMA,
@@ -561,7 +584,8 @@ var ATOM_SCHEMAS = {
561
584
  content: CONTENT_SCHEMA,
562
585
  comment: COMMENT_SCHEMA,
563
586
  query: QUERY_SCHEMA,
564
- reply: REPLY_SCHEMA
587
+ reply: REPLY_SCHEMA,
588
+ abbreviation: ABBR_SCHEMA
565
589
  };
566
590
 
567
591
  // src/schema/elementSchemas/elements/elementsTags.ts
@@ -2275,6 +2299,12 @@ var INLINEEQUATION_SCHEMA = createSchema({
2275
2299
  });
2276
2300
 
2277
2301
  // src/schema/elementSchemas/inlineElements/link.ts
2302
+ var TABLE_LINK_ROLE = "table";
2303
+ var FIGURE_LINK_ROLE = "figure";
2304
+ var EQUATION_LINK_ROLE = "equation";
2305
+ var FOOTNOTE_LINK_ROLE = "footnote";
2306
+ var REFERENCE_LINK_ROLE = "bibr";
2307
+ var CHAPTER_LINK_ROLE = "chapter";
2278
2308
  var LINK_SCHEMA = createSchema({
2279
2309
  code: "link",
2280
2310
  kind: "inline",
@@ -2282,14 +2312,20 @@ var LINK_SCHEMA = createSchema({
2282
2312
  requiredAttributes: [
2283
2313
  ...ID_ATTRS,
2284
2314
  "linkend",
2285
- "data-target-id",
2286
2315
  {
2287
2316
  name: "role",
2288
- values: ["table", "figure", "equation", "footnote", "bibr"],
2289
- defaultValue: ""
2317
+ values: [
2318
+ TABLE_LINK_ROLE,
2319
+ FIGURE_LINK_ROLE,
2320
+ EQUATION_LINK_ROLE,
2321
+ FOOTNOTE_LINK_ROLE,
2322
+ REFERENCE_LINK_ROLE,
2323
+ CHAPTER_LINK_ROLE
2324
+ ],
2325
+ defaultValue: "bibr"
2290
2326
  }
2291
2327
  ],
2292
- optionalAttributes: [],
2328
+ optionalAttributes: ["data-target-id"],
2293
2329
  allowedChildrenCodes: [...ATOM_CODES_ALLOWED_CHILDREN]
2294
2330
  });
2295
2331
 
@@ -2522,7 +2558,8 @@ var ElementLabel = {
2522
2558
  inlineequation: "Inline Equation",
2523
2559
  link: "Link",
2524
2560
  uri: "URI",
2525
- phrase: "Phrase"
2561
+ phrase: "Phrase",
2562
+ abbreviation: "Abbreviation"
2526
2563
  };
2527
2564
 
2528
2565
  // src/schema/shared/dependentsForbiddenElements.ts
@@ -2664,6 +2701,13 @@ var validateConsecutiveFootnoteCues = (root) => {
2664
2701
  var findElementLinkedTo = (linkend, elementsToLink) => {
2665
2702
  return elementsToLink.includes(linkend);
2666
2703
  };
2704
+ var LINK_BLOCKER_ROLES = [
2705
+ TABLE_LINK_ROLE,
2706
+ FIGURE_LINK_ROLE,
2707
+ EQUATION_LINK_ROLE,
2708
+ FOOTNOTE_LINK_ROLE,
2709
+ CHAPTER_LINK_ROLE
2710
+ ];
2667
2711
  var validateLinkend = (linkElement, elementsToLink) => {
2668
2712
  const linkend = linkElement.getAttribute("linkend");
2669
2713
  if (!linkend) {
@@ -2684,16 +2728,21 @@ var validateLinkend = (linkElement, elementsToLink) => {
2684
2728
  })
2685
2729
  ];
2686
2730
  }
2731
+ const role = linkElement.getAttribute("role");
2732
+ if (!role) {
2733
+ return [];
2734
+ }
2687
2735
  if (findElementLinkedTo(linkend, elementsToLink)) {
2688
2736
  return [];
2689
2737
  }
2738
+ const isBlocker = LINK_BLOCKER_ROLES.includes(role.toLowerCase());
2690
2739
  return [
2691
2740
  createValidationIssue({
2692
2741
  store: getStore(linkElement),
2693
2742
  title: "Unlinked element",
2694
2743
  kind: "unlinked",
2695
- description: "This link is not referenced to any element in the current chapter or reference chapters. Please link it again manually.",
2696
- level: "blocker"
2744
+ description: "This link is not referenced to any element in the current chapter or any other chapter. Please link it again manually.",
2745
+ level: isBlocker ? "blocker" : "warning"
2697
2746
  })
2698
2747
  ];
2699
2748
  };
@@ -2727,8 +2776,8 @@ var validateAttributes = (element, schema) => {
2727
2776
  }
2728
2777
  if (!definition.values.includes(value)) {
2729
2778
  addValidationIssue(errors, {
2730
- store: element.id,
2731
- title: `Invalid attribute value "${value}"`,
2779
+ store: getStore(element),
2780
+ title: `Invalid attribute value "${value}" in element ${element.tagName}`,
2732
2781
  level: "warning",
2733
2782
  kind: "forbidden",
2734
2783
  description: `The attribute "${name}" has an invalid value "${value}".`
@@ -2862,7 +2911,7 @@ var validateReferenceCited = (referenceElement, linkElements) => {
2862
2911
  title: "Unlinked element",
2863
2912
  kind: "unlinked",
2864
2913
  description: "This reference is not cited in this chapter or any other chapter. Please add a link to this reference or delete the reference.",
2865
- level: "blocker"
2914
+ level: "warning"
2866
2915
  })
2867
2916
  ];
2868
2917
  };
package/dist/index.mjs CHANGED
@@ -59,11 +59,13 @@ var ATOM_CODES_ALLOWED_CHILDREN = [
59
59
  { code: "commentQuerySection", required: false },
60
60
  { code: "comment", required: false },
61
61
  { code: "query", required: false },
62
- { code: "referenceMark", required: false }
62
+ { code: "referenceMark", required: false },
63
+ { code: "abbreviation", required: false }
63
64
  ];
64
65
 
65
66
  // src/schema/elementSchemas/atoms/atomTags.ts
66
67
  var B_TAG = "B";
68
+ var ABBR_TAG = "ABBR";
67
69
  var I_TAG = "I";
68
70
  var U_TAG = "U";
69
71
  var SC_TAG = "SC";
@@ -468,6 +470,27 @@ var REFERENCE_MARK_SCHEMA = createSchema({
468
470
  allowedChildrenCodes: [...ATOM_CODES_ALLOWED_CHILDREN]
469
471
  });
470
472
 
473
+ // src/schema/elementSchemas/atoms/abbr.ts
474
+ var ABBR_SCHEMA = createSchema({
475
+ code: "abbreviation",
476
+ kind: "atom",
477
+ tag: ABBR_TAG,
478
+ requiredAttributes: [
479
+ ...ID_ATTRS,
480
+ "title",
481
+ TRACK_CHANGES_ATTR_DATA_TIME,
482
+ TRACK_CHANGES_ATTR_DATA_USERID,
483
+ TRACK_CHANGES_ATTR_DATA_USERNAME,
484
+ {
485
+ name: "data-abbr-action",
486
+ values: ["add", "edit"],
487
+ defaultValue: "add"
488
+ }
489
+ ],
490
+ optionalAttributes: [],
491
+ allowedChildrenCodes: [...ATOM_CODES_ALLOWED_CHILDREN]
492
+ });
493
+
471
494
  // src/schema/elementSchemas/atoms/index.ts
472
495
  var ATOM_SCHEMAS = {
473
496
  indexterm: INDEXTERM_SCHEMA,
@@ -493,7 +516,8 @@ var ATOM_SCHEMAS = {
493
516
  content: CONTENT_SCHEMA,
494
517
  comment: COMMENT_SCHEMA,
495
518
  query: QUERY_SCHEMA,
496
- reply: REPLY_SCHEMA
519
+ reply: REPLY_SCHEMA,
520
+ abbreviation: ABBR_SCHEMA
497
521
  };
498
522
 
499
523
  // src/schema/elementSchemas/elements/elementsTags.ts
@@ -2207,6 +2231,12 @@ var INLINEEQUATION_SCHEMA = createSchema({
2207
2231
  });
2208
2232
 
2209
2233
  // src/schema/elementSchemas/inlineElements/link.ts
2234
+ var TABLE_LINK_ROLE = "table";
2235
+ var FIGURE_LINK_ROLE = "figure";
2236
+ var EQUATION_LINK_ROLE = "equation";
2237
+ var FOOTNOTE_LINK_ROLE = "footnote";
2238
+ var REFERENCE_LINK_ROLE = "bibr";
2239
+ var CHAPTER_LINK_ROLE = "chapter";
2210
2240
  var LINK_SCHEMA = createSchema({
2211
2241
  code: "link",
2212
2242
  kind: "inline",
@@ -2214,14 +2244,20 @@ var LINK_SCHEMA = createSchema({
2214
2244
  requiredAttributes: [
2215
2245
  ...ID_ATTRS,
2216
2246
  "linkend",
2217
- "data-target-id",
2218
2247
  {
2219
2248
  name: "role",
2220
- values: ["table", "figure", "equation", "footnote", "bibr"],
2221
- defaultValue: ""
2249
+ values: [
2250
+ TABLE_LINK_ROLE,
2251
+ FIGURE_LINK_ROLE,
2252
+ EQUATION_LINK_ROLE,
2253
+ FOOTNOTE_LINK_ROLE,
2254
+ REFERENCE_LINK_ROLE,
2255
+ CHAPTER_LINK_ROLE
2256
+ ],
2257
+ defaultValue: "bibr"
2222
2258
  }
2223
2259
  ],
2224
- optionalAttributes: [],
2260
+ optionalAttributes: ["data-target-id"],
2225
2261
  allowedChildrenCodes: [...ATOM_CODES_ALLOWED_CHILDREN]
2226
2262
  });
2227
2263
 
@@ -2454,7 +2490,8 @@ var ElementLabel = {
2454
2490
  inlineequation: "Inline Equation",
2455
2491
  link: "Link",
2456
2492
  uri: "URI",
2457
- phrase: "Phrase"
2493
+ phrase: "Phrase",
2494
+ abbreviation: "Abbreviation"
2458
2495
  };
2459
2496
 
2460
2497
  // src/schema/shared/dependentsForbiddenElements.ts
@@ -2596,6 +2633,13 @@ var validateConsecutiveFootnoteCues = (root) => {
2596
2633
  var findElementLinkedTo = (linkend, elementsToLink) => {
2597
2634
  return elementsToLink.includes(linkend);
2598
2635
  };
2636
+ var LINK_BLOCKER_ROLES = [
2637
+ TABLE_LINK_ROLE,
2638
+ FIGURE_LINK_ROLE,
2639
+ EQUATION_LINK_ROLE,
2640
+ FOOTNOTE_LINK_ROLE,
2641
+ CHAPTER_LINK_ROLE
2642
+ ];
2599
2643
  var validateLinkend = (linkElement, elementsToLink) => {
2600
2644
  const linkend = linkElement.getAttribute("linkend");
2601
2645
  if (!linkend) {
@@ -2616,16 +2660,21 @@ var validateLinkend = (linkElement, elementsToLink) => {
2616
2660
  })
2617
2661
  ];
2618
2662
  }
2663
+ const role = linkElement.getAttribute("role");
2664
+ if (!role) {
2665
+ return [];
2666
+ }
2619
2667
  if (findElementLinkedTo(linkend, elementsToLink)) {
2620
2668
  return [];
2621
2669
  }
2670
+ const isBlocker = LINK_BLOCKER_ROLES.includes(role.toLowerCase());
2622
2671
  return [
2623
2672
  createValidationIssue({
2624
2673
  store: getStore(linkElement),
2625
2674
  title: "Unlinked element",
2626
2675
  kind: "unlinked",
2627
- description: "This link is not referenced to any element in the current chapter or reference chapters. Please link it again manually.",
2628
- level: "blocker"
2676
+ description: "This link is not referenced to any element in the current chapter or any other chapter. Please link it again manually.",
2677
+ level: isBlocker ? "blocker" : "warning"
2629
2678
  })
2630
2679
  ];
2631
2680
  };
@@ -2659,8 +2708,8 @@ var validateAttributes = (element, schema) => {
2659
2708
  }
2660
2709
  if (!definition.values.includes(value)) {
2661
2710
  addValidationIssue(errors, {
2662
- store: element.id,
2663
- title: `Invalid attribute value "${value}"`,
2711
+ store: getStore(element),
2712
+ title: `Invalid attribute value "${value}" in element ${element.tagName}`,
2664
2713
  level: "warning",
2665
2714
  kind: "forbidden",
2666
2715
  description: `The attribute "${name}" has an invalid value "${value}".`
@@ -2794,7 +2843,7 @@ var validateReferenceCited = (referenceElement, linkElements) => {
2794
2843
  title: "Unlinked element",
2795
2844
  kind: "unlinked",
2796
2845
  description: "This reference is not cited in this chapter or any other chapter. Please add a link to this reference or delete the reference.",
2797
- level: "blocker"
2846
+ level: "warning"
2798
2847
  })
2799
2848
  ];
2800
2849
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "0.2.1",
3
+ "version": "0.2.21",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",