pro-editor-schema 0.1.185 → 0.1.187

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,
@@ -2213,6 +2214,126 @@ var SCHEMAS = {
2213
2214
  ...INLINE_ELEMENT_SCHEMAS
2214
2215
  };
2215
2216
 
2217
+ // src/schema/schema.types.ts
2218
+ var ElementLabel = {
2219
+ indexterm: "Indexterm",
2220
+ primary: "Primary",
2221
+ secondary: "Secondary",
2222
+ tertiary: "Tertiary",
2223
+ quaternary: "Quaternary",
2224
+ bookmark: "Bookmark",
2225
+ see: "Cross Reference",
2226
+ commentQuerySection: "Comment/Query",
2227
+ comment: "Comment",
2228
+ content: "Content",
2229
+ query: "Query",
2230
+ reply: "Reply",
2231
+ deletion: "Deletion",
2232
+ emphasis: "Emphasis",
2233
+ highlightmark: "Highlightmark",
2234
+ i: "Italic",
2235
+ insertion: "Insertion",
2236
+ sc: "Small Caps",
2237
+ strike: "Strike",
2238
+ sub: "Subscript",
2239
+ sup: "Superscript",
2240
+ u: "Underline",
2241
+ b: "Bold",
2242
+ degrees: "Degrees",
2243
+ email: "Email",
2244
+ equation: "Equation",
2245
+ fignote: "Fignote",
2246
+ figsource: "Figsource",
2247
+ firstname: "Firstname",
2248
+ footnote: "Footnote Marker",
2249
+ footnoteno: "Footnote Number",
2250
+ honorific: "Honorific",
2251
+ img: "Image",
2252
+ informalfigure: "Floating Figure",
2253
+ keyword: "Keyword",
2254
+ label1: "Label",
2255
+ li: "List Item",
2256
+ line: "Line",
2257
+ lrh: "Running Head Left",
2258
+ math: "Math",
2259
+ mathphrase: "Math Phrase",
2260
+ merror: "Math Error",
2261
+ mfrac: "Math Fraction",
2262
+ mi: "Math Identifier",
2263
+ mmultiscripts: "Math Multiscripts",
2264
+ mn: "Math Number",
2265
+ mo: "Math Operator",
2266
+ mover: "Math Over",
2267
+ mpadded: "Math Padded",
2268
+ mphantom: "Math Phantom",
2269
+ mprescripts: "Math Prescripts",
2270
+ mroot: "Math Root",
2271
+ mrow: "Math Row",
2272
+ ms: "Math Space",
2273
+ mspace: "Math Space",
2274
+ msqrt: "Math Square Root",
2275
+ mstyle: "Math Style",
2276
+ msub: "Math Subscript",
2277
+ msubsup: "Math Subscript Superscript",
2278
+ msup: "Math Superscript",
2279
+ mtable: "Math Table",
2280
+ mtd: "Math Table Data",
2281
+ mtext: "Math Text",
2282
+ mtr: "Math Table Row",
2283
+ munder: "Math Under",
2284
+ munderover: "Math Under Over",
2285
+ olink: "Online Link",
2286
+ org: "Org",
2287
+ orgname: "Orgname",
2288
+ para: "Paragraph",
2289
+ punc: "Punctuation",
2290
+ rrh: "Running Head Right",
2291
+ source1: "Source",
2292
+ speaker: "Speaker",
2293
+ subtitle1: "Subtitle",
2294
+ surname: "Surname",
2295
+ tag: "Tag",
2296
+ tblfn: "Table Footnote",
2297
+ tblsource: "Table Source",
2298
+ thead: "Thead",
2299
+ title1: "Title",
2300
+ token: "Token",
2301
+ tp: "Table Paragraph",
2302
+ abstract1: "Abstract",
2303
+ affiliation: "Affiliation",
2304
+ alttext: "Alttext",
2305
+ appendix: "Appendix",
2306
+ author: "Author",
2307
+ authorgroup: "Authorgroup",
2308
+ blockquote: "Blockquote",
2309
+ caption1: "Caption",
2310
+ chapter: "Chapter",
2311
+ dialogue: "Dialogue",
2312
+ epigraph: "Epigraph",
2313
+ figure1: "Figure",
2314
+ footnoteSection: "Footnote Section",
2315
+ heading: "Heading",
2316
+ imageobject: "Image Object",
2317
+ info1: "Info",
2318
+ keywordset: "Keyword FGroup",
2319
+ mediaobject: "Mediaobject",
2320
+ ol: "Ordered List",
2321
+ personname: "Person Name",
2322
+ poem: "Poem",
2323
+ sidebar: "Box",
2324
+ table: "Table",
2325
+ table1: "Table",
2326
+ tbody: "Table Body",
2327
+ td: "Table Data",
2328
+ tgroup: "Table Group",
2329
+ tr: "Table Row",
2330
+ ul: "Unordered List",
2331
+ footnote1: "Footnote",
2332
+ inlineequation: "Inline Equation",
2333
+ link: "Link",
2334
+ uri: "URI"
2335
+ };
2336
+
2216
2337
  // src/schema/shared/ignoredElements.ts
