pro-editor-schema 0.1.186 → 0.1.188

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
@@ -29,6 +29,7 @@ type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
29
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";
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";
31
31
  type InlineSchemaCode = "footnote1" | "inlineequation" | "link" | "uri";
32
+ declare const ElementLabel: Record<SchemaCode, string>;
32
33
 
33
34
  declare const SCHEMAS: Record<SchemaCode, Schema>;
34
35
 
@@ -108,4 +109,4 @@ type ValidationError = {
108
109
  */
109
110
  declare const validateXml: (xml: Element, elementsLinkedTo: readonly string[], schemasToValidateAgainst: SchemaCode[]) => ValidationError[];
110
111
 
111
- export { ALIGNMENT_ATTRIBUTE, ATOM_SCHEMAS, type AllowedChildren, type AtomSchemaCode, type AttributeDefinition, ELEMENT_SCHEMAS, ELE_ID_ATTRIBUTE, 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, LAYOUT_USER_ATTRIBUTE, LEFT_INDENT_ATTRIBUTE, ORIENTATION_ATTRIBUTE, PLACEMENT_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, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement, validateXml };
112
+ 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, LAYOUT_USER_ATTRIBUTE, LEFT_INDENT_ATTRIBUTE, ORIENTATION_ATTRIBUTE, PLACEMENT_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, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement, validateXml };
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
29
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";
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";
31
31
  type InlineSchemaCode = "footnote1" | "inlineequation" | "link" | "uri";
32
+ declare const ElementLabel: Record<SchemaCode, string>;
32
33
 
33
34
  declare const SCHEMAS: Record<SchemaCode, Schema>;
34
35
 
@@ -108,4 +109,4 @@ type ValidationError = {
108
109
  */
109
110
  declare const validateXml: (xml: Element, elementsLinkedTo: readonly string[], schemasToValidateAgainst: SchemaCode[]) => ValidationError[];
110
111
 
111
- export { ALIGNMENT_ATTRIBUTE, ATOM_SCHEMAS, type AllowedChildren, type AtomSchemaCode, type AttributeDefinition, ELEMENT_SCHEMAS, ELE_ID_ATTRIBUTE, 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, LAYOUT_USER_ATTRIBUTE, LEFT_INDENT_ATTRIBUTE, ORIENTATION_ATTRIBUTE, PLACEMENT_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, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement, validateXml };
112
+ 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, LAYOUT_USER_ATTRIBUTE, LEFT_INDENT_ATTRIBUTE, ORIENTATION_ATTRIBUTE, PLACEMENT_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, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement, validateXml };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  ATOM_SCHEMAS: () => ATOM_SCHEMAS,
25
25
  ELEMENT_SCHEMAS: () => ELEMENT_SCHEMAS,
26
26
  ELE_ID_ATTRIBUTE: () => ELE_ID_ATTRIBUTE,
27
+ ElementLabel: () => ElementLabel,
27
28
  FIGURE_PLACEMENT_ATTRIBUTE: () => FIGURE_PLACEMENT_ATTRIBUTE,
28
29
  ID_ATTRS: () => ID_ATTRS,
29
30
  IGNORED_ATTRIBUTES: () => IGNORED_ATTRIBUTES,
@@ -864,6 +865,11 @@ var EQUATION_SCHEMA = createSchema({
864
865
  tagName: CAPTION_TAG,
865
866
  required: false
866
867
  }
868
+ ],
869
+ forbiddenElements: [
870
+ { code: QUERY_SCHEMA.code, resolveTo: "skip" },
871
+ { code: COMMENT_SCHEMA.code, resolveTo: "skip" },
872
+ { code: COMMENT_QUERY_SECTION_SCHEMA.code, resolveTo: "skip" }
867
873
  ]
868
874
  });
869
875
 
