pro-editor-schema 1.1.0 → 1.1.1

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
@@ -17,7 +17,7 @@ type Schema<TRequiredAttributes = readonly AttributeDefinition[], TOptionalAttri
17
17
  requiredAttributes: TRequiredAttributes;
18
18
  optionalAttributes: TOptionalAttributes;
19
19
  defaultChildCode?: SchemaCode;
20
- allowedChildrenCodes: AllowedChildren[];
20
+ allowedChildrenCodes: readonly AllowedChildren[];
21
21
  matchesElement?: (element: Element) => boolean;
22
22
  };
23
23
  type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
package/dist/index.d.ts CHANGED
@@ -17,7 +17,7 @@ type Schema<TRequiredAttributes = readonly AttributeDefinition[], TOptionalAttri
17
17
  requiredAttributes: TRequiredAttributes;
18
18
  optionalAttributes: TOptionalAttributes;
19
19
  defaultChildCode?: SchemaCode;
20
- allowedChildrenCodes: AllowedChildren[];
20
+ allowedChildrenCodes: readonly AllowedChildren[];
21
21
  matchesElement?: (element: Element) => boolean;
22
22
  };
23
23
  type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
package/dist/index.js CHANGED
@@ -1353,6 +1353,7 @@ var FOOTNOTE_SCHEMA = createSchema({
1353
1353
  }
1354
1354
  ],
1355
1355
  optionalAttributes: [...TRACK_CHANGES_ATTRS],
