pro-editor-schema 0.1.194 → 0.1.196

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
@@ -26,7 +26,7 @@ type Schema<TRequiredAttributes = readonly AttributeDefinition[], TOptionalAttri
26
26
  forbiddenElements?: ReadonlySet<ForbiddenElement>;
27
27
  };
28
28
  type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
29
- type ElementSchemaCode = "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";
29
+ 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";
30
30
  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";
31
31
  type InlineSchemaCode = "footnote1" | "inlineequation" | "link" | "uri";
32
32
  declare const ElementLabel: Record<SchemaCode, string>;
@@ -103,11 +103,12 @@ type ValidationError = {
103
103
  * Validates the XML document against the schema.
104
104
 
105
105
  * @param xml - The XML document to validate.
106
- * @param elementsLinkedTo - The elements IDs that are linked to.
106
+ * @param elementsToLink - The elements IDs that are linked to.
107
+ * @param linkElements - The elements IDs that are linked to.
107
108
  * @param schemasToValidateAgainst - The schemas to validate against.
108
109
  * * ValidateConsecutiveFootnotes and ValidateConsecutiveFootnoteCues are default validations.
109
110
  * @returns The validation errors.
110
111
  */
111
- declare const validateXml: (xml: Element, elementsLinkedTo: readonly string[], schemasToValidateAgainst: SchemaCode[]) => ValidationError[];
112
+ declare const validateXml: (xml: Element, elementsToLink: readonly string[], linkElements: readonly string[], schemasToValidateAgainst: SchemaCode[]) => ValidationError[];
112
113
 
113
114
  export { ALIGNMENT_ATTRIBUTE, ATOM_SCHEMAS, type AllowedChildren, type AtomSchemaCode, type AttributeDefinition, ELEMENT_SCHEMAS, ELE_ID_ATTRIBUTE, ElementLabel, type ElementSchemaCode, FIGURE_PLACEMENT_ATTRIBUTE, type ForbiddenElement, type FreeAttribute, ID_ATTRS, IGNORED_ATTRIBUTES, IGNORED_ATTRIBUTES_STARTS_WITH, IGNORED_ELEMENT_SELECTORS, INDENT_TYPE_ATTRIBUTE, INLINE_ELEMENT_SCHEMAS, type InlineSchemaCode, LAYOUT_ATTRIBUTES, LAYOUT_CELL_WIDTH_ATTRIBUTE, LAYOUT_TABLE_ORIENTATION_ATTRIBUTE, LAYOUT_TABLE_PLACEMENT_ATTRIBUTE, LAYOUT_USER_ATTRIBUTE, LEFT_INDENT_ATTRIBUTE, RIGHT_INDENT_ATTRIBUTE, type ResolveTo, type RestrictedAttribute, SCHEMAS, SPACE_ABOVE_ATTRIBUTE, SPACE_BELOW_ATTRIBUTE, SPECIAL_INDENT_ATTRIBUTE, STORE_ATTRIBUTE, STYLE_NAME_ATTRIBUTE, type Schema, type SchemaCode, type SchemaKind, TRACK_CHANGES_ATTRS, TRACK_CHANGES_ATTR_DATA_DATE, TRACK_CHANGES_ATTR_DATA_TIME, TRACK_CHANGES_ATTR_DATA_USERID, TRACK_CHANGES_ATTR_DATA_USERNAME, type ValidationError, type ValidationErrorKind, type ValidationErrorLevel, createElement, findAttributeDefinitionByName, findSchemaByCode, findSchemaByElement, findSchemaByTagName, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement, validateXml };
package/dist/index.d.ts CHANGED
@@ -26,7 +26,7 @@ type Schema<TRequiredAttributes = readonly AttributeDefinition[], TOptionalAttri
26
26
  forbiddenElements?: ReadonlySet<ForbiddenElement>;
27
27
  };
28
28
  type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
29
- type ElementSchemaCode = "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";
29
+ 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";
30
30
  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";
31
31
  type InlineSchemaCode = "footnote1" | "inlineequation" | "link" | "uri";