@@ -1986,7 +1992,8 @@ var HEADING_SCHEMA = createSchema({
1986
1992
  { tagName: TABLE_TAG, required: false },
1987
1993
  { tagName: FIGURE_TAG, required: false },
1988
1994
  { tagName: SECTION_TAG, required: false },
1989
- { tagName: INFO_TAG, required: false }
1995
+ { tagName: INFO_TAG, required: false },
1996
+ { tagName: EQUATION_TAG, required: false }
1990
1997
  ]
1991
1998
  });
1992
1999
 
@@ -2035,11 +2042,6 @@ var MATHPHRASE_SCHEMA = createSchema({
2035
2042
  tagName: SPAN_TAG,
2036
2043
  required: false
2037
2044
  }
2038
- ],
2039
- forbiddenElements: [
2040
- { code: QUERY_SCHEMA.code, resolveTo: "skip" },
2041
- { code: COMMENT_SCHEMA.code, resolveTo: "skip" },
2042
- { code: COMMENT_QUERY_SECTION_SCHEMA.code, resolveTo: "skip" }
2043
2045
  ]
2044
2046
  });
2045
2047
 
@@ -2166,7 +2168,12 @@ var INLINEEQUATION_SCHEMA = createSchema({
2166
2168
  defaultValue: "added"
2167
2169
  }
2168
2170
  ],
2169
- allowedChildTagNames: [{ tagName: MATHPHRASE_TAG, required: true }]
2171
+ allowedChildTagNames: [{ tagName: MATHPHRASE_TAG, required: true }],
2172
+ forbiddenElements: [
2173
+ { code: QUERY_SCHEMA.code, resolveTo: "skip" },
2174
+ { code: COMMENT_SCHEMA.code, resolveTo: "skip" },
2175
+ { code: COMMENT_QUERY_SECTION_SCHEMA.code, resolveTo: "skip" }
2176
+ ]
2170
2177
  });
2171
2178
 
2172
2179
  // src/schema/elementSchemas/inlineElements/link.ts
@@ -2213,6 +2220,126 @@ var SCHEMAS = {
2213
2220
  ...INLINE_ELEMENT_SCHEMAS
2214
2221
  };
2215
2222
 
