pro-editor-schema 0.1.194 → 0.1.195

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 [
@@ -2836,8 +2907,31 @@ var getLinkableRoles = () => {
2836
2907
  return [];
2837
2908
  };
2838
2909
 
2910
+ // src/validation/validateReferences.ts
2911
+ var findElementLinkedTo2 = (xmlid, linkElements) => {
2912
+ return linkElements.includes(xmlid);
2913
+ };
2914
+ var validateReferenceCited = (referenceElement, linkElements) => {
2915
+ const xmlid = referenceElement.getAttribute("xmlid");
2916
+ if (!xmlid) {
2917
+ return [];
2918
+ }
2919
+ if (findElementLinkedTo2(xmlid, linkElements)) {
2920
+ return [];
2921
+ }
2922
+ return [
2923
+ createValidationIssue({
2924
+ store: getStore(referenceElement),
2925
+ title: "Unlinked element",
2926
+ kind: "unlinked",
2927
+ description: "This reference is not cited in this chapter or any other chapter. Please add a link to this reference or delete the reference.",
2928
+ level: "blocker"
2929
+ })
2930
+ ];
2931
+ };
2932
+
2839
2933
  // src/validation/validateXml.ts
2840
- var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst) => {
2934
+ var validateElement = (element, root, elementsToLink, linkElements, schemasToValidateAgainst) => {
2841
2935
  if (isIgnoredElement(element)) {
2842
2936
  return [];
2843
2937
  }
@@ -2856,7 +2950,11 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2856
2950
  const role = element.getAttribute("role") || "";
2857
2951
  const linkableRoles = getLinkableRoles();
2858
2952
  if (schema.tag === LINK_SCHEMA.tag && linkableRoles.includes(role) || schema.tag === FOOTNOTE_LINK_SCHEMA.tag) {
2859
- errors.push(...validateLinkend(element, elementsLinkedTo));
2953
+ errors.push(...validateLinkend(element, elementsToLink));
2954
+ }
2955
+ if (schema.tag === BIBLIOMIXED_SCHEMA.tag) {
2956
+ errors.push(...validateReferenceCited(element, linkElements));
2957
+ return errors;
2860
2958
  }
2861
2959
  if (schema.tag === FOOTNOTE_SCHEMA.tag) {
2862
2960
  errors.push(...validateFootnoteCue(element, root));
@@ -2867,14 +2965,15 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2867
2965
  ...validateElement(
2868
2966
  child,
2869
2967
  root,
2870
- elementsLinkedTo,
2968
+ elementsToLink,
2969
+ linkElements,
2871
2970
  schemasToValidateAgainst
2872
2971
  )
2873
2972
  );
2874
2973
  }
2875
2974
  return errors;
2876
2975
  };
2877
- var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2976
+ var validateXml = (xml, elementsToLink, linkElements, schemasToValidateAgainst) => {
2878
2977
  const errors = [];
2879
2978
  errors.push(...validateConsecutiveFootnotes(xml));
2880
2979
  errors.push(...validateConsecutiveFootnoteCues(xml));
@@ -2883,7 +2982,8 @@ var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2883
2982
  ...validateElement(
2884
2983
  child,
2885
2984
  xml,
2886
- elementsLinkedTo,
2985
+ elementsToLink,
2986
+ linkElements,
2887
2987
  schemasToValidateAgainst
2888
2988
  )
2889
2989
  );
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 [
@@ -2771,8 +2842,31 @@ var getLinkableRoles = () => {
2771
2842
  return [];
2772
2843
  };
2773
2844
 
2845
+ // src/validation/validateReferences.ts
2846
+ var findElementLinkedTo2 = (xmlid, linkElements) => {
2847
+ return linkElements.includes(xmlid);
2848
+ };
2849
+ var validateReferenceCited = (referenceElement, linkElements) => {
2850
+ const xmlid = referenceElement.getAttribute("xmlid");
2851
+ if (!xmlid) {
2852
+ return [];
2853
+ }
2854
+ if (findElementLinkedTo2(xmlid, linkElements)) {
2855
+ return [];
2856
+ }
2857
+ return [
2858
+ createValidationIssue({
2859
+ store: getStore(referenceElement),
2860
+ title: "Unlinked element",
2861
+ kind: "unlinked",
2862
+ description: "This reference is not cited in this chapter or any other chapter. Please add a link to this reference or delete the reference.",
2863
+ level: "blocker"
2864
+ })
2865
+ ];
2866
+ };
2867
+
2774
2868
  // src/validation/validateXml.ts
2775
- var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst) => {
2869
+ var validateElement = (element, root, elementsToLink, linkElements, schemasToValidateAgainst) => {
2776
2870
  if (isIgnoredElement(element)) {
2777
2871
  return [];
2778
2872
  }
@@ -2791,7 +2885,11 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2791
2885
  const role = element.getAttribute("role") || "";
2792
2886
  const linkableRoles = getLinkableRoles();
2793
2887
  if (schema.tag === LINK_SCHEMA.tag && linkableRoles.includes(role) || schema.tag === FOOTNOTE_LINK_SCHEMA.tag) {
2794
- errors.push(...validateLinkend(element, elementsLinkedTo));
2888
+ errors.push(...validateLinkend(element, elementsToLink));
2889
+ }
2890
+ if (schema.tag === BIBLIOMIXED_SCHEMA.tag) {
2891
+ errors.push(...validateReferenceCited(element, linkElements));
2892
+ return errors;
2795
2893
  }
2796
2894
  if (schema.tag === FOOTNOTE_SCHEMA.tag) {
2797
2895
  errors.push(...validateFootnoteCue(element, root));
@@ -2802,14 +2900,15 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2802
2900
  ...validateElement(
2803
2901
  child,
2804
2902
  root,
2805
- elementsLinkedTo,
2903
+ elementsToLink,
2904
+ linkElements,
2806
2905
  schemasToValidateAgainst
2807
2906
  )
2808
2907
  );
2809
2908
  }
2810
2909
  return errors;
2811
2910
  };
2812
- var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2911
+ var validateXml = (xml, elementsToLink, linkElements, schemasToValidateAgainst) => {
2813
2912
  const errors = [];
2814
2913
  errors.push(...validateConsecutiveFootnotes(xml));
2815
2914
  errors.push(...validateConsecutiveFootnoteCues(xml));
@@ -2818,7 +2917,8 @@ var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2818
2917
  ...validateElement(
2819
2918
  child,
2820
2919
  xml,
2821
- elementsLinkedTo,
2920
+ elementsToLink,
2921
+ linkElements,
2822
2922
  schemasToValidateAgainst
2823
2923
  )
2824
2924
  );
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.195",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",