32
32
  declare const ElementLabel: Record<SchemaCode, string>;
@@ -103,11 +103,12 @@ type ValidationError = {
103
103
  * Validates the XML document against the schema.
104
104
 
105
105
  * @param xml - The XML document to validate.
106
- * @param elementsLinkedTo - The elements IDs that are linked to.
106
+ * @param elementsToLink - The elements IDs that are linked to.
107
+ * @param linkElements - The elements IDs that are linked to.
107
108
  * @param schemasToValidateAgainst - The schemas to validate against.
108
109
  * * ValidateConsecutiveFootnotes and ValidateConsecutiveFootnoteCues are default validations.
109
110
  * @returns The validation errors.
110
111
  */
111
- declare const validateXml: (xml: Element, elementsLinkedTo: readonly string[], schemasToValidateAgainst: SchemaCode[]) => ValidationError[];
112
+ declare const validateXml: (xml: Element, elementsToLink: readonly string[], linkElements: readonly string[], schemasToValidateAgainst: SchemaCode[]) => ValidationError[];
112
113
 
113
114
  export { ALIGNMENT_ATTRIBUTE, ATOM_SCHEMAS, type AllowedChildren, type AtomSchemaCode, type AttributeDefinition, ELEMENT_SCHEMAS, ELE_ID_ATTRIBUTE, ElementLabel, type ElementSchemaCode, FIGURE_PLACEMENT_ATTRIBUTE, type ForbiddenElement, type FreeAttribute, ID_ATTRS, IGNORED_ATTRIBUTES, IGNORED_ATTRIBUTES_STARTS_WITH, IGNORED_ELEMENT_SELECTORS, INDENT_TYPE_ATTRIBUTE, INLINE_ELEMENT_SCHEMAS, type InlineSchemaCode, LAYOUT_ATTRIBUTES, LAYOUT_CELL_WIDTH_ATTRIBUTE, LAYOUT_TABLE_ORIENTATION_ATTRIBUTE, LAYOUT_TABLE_PLACEMENT_ATTRIBUTE, LAYOUT_USER_ATTRIBUTE, LEFT_INDENT_ATTRIBUTE, RIGHT_INDENT_ATTRIBUTE, type ResolveTo, type RestrictedAttribute, SCHEMAS, SPACE_ABOVE_ATTRIBUTE, SPACE_BELOW_ATTRIBUTE, SPECIAL_INDENT_ATTRIBUTE, STORE_ATTRIBUTE, STYLE_NAME_ATTRIBUTE, type Schema, type SchemaCode, type SchemaKind, TRACK_CHANGES_ATTRS, TRACK_CHANGES_ATTR_DATA_DATE, TRACK_CHANGES_ATTR_DATA_TIME, TRACK_CHANGES_ATTR_DATA_USERID, TRACK_CHANGES_ATTR_DATA_USERNAME, type ValidationError, type ValidationErrorKind, type ValidationErrorLevel, createElement, findAttributeDefinitionByName, findSchemaByCode, findSchemaByElement, findSchemaByTagName, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement, validateXml };
package/dist/index.js CHANGED
@@ -647,6 +647,8 @@ var EPIGRAPH_TAG = "EPIGRAPH";
647
647
  var INFO_TAG = "INFO1";
648
648
  var POEM_TAG = "POEM";
649
649
  var BIBLIOMIXED_TAG = "BIBLIOMIXED";
650
+ var REFERENCE_BIBLIOGRAPHY_TAG = "REFERENCE_BIBLIOGRAPHY";
651
+ var BIBLIODIV_TAG = "BIBLIODIV";
650
652
  var MATHPHRASE_TAG = "MATHPHRASE";
651
653
  var MATH_TAG = "MATH";
652
654
  var MERROR_TAG = "MERROR";
@@ -1953,7 +1955,8 @@ var CHAPTER_SCHEMA = createSchema({
1953
1955
  { tagName: DIALOGUE_TAG, required: false },
1954
1956
  { tagName: APPENDIX_TAG, required: false },
1955
1957
  { tagName: TABLE_TAG, required: false },
1956
- { tagName: FIGURE_TAG, required: false }
1958
+ { tagName: FIGURE_TAG, required: false },
1959
+ { tagName: REFERENCE_BIBLIOGRAPHY_TAG, required: false }
1957
1960
  ]
1958
1961
  });