2223
+ // src/schema/schema.types.ts
2224
+ var ElementLabel = {
2225
+ indexterm: "Indexterm",
2226
+ primary: "Primary",
2227
+ secondary: "Secondary",
2228
+ tertiary: "Tertiary",
2229
+ quaternary: "Quaternary",
2230
+ bookmark: "Bookmark",
2231
+ see: "Cross Reference",
2232
+ commentQuerySection: "Comment/Query",
2233
+ comment: "Comment",
2234
+ content: "Content",
2235
+ query: "Query",
2236
+ reply: "Reply",
2237
+ deletion: "Deletion",
2238
+ emphasis: "Emphasis",
2239
+ highlightmark: "Highlightmark",
2240
+ i: "Italic",
2241
+ insertion: "Insertion",
2242
+ sc: "Small Caps",
2243
+ strike: "Strike",
2244
+ sub: "Subscript",
2245
+ sup: "Superscript",
2246
+ u: "Underline",
2247
+ b: "Bold",
2248
+ degrees: "Degrees",
2249
+ email: "Email",
2250
+ equation: "Equation",
2251
+ fignote: "Fignote",
2252
+ figsource: "Figsource",
2253
+ firstname: "Firstname",
2254
+ footnote: "Footnote Marker",
2255
+ footnoteno: "Footnote Number",
2256
+ honorific: "Honorific",
2257
+ img: "Image",
2258
+ informalfigure: "Floating Figure",
2259
+ keyword: "Keyword",
2260
+ label1: "Label",
2261
+ li: "List Item",
2262
+ line: "Line",
2263
+ lrh: "Running Head Left",
2264
+ math: "Math",
2265
+ mathphrase: "Math Phrase",
2266
+ merror: "Math Error",
2267
+ mfrac: "Math Fraction",
2268
+ mi: "Math Identifier",
2269
+ mmultiscripts: "Math Multiscripts",
2270
+ mn: "Math Number",
2271
+ mo: "Math Operator",
2272
+ mover: "Math Over",
2273
+ mpadded: "Math Padded",
2274
+ mphantom: "Math Phantom",
2275
+ mprescripts: "Math Prescripts",
2276
+ mroot: "Math Root",
2277
+ mrow: "Math Row",
2278
+ ms: "Math Space",
2279
+ mspace: "Math Space",
2280
+ msqrt: "Math Square Root",
2281
+ mstyle: "Math Style",
2282
+ msub: "Math Subscript",
2283
+ msubsup: "Math Subscript Superscript",
2284
+ msup: "Math Superscript",
2285
+ mtable: "Math Table",
2286
+ mtd: "Math Table Data",
2287
+ mtext: "Math Text",
2288
+ mtr: "Math Table Row",
2289
+ munder: "Math Under",
2290
+ munderover: "Math Under Over",
2291
+ olink: "Online Link",
2292
+ org: "Org",
2293
+ orgname: "Orgname",
2294
+ para: "Paragraph",
2295
+ punc: "Punctuation",
2296
+ rrh: "Running Head Right",
2297
+ source1: "Source",
2298
+ speaker: "Speaker",
2299
+ subtitle1: "Subtitle",
2300
+ surname: "Surname",
2301
+ tag: "Tag",
2302
+ tblfn: "Table Footnote",
2303
+ tblsource: "Table Source",
2304
+ thead: "Thead",
2305
+ title1: "Title",
2306
+ token: "Token",
2307
+ tp: "Table Paragraph",
2308
+ abstract1: "Abstract",
2309
+ affiliation: "Affiliation",
2310
+ alttext: "Alttext",
2311
+ appendix: "Appendix",
2312
+ author: "Author",
2313
+ authorgroup: "Authorgroup",
2314
+ blockquote: "Blockquote",
2315
+ caption1: "Caption",
2316
+ chapter: "Chapter",
2317
+ dialogue: "Dialogue",
2318
+ epigraph: "Epigraph",
2319
+ figure1: "Figure",
2320
+ footnoteSection: "Footnote Section",
2321
+ heading: "Heading",
2322
+ imageobject: "Image Object",
2323
+ info1: "Info",
2324
+ keywordset: "Keyword FGroup",
2325
+ mediaobject: "Mediaobject",
2326
+ ol: "Ordered List",
2327
+ personname: "Person Name",
2328
+ poem: "Poem",
2329
+ sidebar: "Box",
2330
+ table: "Table",
2331
+ table1: "Table",
2332
+ tbody: "Table Body",
2333
+ td: "Table Data",
2334
+ tgroup: "Table Group",
2335
+ tr: "Table Row",
2336
+ ul: "Unordered List",
2337
+ footnote1: "Footnote",
2338
+ inlineequation: "Inline Equation",
2339
+ link: "Link",
2340
+ uri: "URI"
2341
+ };
2342
+
2216
2343
  // src/schema/shared/ignoredElements.ts