1356
+ defaultChildCode: "para",
1356
1357
  allowedChildrenCodes: [
1357
1358
  { code: "footnoteno", required: false },
1358
1359
  { code: "para", required: false }
@@ -1620,7 +1621,6 @@ var RRH_SCHEMA = createSchema({
1620
1621
  tag: RRH_TAG,
1621
1622
  requiredAttributes: [...ID_ATTRS],
1622
1623
  optionalAttributes: [],
1623
- defaultChildCode: "rrh",
1624
1624
  allowedChildrenCodes: [
1625
1625
  ...ATOM_CODES_ALLOWED_CHILDREN,
1626
1626
  { code: "phrase", required: false }
@@ -1734,7 +1734,6 @@ var HTML_TABLE_SCHEMA = createSchema({
1734
1734
  tag: HTML_TABLE_TAG,
1735
1735
  requiredAttributes: [],
1736
1736
  optionalAttributes: [...ID_ATTRS],
1737
- defaultChildCode: "table",
1738
1737
  allowedChildrenCodes: [
1739
1738
  { code: "thead", required: false },
1740
1739
  { code: "tbody", required: true }
@@ -2011,7 +2010,7 @@ var FOOTNOTE_SECTION_SCHEMA = createSchema({
2011
2010
  }
2012
2011
  ],
2013
2012
  optionalAttributes: [...TRACK_CHANGES_ATTRS],
2014
- defaultChildCode: "para",
2013
+ defaultChildCode: "footnote",
2015
2014
  allowedChildrenCodes: [
2016
2015
  { code: "footnote", required: true },
2017
2016
  { code: "title1", required: true }
@@ -2272,12 +2271,22 @@ var URI_TAG = "URI";
2272
2271
  var PHRASE_TAG = "PHRASE";
2273
2272
 
2274
2273
  // src/schema/elementSchemas/inlineElements/footnoteLink.ts
2274
+ var FOOTNOTE_LINK_ROLES = ["end-ch-note", "end-bk-note"];
2275
2275
  var FOOTNOTE_LINK_SCHEMA = createSchema({
2276
2276
  code: "footnote1",
2277
2277
  kind: "inline",
2278
2278
  tag: FOOTNOTE_LINK_TAG,
2279
- requiredAttributes: [...ID_ATTRS],
2280
- optionalAttributes: ["linkend"],
2279
+ requiredAttributes: [
2280
+ ...ID_ATTRS,
2281
+ {
2282
+ name: "role",
2283
+ values: FOOTNOTE_LINK_ROLES,
2284
+ defaultValue: "end-ch-note"
2285
+ },
2286
+ "label",
2287
+ "linkend"
2288
+ ],
2289
+ optionalAttributes: [],
2281
2290
  defaultChildCode: "sup",
2282
2291
  allowedChildrenCodes: [{ code: "sup", required: true }]
2283
2292
  });
@@ -2341,8 +2350,8 @@ var URI_SCHEMA = createSchema({
2341
2350
  code: "uri",
2342
2351
  kind: "inline",
2343
2352
  tag: URI_TAG,
2344
- requiredAttributes: [LINK_ATTRIBUTE],
2345
- optionalAttributes: [],
2353
+ requiredAttributes: [...ID_ATTRS],
2354
+ optionalAttributes: [LINK_ATTRIBUTE],
2346
2355
  allowedChildrenCodes: [...ATOM_CODES_ALLOWED_CHILDREN]
2347
2356
  });
2348
2357
 
@@ -2378,7 +2387,8 @@ var IGNORED_ELEMENT_SELECTORS = [
2378
2387
  "span.printlabel",
2379
2388
  "span.refIcon",
2380
2389
  "span.missLink",
2381
- "span.ref-drag"
2390
+ "span.ref-drag",
2391
+ "span#dummySpan"
2382
2392
  ];
2383
2393
  var IGNORED_VALIDATION_ELEMENT_SELECTORS = [
2384
2394
  "referenceBibliomixed"
@@ -2725,64 +2735,85 @@ var validateFootnoteCue = (footnoteElement, linkElements) => {
2725
2735
  return errors;
2726
2736
  };
2727
2737
  var validateConsecutiveFootnotes = (root) => {
2728
- const footnotes = getElementsSelector({
2729
- element: root,
2730
- selector: FOOTNOTE_SCHEMA.tag,
2731
- filterDeletedNodes: true
2732
- });
2733
- if (footnotes.length === 0) {
2734
- return [];
2735
- }
2736
- for (const [index, footnote] of footnotes.entries()) {
2737
- const expectedNumber = index + 1;
2738
- const footnoteNumberElement = footnote.querySelector(
2739
- FOOTNOTE_NUMBER_SCHEMA.tag
2738
+ const errors = [];
2739
+ for (const role of FOOTNOTE_SECTION_ROLES) {
2740
+ const footnoteSections = root.querySelectorAll(
2741
+ `${FOOTNOTE_SECTION_SCHEMA.tag}[role="${role}"]`
2740
2742
  );
2741
- if (!footnoteNumberElement) {
2742
- continue;
2743
- }
2744
- const label = extractFootnoteNumber(footnoteNumberElement);
2745
- if (label === expectedNumber) {
2746
- continue;
2743
+ for (const footnoteSection of footnoteSections) {
2744
+ const footnotes = getElementsSelector({
2745
+ element: footnoteSection,
2746
+ selector: FOOTNOTE_SCHEMA.tag,
2747
+ filterDeletedNodes: true
2748
+ });
2749
+ if (footnotes.length === 0) {
2750
+ continue;
2751
+ }
2752
+ for (const [index, footnote] of footnotes.entries()) {
2753
+ const expectedNumber = index + 1;
2754
+ const footnoteNumberElement = footnote.querySelector(
2755
+ FOOTNOTE_NUMBER_SCHEMA.tag
2756
+ );
2757
+ if (!footnoteNumberElement) {
2758
+ errors.push(
2759
+ createValidationIssue({
2760
+ store: getStore(footnote),
2761
+ title: "Footnote number missing",
2762
+ kind: "missing",
2763
+ description: "The footnote number is missing. Please add it to the footnote.",
2764
+ level: "blocker"
2765
+ })
2766
+ );
2767
+ }
2768
+ const label = extractFootnoteNumber(footnoteNumberElement);
2769
+ if (label === expectedNumber) {
2770
+ continue;
2771
+ }
2772
+ errors.push(
2773
+ createValidationIssue({
2774
+ store: getStore(footnote),
2775
+ title: "Non-consecutive footnote numbers",
2776
+ kind: "missing",
2777
+ description: `Footnote numbers must be consecutive, footnote number (${label}) expected to be (${expectedNumber}). Please reorder the footnotes.`,
2778
+ level: "warning"
2779
+ })
2780
+ );
2781
+ break;
2782
+ }
2747
2783
  }
2748
- return [
2749
- createValidationIssue({
2750
- store: getStore(footnote),
2751
- title: "Non-consecutive footnote numbers",
2752
- kind: "missing",
2753
- description: "Footnote numbers must be consecutive. Please reorder the footnotes.",
2754
- level: "warning"
2755
- })
2756
- ];
2757
2784
  }
2758
- return [];
2785
+ return errors;
2759
2786
  };
2760
2787
  var validateConsecutiveFootnoteCues = (root) => {
2761
- const footnoteLinks = getElementsSelector({
2762
- element: root,
2763
- selector: FOOTNOTE_LINK_SCHEMA.tag,
2764
- filterDeletedNodes: true
2765
- });
2766
- if (footnoteLinks.length === 0) {
2767
- return [];
2768
- }
2769
- for (const [index, footnoteLink] of footnoteLinks.entries()) {
2770
- const expectedNumber = index + 1;
2771
- const label = extractFootnoteNumber(footnoteLink);
2772
- if (label === expectedNumber) {
2788
+ const errors = [];
2789
+ for (const role of FOOTNOTE_LINK_ROLES) {
2790
+ const footnoteLinks = getElementsSelector({
2791
+ element: root,
2792
+ selector: `${FOOTNOTE_LINK_SCHEMA.tag}[role="${role}"]`,
2793
+ filterDeletedNodes: true
2794
+ });
2795
+ if (footnoteLinks.length === 0) {
2773
2796
  continue;
2774
2797
  }
2775
- return [
2776
- createValidationIssue({
2777
- store: getStore(footnoteLink),
2778
- title: "Non-consecutive footnote cues",
2779
- kind: "missing",
2780
- description: "Footnote cues must be consecutive. Please reorder the footnote cues.",
2781
- level: "warning"
2782
- })
2783
- ];
2798
+ for (const [index, footnoteLink] of footnoteLinks.entries()) {
2799
+ const expectedNumber = index + 1;
2800
+ const label = extractFootnoteNumber(footnoteLink);
2801
+ if (label === expectedNumber) {
2802
+ continue;
2803
+ }
2804
+ errors.push(
2805
+ createValidationIssue({
2806
+ store: getStore(footnoteLink),
2807
+ title: "Non-consecutive footnote cues",
2808
+ kind: "missing",
2809
+ description: "Footnote cues must be consecutive. Please reorder the footnote cues.",
2810
+ level: "warning"
2811
+ })
2812
+ );
2813
+ break;
2814
+ }
2784
2815
  }
2785
- return [];
2816
+ return errors;
2786
2817
  };
2787
2818
 
2788
2819
  // src/validation/validateAttributes.ts
package/dist/index.mjs CHANGED
@@ -1285,6 +1285,7 @@ var FOOTNOTE_SCHEMA = createSchema({
1285
1285
  }
1286
1286
  ],
1287
1287
  optionalAttributes: [...TRACK_CHANGES_ATTRS],
1288
+ defaultChildCode: "para",
1288
1289
  allowedChildrenCodes: [
1289
1290
  { code: "footnoteno", required: false },
1290
1291
  { code: "para", required: false }
@@ -1552,7 +1553,6 @@ var RRH_SCHEMA = createSchema({
1552
1553
  tag: RRH_TAG,
1553
1554
  requiredAttributes: [...ID_ATTRS],
1554
1555
  optionalAttributes: [],
1555
- defaultChildCode: "rrh",
1556
1556
  allowedChildrenCodes: [
1557
1557
  ...ATOM_CODES_ALLOWED_CHILDREN,
1558
1558
  { code: "phrase", required: false }
@@ -1666,7 +1666,6 @@ var HTML_TABLE_SCHEMA = createSchema({
1666
1666
  tag: HTML_TABLE_TAG,
1667
1667
  requiredAttributes: [],
1668
1668
  optionalAttributes: [...ID_ATTRS],
1669
- defaultChildCode: "table",
1670
1669
  allowedChildrenCodes: [
1671
1670
  { code: "thead", required: false },
1672
1671
  { code: "tbody", required: true }
@@ -1943,7 +1942,7 @@ var FOOTNOTE_SECTION_SCHEMA = createSchema({
1943
1942
  }
1944
1943
  ],
1945
1944
  optionalAttributes: [...TRACK_CHANGES_ATTRS],
1946
- defaultChildCode: "para",
1945
+ defaultChildCode: "footnote",
1947
1946
  allowedChildrenCodes: [
1948
1947
  { code: "footnote", required: true },
1949
1948
  { code: "title1", required: true }
@@ -2204,12 +2203,22 @@ var URI_TAG = "URI";
2204
2203
  var PHRASE_TAG = "PHRASE";
2205
2204
 
2206
2205
  // src/schema/elementSchemas/inlineElements/footnoteLink.ts
2206
+ var FOOTNOTE_LINK_ROLES = ["end-ch-note", "end-bk-note"];
2207
2207
  var FOOTNOTE_LINK_SCHEMA = createSchema({
2208
2208
  code: "footnote1",
2209
2209
  kind: "inline",
2210
2210
  tag: FOOTNOTE_LINK_TAG,
2211
- requiredAttributes: [...ID_ATTRS],
2212
- optionalAttributes: ["linkend"],
2211
+ requiredAttributes: [
2212
+ ...ID_ATTRS,
2213
+ {
2214
+ name: "role",
2215
+ values: FOOTNOTE_LINK_ROLES,
2216
+ defaultValue: "end-ch-note"
2217
+ },
2218
+ "label",
2219
+ "linkend"
2220
+ ],
2221
+ optionalAttributes: [],
2213
2222
  defaultChildCode: "sup",
2214
2223
  allowedChildrenCodes: [{ code: "sup", required: true }]
2215
2224
  });
@@ -2273,8 +2282,8 @@ var URI_SCHEMA = createSchema({
2273
2282
  code: "uri",
2274
2283
  kind: "inline",
2275
2284
  tag: URI_TAG,
2276
- requiredAttributes: [LINK_ATTRIBUTE],
2277
- optionalAttributes: [],
2285
+ requiredAttributes: [...ID_ATTRS],
2286
+ optionalAttributes: [LINK_ATTRIBUTE],
2278
2287
  allowedChildrenCodes: [...ATOM_CODES_ALLOWED_CHILDREN]
2279
2288
  });
2280
2289
 
@@ -2310,7 +2319,8 @@ var IGNORED_ELEMENT_SELECTORS = [
2310
2319
  "span.printlabel",
2311
2320
  "span.refIcon",
2312
2321
  "span.missLink",
2313
- "span.ref-drag"
2322
+ "span.ref-drag",
2323
+ "span#dummySpan"
2314
2324
  ];
2315
2325
  var IGNORED_VALIDATION_ELEMENT_SELECTORS = [
2316
2326
  "referenceBibliomixed"
@@ -2657,64 +2667,85 @@ var validateFootnoteCue = (footnoteElement, linkElements) => {
2657
2667
  return errors;
2658
2668
  };
2659
2669
  var validateConsecutiveFootnotes = (root) => {
2660
- const footnotes = getElementsSelector({
2661
- element: root,
2662
- selector: FOOTNOTE_SCHEMA.tag,
2663
- filterDeletedNodes: true
2664
- });
2665
- if (footnotes.length === 0) {
2666
- return [];
2667
- }
2668
- for (const [index, footnote] of footnotes.entries()) {
2669
- const expectedNumber = index + 1;
2670
- const footnoteNumberElement = footnote.querySelector(
2671
- FOOTNOTE_NUMBER_SCHEMA.tag
2670
+ const errors = [];
2671
+ for (const role of FOOTNOTE_SECTION_ROLES) {
2672
+ const footnoteSections = root.querySelectorAll(
2673
+ `${FOOTNOTE_SECTION_SCHEMA.tag}[role="${role}"]`
2672
2674
  );
2673
- if (!footnoteNumberElement) {
2674
- continue;
2675
- }
2676
- const label = extractFootnoteNumber(footnoteNumberElement);
2677
- if (label === expectedNumber) {
2678
- continue;
2675
+ for (const footnoteSection of footnoteSections) {
2676
+ const footnotes = getElementsSelector({
2677
+ element: footnoteSection,
2678
+ selector: FOOTNOTE_SCHEMA.tag,
2679
+ filterDeletedNodes: true
2680
+ });
2681
+ if (footnotes.length === 0) {
2682
+ continue;
2683
+ }
2684
+ for (const [index, footnote] of footnotes.entries()) {
2685
+ const expectedNumber = index + 1;
2686
+ const footnoteNumberElement = footnote.querySelector(
2687
+ FOOTNOTE_NUMBER_SCHEMA.tag
2688
+ );
2689
+ if (!footnoteNumberElement) {
2690
+ errors.push(
2691
+ createValidationIssue({
2692
+ store: getStore(footnote),
2693
+ title: "Footnote number missing",
2694
+ kind: "missing",
2695
+ description: "The footnote number is missing. Please add it to the footnote.",
2696
+ level: "blocker"
2697
+ })
2698
+ );
2699
+ }
2700
+ const label = extractFootnoteNumber(footnoteNumberElement);
2701
+ if (label === expectedNumber) {
2702
+ continue;
2703
+ }
2704
+ errors.push(
2705
+ createValidationIssue({
2706
+ store: getStore(footnote),
2707
+ title: "Non-consecutive footnote numbers",
2708
+ kind: "missing",
2709
+ description: `Footnote numbers must be consecutive, footnote number (${label}) expected to be (${expectedNumber}). Please reorder the footnotes.`,
2710
+ level: "warning"
2711
+ })
2712
+ );
2713
+ break;
2714
+ }
2679
2715
  }
2680
- return [
2681
- createValidationIssue({
2682
- store: getStore(footnote),
2683
- title: "Non-consecutive footnote numbers",
2684
- kind: "missing",
2685
- description: "Footnote numbers must be consecutive. Please reorder the footnotes.",
2686
- level: "warning"
2687
- })
2688
- ];
2689
2716
  }
2690
- return [];
2717
+ return errors;
2691
2718
  };
2692
2719
  var validateConsecutiveFootnoteCues = (root) => {
2693
- const footnoteLinks = getElementsSelector({
2694
- element: root,
2695
- selector: FOOTNOTE_LINK_SCHEMA.tag,
2696
- filterDeletedNodes: true
2697
- });
2698
- if (footnoteLinks.length === 0) {
2699
- return [];
2700
- }
2701
- for (const [index, footnoteLink] of footnoteLinks.entries()) {
2702
- const expectedNumber = index + 1;
2703
- const label = extractFootnoteNumber(footnoteLink);
2704
- if (label === expectedNumber) {
2720
+ const errors = [];
2721
+ for (const role of FOOTNOTE_LINK_ROLES) {
2722
+ const footnoteLinks = getElementsSelector({
2723
+ element: root,
2724
+ selector: `${FOOTNOTE_LINK_SCHEMA.tag}[role="${role}"]`,
2725
+ filterDeletedNodes: true
2726
+ });
2727
+ if (footnoteLinks.length === 0) {
2705
2728
  continue;
2706
2729
  }
2707
- return [
2708
- createValidationIssue({
2709
- store: getStore(footnoteLink),
2710
- title: "Non-consecutive footnote cues",
2711
- kind: "missing",
2712
- description: "Footnote cues must be consecutive. Please reorder the footnote cues.",
2713
- level: "warning"
2714
- })
2715
- ];
2730
+ for (const [index, footnoteLink] of footnoteLinks.entries()) {
2731
+ const expectedNumber = index + 1;
2732
+ const label = extractFootnoteNumber(footnoteLink);
2733
+ if (label === expectedNumber) {
2734
+ continue;
2735
+ }
2736
+ errors.push(
2737
+ createValidationIssue({
2738
+ store: getStore(footnoteLink),
2739
+ title: "Non-consecutive footnote cues",
2740
+ kind: "missing",
2741
+ description: "Footnote cues must be consecutive. Please reorder the footnote cues.",
2742
+ level: "warning"
2743
+ })
2744
+ );
2745
+ break;
2746
+ }
2716
2747
  }
2717
- return [];
2748
+ return errors;
2718
2749
  };
2719
2750
 
2720
2751
  // src/validation/validateAttributes.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",