1959
1962
 
@@ -2082,8 +2085,75 @@ var MATHPHRASE_SCHEMA = createSchema({
2082
2085
  ]
2083
2086
  });
2084
2087
 
2088
+ // src/schema/elementSchemas/elements/reference/bibliodiv.ts
2089
+ var BIBLIODIV_SCHEMA = createSchema({
2090
+ code: "bibliodiv",
2091
+ kind: "element",
2092
+ tag: BIBLIODIV_TAG,
2093
+ requiredAttributes: [
2094
+ ...ID_ATTRS,
2095
+ {
2096
+ name: "role",
2097
+ values: ["H1", "H2", "H3", "H4", "H5", "H6"],
2098
+ defaultValue: "H1"
2099
+ }
2100
+ ],
2101
+ optionalAttributes: [],
2102
+ allowedChildTagNames: [
2103
+ { tagName: BIBLIODIV_TAG, required: false },
2104
+ { tagName: BIBLIOMIXED_TAG, required: false },
2105
+ { tagName: PARA_TAG, required: false },
2106
+ { tagName: TITLE_TAG, required: false }
2107
+ ]
2108
+ });
2109
+
2110
+ // src/schema/elementSchemas/elements/reference/bibliography.ts
2111
+ var REFERENCE_BIBLIOGRAPHY_SCHEMA = createSchema({
2112
+ code: "referenceBibliography",
2113
+ kind: "element",
2114
+ tag: REFERENCE_BIBLIOGRAPHY_TAG,
2115
+ requiredAttributes: [
2116
+ ...ID_ATTRS,
2117
+ "xmlid",
2118
+ {
2119
+ name: "role",
2120
+ values: ["chapterend"],
2121
+ defaultValue: "chapterend"
2122
+ },
2123
+ {
2124
+ name: "doc-type",
2125
+ values: ["doc-bibliography"],
2126
+ defaultValue: "doc-bibliography"
2127
+ }
2128
+ ],
2129
+ optionalAttributes: [],
2130
+ allowedChildTagNames: [
2131
+ { tagName: BIBLIODIV_TAG, required: false },
2132
+ { tagName: BIBLIOMIXED_TAG, required: false },
2133
+ { tagName: PARA_TAG, required: false },
2134
+ { tagName: TITLE_TAG, required: false }
2135
+ ]
2136
+ });
2137
+
2138
+ // src/schema/elementSchemas/elements/reference/bibliomixed.ts
2139
+ var BIBLIOMIXED_SCHEMA = createSchema({
2140
+ code: "referenceBibliomixed",
2141
+ kind: "element",
2142
+ tag: BIBLIOMIXED_TAG,
2143
+ requiredAttributes: [...ID_ATTRS, "xmlid", "role"],
2144
+ optionalAttributes: [
2145
+ "track-role",
2146
+ TRACK_CHANGES_ATTR_DATA_USERID,
2147
+ TRACK_CHANGES_ATTR_DATA_DATE
2148
+ ],
2149
+ allowedChildTagNames: []
2150
+ });
2151
+
2085
2152
  // src/schema/elementSchemas/elements/index.ts