2217
2344
  var IGNORED_ELEMENT_SELECTORS = [
2218
2345
  "span.rhlabel",
@@ -2524,7 +2651,7 @@ var validateAttributes = (element, schema) => {
2524
2651
  };
2525
2652
 
2526
2653
  // src/validation/validateChildren.ts
2527
- var validateElementAgainstSchema = (element, schema) => {
2654
+ var validateElementAgainstSchema = (element, schema, inheritedForbiddenScope) => {
2528
2655
  const errors = [];
2529
2656
  if (element.tagName.toUpperCase() !== schema.tag) {
2530
2657
  addValidationIssue(errors, {
@@ -2563,10 +2690,10 @@ var validateElementAgainstSchema = (element, schema) => {
2563
2690
  });
2564
2691
  }
2565
2692
  errors.push(...validateAttributes(element, schema));
2566
- errors.push(...validateChildren(element, schema));
2693
+ errors.push(...validateChildren(element, schema, inheritedForbiddenScope));
2567
2694
  return errors;
2568
2695
  };
2569
- var validateChildren = (element, schema) => {
2696
+ var validateChildren = (element, schema, inheritedForbiddenScope) => {
2570
2697
  const errors = [];
2571
2698
  const childElements = [...element.children].filter(
2572
2699
  (child) => !isIgnoredElement(child)
@@ -2601,22 +2728,30 @@ var validateChildren = (element, schema) => {
2601
2728
  });
2602
2729
  continue;
2603
2730
  }
2604
- if (schema.forbiddenElements) {
2605
- const forbiddenChild = Array.from(schema.forbiddenElements).find(
2606
- (candidate) => candidate.code === childSchema.code
2607
- );
2608
- if (forbiddenChild) {
2609
- addValidationIssue(errors, {
2610
- store: getStore(child),
2611
- title: `Forbidden element ${child.tagName}`,
2612
- level: "blocker",
2613
- kind: "forbidden",
2614
- description: `The element ${childSchema.code} is not permitted within ${schema.tag} content. Please delete the element or move it to a different location.`
2615
- });
2616
- continue;
2617
- }
2731
+ const forbiddenScope = [
2732
+ ...inheritedForbiddenScope || [],
2733
+ ...childSchema.forbiddenElements || []
2734
+ ];
2735
+ const forbiddenChild = forbiddenScope.find(
2736
+ (candidate) => candidate.code === childSchema.code
2737
+ );
2738
+ if (forbiddenChild) {
2739
+ addValidationIssue(errors, {
2740
+ store: getStore(child),
2741
+ title: `Forbidden element ${child.tagName}`,
2742
+ level: "blocker",
2743
+ kind: "forbidden",
2744
+ description: `The element ${ElementLabel[childSchema.code]} is not permitted within ${ElementLabel[schema.code]} content. Please delete the element or move it to a different location.`
2745
+ });
2746
+ continue;
2618
2747
  }
2619
- errors.push(...validateElementAgainstSchema(child, childSchema));
2748
+ errors.push(
2749
+ ...validateElementAgainstSchema(
2750
+ child,
2751
+ childSchema,
2752
+ new Set(forbiddenScope)
2753
+ )
2754
+ );
2620
2755
  }
2621
2756
  for (const allowedChild of allowedChildren) {
2622
2757
  if (!allowedChild.required) {
@@ -2671,7 +2806,13 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2671
2806
  const schema = findSchemaByElement(element);
2672
2807
  if (schema) {
2673
2808
  if (schemasToValidateAgainst.includes(schema.code)) {
2674
- errors.push(...validateElementAgainstSchema(element, schema));
2809
+ errors.push(
2810
+ ...validateElementAgainstSchema(
2811
+ element,
2812
+ schema,
2813
+ schema.forbiddenElements
2814
+ )
2815
+ );
2675
2816
  }
2676
2817
  const role = element.getAttribute("role") || "";
2677
2818
  const linkableRoles = getLinkableRoles();
@@ -2716,6 +2857,7 @@ var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2716
2857
  ATOM_SCHEMAS,
2717
2858
  ELEMENT_SCHEMAS,
2718
2859
  ELE_ID_ATTRIBUTE,
2860
+ ElementLabel,
2719
2861
  FIGURE_PLACEMENT_ATTRIBUTE,
2720
2862
  ID_ATTRS,
2721
2863
  IGNORED_ATTRIBUTES,
package/dist/index.mjs CHANGED
@@ -801,6 +801,11 @@ var EQUATION_SCHEMA = createSchema({
801
801
  tagName: CAPTION_TAG,
802
802
  required: false
803
803
  }
804
+ ],
805
+ forbiddenElements: [
806
+ { code: QUERY_SCHEMA.code, resolveTo: "skip" },
807
+ { code: COMMENT_SCHEMA.code, resolveTo: "skip" },
808
+ { code: COMMENT_QUERY_SECTION_SCHEMA.code, resolveTo: "skip" }
804
809
  ]
805
810
  });
806
811
 
@@ -1923,7 +1928,8 @@ var HEADING_SCHEMA = createSchema({
1923
1928
  { tagName: TABLE_TAG, required: false },
1924
1929
  { tagName: FIGURE_TAG, required: false },
1925
1930
  { tagName: SECTION_TAG, required: false },
1926
- { tagName: INFO_TAG, required: false }
1931
+ { tagName: INFO_TAG, required: false },
1932
+ { tagName: EQUATION_TAG, required: false }
1927
1933
  ]
1928
1934
  });
1929
1935
 
@@ -1972,11 +1978,6 @@ var MATHPHRASE_SCHEMA = createSchema({
1972
1978
  tagName: SPAN_TAG,
1973
1979
  required: false
1974
1980
  }
1975
- ],
1976
- forbiddenElements: [
1977
- { code: QUERY_SCHEMA.code, resolveTo: "skip" },
1978
- { code: COMMENT_SCHEMA.code, resolveTo: "skip" },
1979
- { code: COMMENT_QUERY_SECTION_SCHEMA.code, resolveTo: "skip" }
1980
1981
  ]
1981
1982
  });
1982
1983
 
@@ -2103,7 +2104,12 @@ var INLINEEQUATION_SCHEMA = createSchema({
2103
2104
  defaultValue: "added"
2104
2105
  }
2105
2106
  ],
2106
- allowedChildTagNames: [{ tagName: MATHPHRASE_TAG, required: true }]
2107
+ allowedChildTagNames: [{ tagName: MATHPHRASE_TAG, required: true }],
2108
+ forbiddenElements: [
2109
+ { code: QUERY_SCHEMA.code, resolveTo: "skip" },
2110
+ { code: COMMENT_SCHEMA.code, resolveTo: "skip" },
2111
+ { code: COMMENT_QUERY_SECTION_SCHEMA.code, resolveTo: "skip" }
2112
+ ]
2107
2113
  });