2217
2338
  var IGNORED_ELEMENT_SELECTORS = [
2218
2339
  "span.rhlabel",
@@ -2524,7 +2645,7 @@ var validateAttributes = (element, schema) => {
2524
2645
  };
2525
2646
 
2526
2647
  // src/validation/validateChildren.ts
2527
- var validateElementAgainstSchema = (element, schema) => {
2648
+ var validateElementAgainstSchema = (element, schema, inheritedForbiddenScope) => {
2528
2649
  const errors = [];
2529
2650
  if (element.tagName.toUpperCase() !== schema.tag) {
2530
2651
  addValidationIssue(errors, {
@@ -2563,15 +2684,18 @@ var validateElementAgainstSchema = (element, schema) => {
2563
2684
  });
2564
2685
  }
2565
2686
  errors.push(...validateAttributes(element, schema));
2566
- errors.push(...validateChildren(element, schema));
2687
+ errors.push(...validateChildren(element, schema, inheritedForbiddenScope));
2567
2688
  return errors;
2568
2689
  };
2569
- var validateChildren = (element, schema) => {
2690
+ var validateChildren = (element, schema, inheritedForbiddenScope) => {
2570
2691
  const errors = [];
2571
2692
  const childElements = [...element.children].filter(
2572
2693
  (child) => !isIgnoredElement(child)
2573
2694
  );
2574
2695
  const allowedChildren = [...schema.allowedChildTagNames];
2696
+ if (schema.kind === "atom") {
2697
+ return errors;
2698
+ }
2575
2699
  for (const child of childElements) {
2576
2700
  const childTag = child.tagName.toUpperCase();
2577
2701
  const allowedChild = allowedChildren.find(
@@ -2598,22 +2722,26 @@ var validateChildren = (element, schema) => {
2598
2722
  });
2599
2723
  continue;
2600
2724
  }
2601
- if (schema.forbiddenElements) {
2602
- const forbiddenChild = Array.from(schema.forbiddenElements).find(
2603
- (candidate) => candidate.code === childSchema.code
2604
- );
2605
- if (forbiddenChild) {
2606
- addValidationIssue(errors, {
2607
- store: getStore(child),
2608
- title: `Forbidden element ${child.tagName}`,
2609
- level: "blocker",
2610
- kind: "forbidden",
2611
- description: `The element ${childSchema.code} is not permitted within ${schema.tag} content. Please delete the element or move it to a different location.`
2612
- });
2613
- continue;
2614
- }
2725
+ const forbiddenChild = Array.from(inheritedForbiddenScope || []).find(
2726
+ (candidate) => candidate.code === childSchema.code
2727
+ );
2728
+ if (forbiddenChild) {
2729
+ addValidationIssue(errors, {
2730
+ store: getStore(child),
2731
+ title: `Forbidden element ${child.tagName}`,
2732
+ level: "blocker",
2733
+ kind: "forbidden",
2734
+ 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.`
2735
+ });
2736
+ continue;
2615
2737
  }
2616
- errors.push(...validateElementAgainstSchema(child, childSchema));
2738
+ errors.push(
2739
+ ...validateElementAgainstSchema(
2740
+ child,
2741
+ childSchema,
2742
+ inheritedForbiddenScope
2743
+ )
2744
+ );
2617
2745
  }
2618
2746
  for (const allowedChild of allowedChildren) {
2619
2747
  if (!allowedChild.required) {
@@ -2668,7 +2796,13 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2668
2796
  const schema = findSchemaByElement(element);
2669
2797
  if (schema) {
2670
2798
  if (schemasToValidateAgainst.includes(schema.code)) {
2671
- errors.push(...validateElementAgainstSchema(element, schema));
2799
+ errors.push(
2800
+ ...validateElementAgainstSchema(
2801
+ element,
2802
+ schema,
2803
+ schema.forbiddenElements
2804
+ )
2805
+ );
2672
2806
  }
2673
2807
  const role = element.getAttribute("role") || "";
2674
2808
  const linkableRoles = getLinkableRoles();
@@ -2713,6 +2847,7 @@ var validateXml = (xml, elementsLinkedTo, schemasToValidateAgainst) => {
2713
2847
  ATOM_SCHEMAS,
2714
2848
  ELEMENT_SCHEMAS,
2715
2849
  ELE_ID_ATTRIBUTE,
2850
+ ElementLabel,
2716
2851
  FIGURE_PLACEMENT_ATTRIBUTE,
2717
2852
  ID_ATTRS,
2718
2853
  IGNORED_ATTRIBUTES,
package/dist/index.mjs CHANGED
@@ -2150,6 +2150,126 @@ var SCHEMAS = {
2150
2150
  ...INLINE_ELEMENT_SCHEMAS
2151
2151
  };
2152
2152
 
2153
+ // src/schema/schema.types.ts
2154
+ var ElementLabel = {
2155
+ indexterm: "Indexterm",
2156
+ primary: "Primary",
2157
+ secondary: "Secondary",
2158
+ tertiary: "Tertiary",
2159
+ quaternary: "Quaternary",
2160
+ bookmark: "Bookmark",
2161
+ see: "Cross Reference",
2162
+ commentQuerySection: "Comment/Query",
2163
+ comment: "Comment",
2164
+ content: "Content",
2165
+ query: "Query",
2166
+ reply: "Reply",
2167
+ deletion: "Deletion",
2168
+ emphasis: "Emphasis",
2169
+ highlightmark: "Highlightmark",
2170
+ i: "Italic",
2171
+ insertion: "Insertion",
2172
+ sc: "Small Caps",
2173
+ strike: "Strike",
2174
+ sub: "Subscript",
2175
+ sup: "Superscript",
2176
+ u: "Underline",
2177
+ b: "Bold",
2178
+ degrees: "Degrees",
2179
+ email: "Email",
2180
+ equation: "Equation",
2181
+ fignote: "Fignote",
2182
+ figsource: "Figsource",
2183
+ firstname: "Firstname",
2184
+ footnote: "Footnote Marker",
2185
+ footnoteno: "Footnote Number",
2186
+ honorific: "Honorific",
2187
+ img: "Image",
2188
+ informalfigure: "Floating Figure",
2189
+ keyword: "Keyword",
2190
+ label1: "Label",
2191
+ li: "List Item",
2192
+ line: "Line",
2193
+ lrh: "Running Head Left",
2194
+ math: "Math",
2195
+ mathphrase: "Math Phrase",
2196
+ merror: "Math Error",
2197
+ mfrac: "Math Fraction",
2198
+ mi: "Math Identifier",
2199
+ mmultiscripts: "Math Multiscripts",
2200
+ mn: "Math Number",
2201
+ mo: "Math Operator",
2202
+ mover: "Math Over",
2203
+ mpadded: "Math Padded",
2204
+ mphantom: "Math Phantom",
2205
+ mprescripts: "Math Prescripts",
2206
+ mroot: "Math Root",
2207
+ mrow: "Math Row",
2208
+ ms: "Math Space",
2209
+ mspace: "Math Space",
2210
+ msqrt: "Math Square Root",
2211
+ mstyle: "Math Style",
2212
+ msub: "Math Subscript",
2213
+ msubsup: "Math Subscript Superscript",
2214
+ msup: "Math Superscript",
2215
+ mtable: "Math Table",
2216
+ mtd: "Math Table Data",
2217
+ mtext: "Math Text",
2218
+ mtr: "Math Table Row",
2219
+ munder: "Math Under",
2220
+ munderover: "Math Under Over",
2221
+ olink: "Online Link",
2222
+ org: "Org",
2223
+ orgname: "Orgname",
2224
+ para: "Paragraph",
2225
+ punc: "Punctuation",
2226
+ rrh: "Running Head Right",
2227
+ source1: "Source",
2228
+ speaker: "Speaker",
2229
+ subtitle1: "Subtitle",
2230
+ surname: "Surname",
2231
+ tag: "Tag",
2232
+ tblfn: "Table Footnote",
2233
+ tblsource: "Table Source",
2234
+ thead: "Thead",
2235
+ title1: "Title",
2236
+ token: "Token",
2237
+ tp: "Table Paragraph",
2238
+ abstract1: "Abstract",
2239
+ affiliation: "Affiliation",
2240
+ alttext: "Alttext",
2241
+ appendix: "Appendix",
2242
+ author: "Author",
2243
+ authorgroup: "Authorgroup",
2244
+ blockquote: "Blockquote",
2245
+ caption1: "Caption",
2246
+ chapter: "Chapter",
2247
+ dialogue: "Dialogue",
2248
+ epigraph: "Epigraph",
2249
+ figure1: "Figure",
2250
+ footnoteSection: "Footnote Section",
2251
+ heading: "Heading",
2252
+ imageobject: "Image Object",
2253
+ info1: "Info",
2254
+ keywordset: "Keyword FGroup",
2255
+ mediaobject: "Mediaobject",
2256
+ ol: "Ordered List",
2257
+ personname: "Person Name",
2258
+ poem: "Poem",
2259
+ sidebar: "Box",
2260
+ table: "Table",
2261
+ table1: "Table",
2262
+ tbody: "Table Body",
2263
+ td: "Table Data",
2264
+ tgroup: "Table Group",
2265
+ tr: "Table Row",
2266
+ ul: "Unordered List",
2267
+ footnote1: "Footnote",
2268
+ inlineequation: "Inline Equation",
2269
+ link: "Link",
2270
+ uri: "URI"
2271
+ };
2272
+
2153
2273
  // src/schema/shared/ignoredElements.ts
2154
2274
  var IGNORED_ELEMENT_SELECTORS = [
2155
2275
  "span.rhlabel",
@@ -2461,7 +2581,7 @@ var validateAttributes = (element, schema) => {
2461
2581
  };
2462
2582
 
2463
2583
  // src/validation/validateChildren.ts
2464
- var validateElementAgainstSchema = (element, schema) => {
2584
+ var validateElementAgainstSchema = (element, schema, inheritedForbiddenScope) => {
2465
2585
  const errors = [];
2466
2586
  if (element.tagName.toUpperCase() !== schema.tag) {
2467
2587
  addValidationIssue(errors, {
@@ -2500,15 +2620,18 @@ var validateElementAgainstSchema = (element, schema) => {
2500
2620
  });
2501
2621
  }
2502
2622
  errors.push(...validateAttributes(element, schema));
2503
- errors.push(...validateChildren(element, schema));
2623
+ errors.push(...validateChildren(element, schema, inheritedForbiddenScope));
2504
2624
  return errors;
2505
2625
  };
2506
- var validateChildren = (element, schema) => {
2626
+ var validateChildren = (element, schema, inheritedForbiddenScope) => {
2507
2627
  const errors = [];
2508
2628
  const childElements = [...element.children].filter(
2509
2629
  (child) => !isIgnoredElement(child)
2510
2630
  );
2511
2631
  const allowedChildren = [...schema.allowedChildTagNames];
2632
+ if (schema.kind === "atom") {
2633
+ return errors;
2634
+ }
2512
2635
  for (const child of childElements) {
2513
2636
  const childTag = child.tagName.toUpperCase();
2514
2637
  const allowedChild = allowedChildren.find(
@@ -2535,22 +2658,26 @@ var validateChildren = (element, schema) => {
2535
2658
  });
2536
2659
  continue;
2537
2660
  }
2538
- if (schema.forbiddenElements) {
2539
- const forbiddenChild = Array.from(schema.forbiddenElements).find(
2540
- (candidate) => candidate.code === childSchema.code
2541
- );
2542
- if (forbiddenChild) {
2543
- addValidationIssue(errors, {
2544
- store: getStore(child),
2545
- title: `Forbidden element ${child.tagName}`,
2546
- level: "blocker",
2547
- kind: "forbidden",
2548
- description: `The element ${childSchema.code} is not permitted within ${schema.tag} content. Please delete the element or move it to a different location.`
2549
- });
2550
- continue;
2551
- }
2661
+ const forbiddenChild = Array.from(inheritedForbiddenScope || []).find(
2662
+ (candidate) => candidate.code === childSchema.code
2663
+ );
2664
+ if (forbiddenChild) {
2665
+ addValidationIssue(errors, {
2666
+ store: getStore(child),
2667
+ title: `Forbidden element ${child.tagName}`,
2668
+ level: "blocker",
2669
+ kind: "forbidden",
2670
+ 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.`
2671
+ });
2672
+ continue;
2552
2673
  }
2553
- errors.push(...validateElementAgainstSchema(child, childSchema));
2674
+ errors.push(
2675
+ ...validateElementAgainstSchema(
2676
+ child,
2677
+ childSchema,
2678
+ inheritedForbiddenScope
2679
+ )
2680
+ );
2554
2681
  }
2555
2682
  for (const allowedChild of allowedChildren) {
2556
2683
  if (!allowedChild.required) {
@@ -2605,7 +2732,13 @@ var validateElement = (element, root, elementsLinkedTo, schemasToValidateAgainst
2605
2732
  const schema = findSchemaByElement(element);
2606
2733
  if (schema) {
2607
2734
  if (schemasToValidateAgainst.includes(schema.code)) {
2608
- errors.push(...validateElementAgainstSchema(element, schema));
2735
+ errors.push(
2736
+ ...validateElementAgainstSchema(
2737
+ element,
2738
+ schema,
2739
+ schema.forbiddenElements
2740
+ )
2741
+ );
2609
2742
  }
2610
2743
  const role = element.getAttribute("role") || "";
2611
2744
  const linkableRoles = getLinkableRoles();
@@ -2649,6 +2782,7 @@ export {
2649
2782
  ATOM_SCHEMAS,
2650
2783
  ELEMENT_SCHEMAS,
2651
2784
  ELE_ID_ATTRIBUTE,
2785
+ ElementLabel,
2652
2786
  FIGURE_PLACEMENT_ATTRIBUTE,
2653
2787
  ID_ATTRS,
2654
2788
  IGNORED_ATTRIBUTES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "0.1.185",
3
+ "version": "0.1.187",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",