2086
2153
  var ELEMENT_SCHEMAS = {
2154
+ bibliodiv: BIBLIODIV_SCHEMA,
2155
+ referenceBibliography: REFERENCE_BIBLIOGRAPHY_SCHEMA,
2156
+ referenceBibliomixed: BIBLIOMIXED_SCHEMA,
2087
2157
  para: PARA_SCHEMA,
2088
2158
  title1: TITLE_SCHEMA,
2089
2159
  footnote: FOOTNOTE_SCHEMA,
@@ -2259,6 +2329,9 @@ var SCHEMAS = {
2259
2329
 
2260
2330
  // src/schema/schema.types.ts
2261
2331
  var ElementLabel = {
2332
+ referenceBibliomixed: "Reference Bibliomixed",
2333
+ referenceBibliography: "Reference Bibliography",
2334
+ bibliodiv: "Bibliodiv",
2262
2335
  indexterm: "Indexterm",
2263
2336
  primary: "Primary",
2264
2337
  secondary: "Secondary",
@@ -2384,9 +2457,7 @@ var IGNORED_ELEMENT_SELECTORS = [
2384
2457
  "span.printlabel",
2385
2458
  "span.refIcon",
2386
2459
  "span.missLink",
2387
- "span.ref-drag",
2388
- "bibliomixed"
2389
- // TODO: Remove this once we have a proper schema for bibliomixed
2460
+ "span.ref-drag"
2390
2461
  ];
2391
2462
 
2392
2463
  // src/schema/shared/ignoredAttributes.ts
@@ -2612,17 +2683,17 @@ var validateConsecutiveFootnoteCues = (root) => {
2612
2683
  };
2613
2684
 
2614
2685
  // src/validation/validateLinkend.ts
2615
- var findElementLinkedTo = (linkend, elementsLinkedTo) => {
2616
- return elementsLinkedTo.includes(linkend);
2686
+ var findElementLinkedTo = (linkend, elementsToLink) => {
2687
+ return elementsToLink.includes(linkend);
2617
2688
  };
2618
- var validateLinkend = (linkElement, elementsLinkedTo) => {
2689
+ var validateLinkend = (linkElement, elementsToLink) => {
2619
2690
  const linkend = linkElement.getAttribute("linkend");
2620
2691
  if (!linkend) {
2621
2692
  return [];
2622
2693
  }
2623
2694
  const isLinkFootnoteCue = linkElement.tagName.toUpperCase() === FOOTNOTE_LINK_SCHEMA.tag;
2624
2695
  if (isLinkFootnoteCue) {
2625
- if (findElementLinkedTo(linkend, elementsLinkedTo)) {
2696
+ if (findElementLinkedTo(linkend, elementsToLink)) {
2626
2697
  return [];
2627
2698
  }
2628
2699
  return [
@@ -2635,7 +2706,7 @@ var validateLinkend = (linkElement, elementsLinkedTo) => {
2635
2706
  })
2636
2707
  ];
2637
2708
  }
2638
- if (findElementLinkedTo(linkend, elementsLinkedTo)) {
2709
+ if (findElementLinkedTo(linkend, elementsToLink)) {
2639
2710
  return [];
2640
2711
  }
2641
2712
  return [
@@ -2701,33 +2772,6 @@ var validateElementAgainstSchema = (element, schema, inheritedForbiddenScope) =>
2701
2772
  description: `The element is not allowed in this context.`
2702
2773
  });
2703
2774
  }
2704
- if (schema.code === "insertion" && !element.classList.contains("ins")) {
2705
- addValidationIssue(errors, {
2706
- store: getStore(element),
2707
- title: 'Missing class "ins" for insertion element',
2708
- level: "warning",
2709
- kind: "missing",
2710
- description: `The element is missing the class "ins".`
2711
- });
2712
- }
2713
- if (schema.code === "deletion" && !element.classList.contains("del")) {
2714
- addValidationIssue(errors, {
2715
- store: getStore(element),
2716
- title: 'Missing class "del" for deletion element',
2717
- level: "warning",
2718
- kind: "missing",
2719
- description: `The element is missing the class "del".`
2720
- });
2721
- }
2722
- if (schema.code === "commentQuerySection" && !element.classList.contains("cmtQurySection")) {
2723
- addValidationIssue(errors, {
2724
- store: getStore(element),
2725
- title: 'Missing class "cmtQurySection" for comment query section',
2726
- level: "warning",
2727
- kind: "missing",
2728
- description: `The element is missing the class "cmtQurySection".`
2729
- });
2730
- }
2731
2775
  errors.push(...validateAttributes(element, schema));
2732
2776
  errors.push(...validateChildren(element, schema, inheritedForbiddenScope));
2733
2777
  return errors;
@@ -2836,8 +2880,31 @@ var getLinkableRoles = () => {
2836
2880
  return [];
2837
2881
  };
2838
2882
 
2883
+ // src/validation/validateReferences.ts
2884
+ var findElementLinkedTo2 = (xmlid, linkElements) => {
2885
+ return linkElements.includes(xmlid);
2886
+ };
2887
+ var validateReferenceCited = (referenceElement, linkElements) => {
2888
+ const xmlid = referenceElement.getAttribute("xmlid");
2889
+ if (!xmlid) {
2890
+ return [];
2891
+ }
2892
+ if (findElementLinkedTo2(xmlid, linkElements)) {
2893
+ return [];
2894
+ }
2895
+ return [
2896
+ createValidationIssue({
2897
+ store: getStore(referenceElement),
2898
+ title: "Unlinked element",
2899
+ kind: "unlinked",
2900
+ description: "This reference is not cited in this chapter or any other chapter. Please add a link to this reference or delete the reference.",
2901
+ level: "blocker"
2902
+ })
2903
+ ];
2904
+ };
2905
+
2839
2906
  // src/validation/validateXml.ts
2840
- var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst) => {
2907
+ var validateElement = (element, root, elementsToLink, linkElements, schemasToValidateAgainst) => {
2841
2908
  if (isIgnoredElement(element)) {
2842
2909
  return [];
2843
2910
  }
@@ -2856,7 +2923,11 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2856
2923
  const role = element.getAttribute("role") || "";
2857
2924
  const linkableRoles = getLinkableRoles();
2858
2925
  if (schema.tag === LINK_SCHEMA.tag && linkableRoles.includes(role) || schema.tag === FOOTNOTE_LINK_SCHEMA.tag) {
2859
- errors.push(...validateLinkend(element, elementsLinkedTo));
2926
+ errors.push(...validateLinkend(element, elementsToLink));
2927
+ }
2928
+ if (schema.tag === BIBLIOMIXED_SCHEMA.tag) {
2929
+ errors.push(...validateReferenceCited(element, linkElements));
2930
+ return errors;
2860
2931
  }
2861
2932
  if (schema.tag === FOOTNOTE_SCHEMA.tag) {
2862
2933
  errors.push(...validateFootnoteCue(element, root));
@@ -2867,14 +2938,15 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2867
2938
  ...validateElement(
2868
2939
  child,
2869
2940
  root,
2870
- elementsLinkedTo,
2941
+ elementsToLink,
2942
+ linkElements,
2871
2943
  schemasToValidateAgainst
2872
2944
  )
2873
2945
  );
2874
2946
  }
2875
2947
  return errors;
2876
2948
  };
2877
- var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2949
+ var validateXml = (xml, elementsToLink, linkElements, schemasToValidateAgainst) => {
2878
2950
  const errors = [];
2879
2951
  errors.push(...validateConsecutiveFootnotes(xml));
2880
2952
  errors.push(...validateConsecutiveFootnoteCues(xml));
@@ -2883,7 +2955,8 @@ var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2883
2955
  ...validateElement(
2884
2956
  child,
2885
2957
  xml,
2886
- elementsLinkedTo,
2958
+ elementsToLink,
2959
+ linkElements,
2887
2960
  schemasToValidateAgainst
2888
2961
  )
2889
2962
  );
package/dist/index.mjs CHANGED
@@ -582,6 +582,8 @@ var EPIGRAPH_TAG = "EPIGRAPH";
582
582
  var INFO_TAG = "INFO1";
583
583
  var POEM_TAG = "POEM";
584
584
  var BIBLIOMIXED_TAG = "BIBLIOMIXED";
585
+ var REFERENCE_BIBLIOGRAPHY_TAG = "REFERENCE_BIBLIOGRAPHY";
586
+ var BIBLIODIV_TAG = "BIBLIODIV";
585
587
  var MATHPHRASE_TAG = "MATHPHRASE";
586
588
  var MATH_TAG = "MATH";
587
589
  var MERROR_TAG = "MERROR";
@@ -1888,7 +1890,8 @@ var CHAPTER_SCHEMA = createSchema({
1888
1890
  { tagName: DIALOGUE_TAG, required: false },
1889
1891
  { tagName: APPENDIX_TAG, required: false },
1890
1892
  { tagName: TABLE_TAG, required: false },
1891
- { tagName: FIGURE_TAG, required: false }
1893
+ { tagName: FIGURE_TAG, required: false },
1894
+ { tagName: REFERENCE_BIBLIOGRAPHY_TAG, required: false }
1892
1895
  ]
1893
1896
  });
1894
1897
 
@@ -2017,8 +2020,75 @@ var MATHPHRASE_SCHEMA = createSchema({
2017
2020
  ]
2018
2021
  });
2019
2022
 
2023
+ // src/schema/elementSchemas/elements/reference/bibliodiv.ts
2024
+ var BIBLIODIV_SCHEMA = createSchema({
2025
+ code: "bibliodiv",
2026
+ kind: "element",
2027
+ tag: BIBLIODIV_TAG,
2028
+ requiredAttributes: [
2029
+ ...ID_ATTRS,
2030
+ {
2031
+ name: "role",
2032
+ values: ["H1", "H2", "H3", "H4", "H5", "H6"],
2033
+ defaultValue: "H1"
2034
+ }
2035
+ ],
2036
+ optionalAttributes: [],
2037
+ allowedChildTagNames: [
2038
+ { tagName: BIBLIODIV_TAG, required: false },
2039
+ { tagName: BIBLIOMIXED_TAG, required: false },
2040
+ { tagName: PARA_TAG, required: false },
2041
+ { tagName: TITLE_TAG, required: false }
2042
+ ]
2043
+ });
2044
+
2045
+ // src/schema/elementSchemas/elements/reference/bibliography.ts
2046
+ var REFERENCE_BIBLIOGRAPHY_SCHEMA = createSchema({
2047
+ code: "referenceBibliography",
2048
+ kind: "element",
2049
+ tag: REFERENCE_BIBLIOGRAPHY_TAG,
2050
+ requiredAttributes: [
2051
+ ...ID_ATTRS,
2052
+ "xmlid",
2053
+ {
2054
+ name: "role",
2055
+ values: ["chapterend"],
2056
+ defaultValue: "chapterend"
2057
+ },
2058
+ {
2059
+ name: "doc-type",
2060
+ values: ["doc-bibliography"],
2061
+ defaultValue: "doc-bibliography"
2062
+ }
2063
+ ],
2064
+ optionalAttributes: [],
2065
+ allowedChildTagNames: [
2066
+ { tagName: BIBLIODIV_TAG, required: false },
2067
+ { tagName: BIBLIOMIXED_TAG, required: false },
2068
+ { tagName: PARA_TAG, required: false },
2069
+ { tagName: TITLE_TAG, required: false }
2070
+ ]
2071
+ });
2072
+
2073
+ // src/schema/elementSchemas/elements/reference/bibliomixed.ts
2074
+ var BIBLIOMIXED_SCHEMA = createSchema({
2075
+ code: "referenceBibliomixed",
2076
+ kind: "element",
2077
+ tag: BIBLIOMIXED_TAG,
2078
+ requiredAttributes: [...ID_ATTRS, "xmlid", "role"],
2079
+ optionalAttributes: [
2080
+ "track-role",
2081
+ TRACK_CHANGES_ATTR_DATA_USERID,
2082
+ TRACK_CHANGES_ATTR_DATA_DATE
2083
+ ],
2084
+ allowedChildTagNames: []
2085
+ });
2086
+
2020
2087
  // src/schema/elementSchemas/elements/index.ts
2021
2088
  var ELEMENT_SCHEMAS = {
2089
+ bibliodiv: BIBLIODIV_SCHEMA,
2090
+ referenceBibliography: REFERENCE_BIBLIOGRAPHY_SCHEMA,
2091
+ referenceBibliomixed: BIBLIOMIXED_SCHEMA,
2022
2092
  para: PARA_SCHEMA,
2023
2093
  title1: TITLE_SCHEMA,
2024
2094
  footnote: FOOTNOTE_SCHEMA,
@@ -2194,6 +2264,9 @@ var SCHEMAS = {
2194
2264
 
2195
2265
  // src/schema/schema.types.ts
2196
2266
  var ElementLabel = {
2267
+ referenceBibliomixed: "Reference Bibliomixed",
2268
+ referenceBibliography: "Reference Bibliography",
2269
+ bibliodiv: "Bibliodiv",
2197
2270
  indexterm: "Indexterm",
2198
2271
  primary: "Primary",
2199
2272
  secondary: "Secondary",
@@ -2319,9 +2392,7 @@ var IGNORED_ELEMENT_SELECTORS = [
2319
2392
  "span.printlabel",
2320
2393
  "span.refIcon",
2321
2394
  "span.missLink",
2322
- "span.ref-drag",
2323
- "bibliomixed"
2324
- // TODO: Remove this once we have a proper schema for bibliomixed
2395
+ "span.ref-drag"
2325
2396
  ];
2326
2397
 
2327
2398
  // src/schema/shared/ignoredAttributes.ts
@@ -2547,17 +2618,17 @@ var validateConsecutiveFootnoteCues = (root) => {
2547
2618
  };
2548
2619
 
2549
2620
  // src/validation/validateLinkend.ts
2550
- var findElementLinkedTo = (linkend, elementsLinkedTo) => {
2551
- return elementsLinkedTo.includes(linkend);
2621
+ var findElementLinkedTo = (linkend, elementsToLink) => {
2622
+ return elementsToLink.includes(linkend);
2552
2623
  };
2553
- var validateLinkend = (linkElement, elementsLinkedTo) => {
2624
+ var validateLinkend = (linkElement, elementsToLink) => {
2554
2625
  const linkend = linkElement.getAttribute("linkend");
2555
2626
  if (!linkend) {
2556
2627
  return [];
2557
2628
  }
2558
2629
  const isLinkFootnoteCue = linkElement.tagName.toUpperCase() === FOOTNOTE_LINK_SCHEMA.tag;
2559
2630
  if (isLinkFootnoteCue) {
2560
- if (findElementLinkedTo(linkend, elementsLinkedTo)) {
2631
+ if (findElementLinkedTo(linkend, elementsToLink)) {
2561
2632
  return [];
2562
2633
  }
2563
2634
  return [
@@ -2570,7 +2641,7 @@ var validateLinkend = (linkElement, elementsLinkedTo) => {
2570
2641
  })
2571
2642
  ];
2572
2643
  }
2573
- if (findElementLinkedTo(linkend, elementsLinkedTo)) {
2644
+ if (findElementLinkedTo(linkend, elementsToLink)) {
2574
2645
  return [];
2575
2646
  }
2576
2647
  return [
@@ -2636,33 +2707,6 @@ var validateElementAgainstSchema = (element, schema, inheritedForbiddenScope) =>
2636
2707
  description: `The element is not allowed in this context.`
2637
2708
  });
2638
2709
  }
2639
- if (schema.code === "insertion" && !element.classList.contains("ins")) {
2640
- addValidationIssue(errors, {
2641
- store: getStore(element),
2642
- title: 'Missing class "ins" for insertion element',
2643
- level: "warning",
2644
- kind: "missing",
2645
- description: `The element is missing the class "ins".`
2646
- });
2647
- }
2648
- if (schema.code === "deletion" && !element.classList.contains("del")) {
2649
- addValidationIssue(errors, {
2650
- store: getStore(element),
2651
- title: 'Missing class "del" for deletion element',
2652
- level: "warning",
2653
- kind: "missing",
2654
- description: `The element is missing the class "del".`
2655
- });
2656
- }
2657
- if (schema.code === "commentQuerySection" && !element.classList.contains("cmtQurySection")) {
2658
- addValidationIssue(errors, {
2659
- store: getStore(element),
2660
- title: 'Missing class "cmtQurySection" for comment query section',
2661
- level: "warning",
2662
- kind: "missing",
2663
- description: `The element is missing the class "cmtQurySection".`
2664
- });
2665
- }
2666
2710
  errors.push(...validateAttributes(element, schema));
2667
2711
  errors.push(...validateChildren(element, schema, inheritedForbiddenScope));
2668
2712
  return errors;
@@ -2771,8 +2815,31 @@ var getLinkableRoles = () => {
2771
2815
  return [];
2772
2816
  };
2773
2817
 
2818
+ // src/validation/validateReferences.ts
2819
+ var findElementLinkedTo2 = (xmlid, linkElements) => {
2820
+ return linkElements.includes(xmlid);
2821
+ };
2822
+ var validateReferenceCited = (referenceElement, linkElements) => {
2823
+ const xmlid = referenceElement.getAttribute("xmlid");
2824
+ if (!xmlid) {
2825
+ return [];
2826
+ }
2827
+ if (findElementLinkedTo2(xmlid, linkElements)) {
2828
+ return [];
2829
+ }
2830
+ return [
2831
+ createValidationIssue({
2832
+ store: getStore(referenceElement),
2833
+ title: "Unlinked element",
2834
+ kind: "unlinked",
2835
+ description: "This reference is not cited in this chapter or any other chapter. Please add a link to this reference or delete the reference.",
2836
+ level: "blocker"
2837
+ })
2838
+ ];
2839
+ };
2840
+
2774
2841
  // src/validation/validateXml.ts
2775
- var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst) => {
2842
+ var validateElement = (element, root, elementsToLink, linkElements, schemasToValidateAgainst) => {
2776
2843
  if (isIgnoredElement(element)) {
2777
2844
  return [];
2778
2845
  }
@@ -2791,7 +2858,11 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2791
2858
  const role = element.getAttribute("role") || "";
2792
2859
  const linkableRoles = getLinkableRoles();
2793
2860
  if (schema.tag === LINK_SCHEMA.tag && linkableRoles.includes(role) || schema.tag === FOOTNOTE_LINK_SCHEMA.tag) {
2794
- errors.push(...validateLinkend(element, elementsLinkedTo));
2861
+ errors.push(...validateLinkend(element, elementsToLink));
2862
+ }
2863
+ if (schema.tag === BIBLIOMIXED_SCHEMA.tag) {
2864
+ errors.push(...validateReferenceCited(element, linkElements));
2865
+ return errors;
2795
2866
  }
2796
2867
  if (schema.tag === FOOTNOTE_SCHEMA.tag) {
2797
2868
  errors.push(...validateFootnoteCue(element, root));
@@ -2802,14 +2873,15 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2802
2873
  ...validateElement(
2803
2874
  child,
2804
2875
  root,
2805
- elementsLinkedTo,
2876
+ elementsToLink,
2877
+ linkElements,
2806
2878
  schemasToValidateAgainst
2807
2879
  )
2808
2880
  );
2809
2881
  }
2810
2882
  return errors;
2811
2883
  };
2812
- var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2884
+ var validateXml = (xml, elementsToLink, linkElements, schemasToValidateAgainst) => {
2813
2885
  const errors = [];
2814
2886
  errors.push(...validateConsecutiveFootnotes(xml));
2815
2887
  errors.push(...validateConsecutiveFootnoteCues(xml));
@@ -2818,7 +2890,8 @@ var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2818
2890
  ...validateElement(
2819
2891
  child,
2820
2892
  xml,
2821
- elementsLinkedTo,
2893
+ elementsToLink,
2894
+ linkElements,
2822
2895
  schemasToValidateAgainst
2823
2896
  )
2824
2897
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "0.1.194",
3
+ "version": "0.1.196",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",