2108
2114
 
2109
2115
  // src/schema/elementSchemas/inlineElements/link.ts
@@ -2150,6 +2156,126 @@ var SCHEMAS = {
2150
2156
  ...INLINE_ELEMENT_SCHEMAS
2151
2157
  };
2152
2158
 
2159
+ // src/schema/schema.types.ts
2160
+ var ElementLabel = {
2161
+ indexterm: "Indexterm",
2162
+ primary: "Primary",
2163
+ secondary: "Secondary",
2164
+ tertiary: "Tertiary",
2165
+ quaternary: "Quaternary",
2166
+ bookmark: "Bookmark",
2167
+ see: "Cross Reference",
2168
+ commentQuerySection: "Comment/Query",
2169
+ comment: "Comment",
2170
+ content: "Content",
2171
+ query: "Query",
2172
+ reply: "Reply",
2173
+ deletion: "Deletion",
2174
+ emphasis: "Emphasis",
2175
+ highlightmark: "Highlightmark",
2176
+ i: "Italic",
2177
+ insertion: "Insertion",
2178
+ sc: "Small Caps",
2179
+ strike: "Strike",
2180
+ sub: "Subscript",
2181
+ sup: "Superscript",
2182
+ u: "Underline",
2183
+ b: "Bold",
2184
+ degrees: "Degrees",
2185
+ email: "Email",
2186
+ equation: "Equation",
2187
+ fignote: "Fignote",
2188
+ figsource: "Figsource",
2189
+ firstname: "Firstname",
2190
+ footnote: "Footnote Marker",
2191
+ footnoteno: "Footnote Number",
2192
+ honorific: "Honorific",
2193
+ img: "Image",
2194
+ informalfigure: "Floating Figure",
2195
+ keyword: "Keyword",
2196
+ label1: "Label",
2197
+ li: "List Item",
2198
+ line: "Line",
2199
+ lrh: "Running Head Left",
2200
+ math: "Math",
2201
+ mathphrase: "Math Phrase",
2202
+ merror: "Math Error",
2203
+ mfrac: "Math Fraction",
2204
+ mi: "Math Identifier",
2205
+ mmultiscripts: "Math Multiscripts",
2206
+ mn: "Math Number",
2207
+ mo: "Math Operator",
2208
+ mover: "Math Over",
2209
+ mpadded: "Math Padded",
2210
+ mphantom: "Math Phantom",
2211
+ mprescripts: "Math Prescripts",
2212
+ mroot: "Math Root",
2213
+ mrow: "Math Row",
2214
+ ms: "Math Space",
2215
+ mspace: "Math Space",
2216
+ msqrt: "Math Square Root",
2217
+ mstyle: "Math Style",
2218
+ msub: "Math Subscript",
2219
+ msubsup: "Math Subscript Superscript",
2220
+ msup: "Math Superscript",
2221
+ mtable: "Math Table",
2222
+ mtd: "Math Table Data",
2223
+ mtext: "Math Text",
2224
+ mtr: "Math Table Row",
2225
+ munder: "Math Under",
2226
+ munderover: "Math Under Over",
2227
+ olink: "Online Link",
2228
+ org: "Org",
2229
+ orgname: "Orgname",
2230
+ para: "Paragraph",
2231
+ punc: "Punctuation",
2232
+ rrh: "Running Head Right",
2233
+ source1: "Source",
2234
+ speaker: "Speaker",
2235
+ subtitle1: "Subtitle",
2236
+ surname: "Surname",
2237
+ tag: "Tag",
2238
+ tblfn: "Table Footnote",
2239
+ tblsource: "Table Source",
2240
+ thead: "Thead",
2241
+ title1: "Title",
2242
+ token: "Token",
2243
+ tp: "Table Paragraph",
2244
+ abstract1: "Abstract",
2245
+ affiliation: "Affiliation",
2246
+ alttext: "Alttext",
2247
+ appendix: "Appendix",
2248
+ author: "Author",
2249
+ authorgroup: "Authorgroup",
2250
+ blockquote: "Blockquote",
2251
+ caption1: "Caption",
2252
+ chapter: "Chapter",
2253
+ dialogue: "Dialogue",
2254
+ epigraph: "Epigraph",
2255
+ figure1: "Figure",
2256
+ footnoteSection: "Footnote Section",
2257
+ heading: "Heading",
2258
+ imageobject: "Image Object",
2259
+ info1: "Info",
2260
+ keywordset: "Keyword FGroup",
2261
+ mediaobject: "Mediaobject",
2262
+ ol: "Ordered List",
2263
+ personname: "Person Name",
2264
+ poem: "Poem",
2265
+ sidebar: "Box",
2266
+ table: "Table",
2267
+ table1: "Table",
2268
+ tbody: "Table Body",
2269
+ td: "Table Data",
2270
+ tgroup: "Table Group",
2271
+ tr: "Table Row",
2272
+ ul: "Unordered List",
2273
+ footnote1: "Footnote",
2274
+ inlineequation: "Inline Equation",
2275
+ link: "Link",
2276
+ uri: "URI"
2277
+ };
2278
+
2153
2279
  // src/schema/shared/ignoredElements.ts
2154
2280
  var IGNORED_ELEMENT_SELECTORS = [
2155
2281
  "span.rhlabel",
@@ -2461,7 +2587,7 @@ var validateAttributes = (element, schema) => {
2461
2587
  };
2462
2588
 
2463
2589
  // src/validation/validateChildren.ts
2464
- var validateElementAgainstSchema = (element, schema) => {
2590
+ var validateElementAgainstSchema = (element, schema, inheritedForbiddenScope) => {
2465
2591
  const errors = [];
2466
2592
  if (element.tagName.toUpperCase() !== schema.tag) {
2467
2593
  addValidationIssue(errors, {
@@ -2500,10 +2626,10 @@ var validateElementAgainstSchema = (element, schema) => {
2500
2626
  });
2501
2627
  }
2502
2628
  errors.push(...validateAttributes(element, schema));
2503
- errors.push(...validateChildren(element, schema));
2629
+ errors.push(...validateChildren(element, schema, inheritedForbiddenScope));
2504
2630
  return errors;
2505
2631
  };
2506
- var validateChildren = (element, schema) => {
2632
+ var validateChildren = (element, schema, inheritedForbiddenScope) => {
2507
2633
  const errors = [];
2508
2634
  const childElements = [...element.children].filter(
2509
2635
  (child) => !isIgnoredElement(child)
@@ -2538,22 +2664,30 @@ var validateChildren = (element, schema) => {
2538
2664
  });
2539
2665
  continue;
2540
2666
  }
2541
- if (schema.forbiddenElements) {
2542
- const forbiddenChild = Array.from(schema.forbiddenElements).find(
2543
- (candidate) => candidate.code === childSchema.code
2544
- );
2545
- if (forbiddenChild) {
2546
- addValidationIssue(errors, {
2547
- store: getStore(child),
2548
- title: `Forbidden element ${child.tagName}`,
2549
- level: "blocker",
2550
- kind: "forbidden",
2551
- description: `The element ${childSchema.code} is not permitted within ${schema.tag} content. Please delete the element or move it to a different location.`
2552
- });
2553
- continue;
2554
- }
2667
+ const forbiddenScope = [
2668
+ ...inheritedForbiddenScope || [],
2669
+ ...childSchema.forbiddenElements || []
2670
+ ];
2671
+ const forbiddenChild = forbiddenScope.find(
2672
+ (candidate) => candidate.code === childSchema.code
2673
+ );
2674
+ if (forbiddenChild) {
2675
+ addValidationIssue(errors, {
2676
+ store: getStore(child),
2677
+ title: `Forbidden element ${child.tagName}`,
2678
+ level: "blocker",
2679
+ kind: "forbidden",
2680
+ description: `The element ${ElementLabel[childSchema.code]} is not permitted within ${ElementLabel[schema.code]} content. Please delete the element or move it to a different location.`
2681
+ });
2682
+ continue;
2555
2683
  }
2556
- errors.push(...validateElementAgainstSchema(child, childSchema));
2684
+ errors.push(
2685
+ ...validateElementAgainstSchema(
2686
+ child,
2687
+ childSchema,
2688
+ new Set(forbiddenScope)
2689
+ )
2690
+ );
2557
2691
  }
2558
2692
  for (const allowedChild of allowedChildren) {
2559
2693
  if (!allowedChild.required) {
@@ -2608,7 +2742,13 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2608
2742
  const schema = findSchemaByElement(element);
2609
2743
  if (schema) {
2610
2744
  if (schemasToValidateAgainst.includes(schema.code)) {
2611
- errors.push(...validateElementAgainstSchema(element, schema));
2745
+ errors.push(
2746
+ ...validateElementAgainstSchema(
2747
+ element,
2748
+ schema,
2749
+ schema.forbiddenElements
2750
+ )
2751
+ );
2612
2752
  }
2613
2753
  const role = element.getAttribute("role") || "";
2614
2754
  const linkableRoles = getLinkableRoles();
@@ -2652,6 +2792,7 @@ export {
2652
2792
  ATOM_SCHEMAS,
2653
2793
  ELEMENT_SCHEMAS,
2654
2794
  ELE_ID_ATTRIBUTE,
2795
+ ElementLabel,
2655
2796
  FIGURE_PLACEMENT_ATTRIBUTE,
2656
2797
  ID_ATTRS,
2657
2798
  IGNORED_ATTRIBUTES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "0.1.186",
3
+ "version": "0.1.188",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",