pro-editor-schema 1.4.1 → 1.5.5-8

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/README.md CHANGED
@@ -4,7 +4,7 @@ TypeScript library that defines XML/HTML schema rules used by the editor and pro
4
4
 
5
5
  ## NPM
6
6
 
7
- https://www.npmjs.com/package/pro-editor-schema?activeTab=versions
7
+ https://www.npmjs.com/package/pro-editor-schema
8
8
 
9
9
  ## What this repository contains
10
10
 
@@ -131,6 +131,7 @@ The publishing workflow is defined in `.github/workflows/publish.yml`.
131
131
  - `src/schema/elementSchemas/elements` — element schema definitions and `ELEMENT_SCHEMAS`.
132
132
  - `src/schema/elementSchemas/atoms` — atom schema definitions and `ATOM_SCHEMAS`.
133
133
  - `src/schema/elementSchemas/inlineElements` — inline schema definitions and `INLINE_ELEMENT_SCHEMAS`.
134
+ - `src/schema/referenceSchemas` — reference type and reference field schemas for bibliography entries.
134
135
  - `src/schema/shared` — shared allowed-children lists, global attributes, and labels.
135
136
  - `src/schema/helpers` — `createSchema` and schema lookup/attribute helpers.
136
137
  - `src/helpers` — DOM helpers (`createElement`, `closestElementBySchema`, ignored attributes/elements, and related utilities).
@@ -181,7 +182,7 @@ From `src/index.ts`, consumers can import:
181
182
  - **Schema helpers:** `findSchemaByCode`, `findSchemaByElement`, `findAttributeDefinitionByName`, `getAttributeName`, `isAttributeRestricted`, `isTrackChangesSchema`
182
183
  - **DOM helpers:** `createElement`, `closestElementBySchema`, `queryElementBySchema`, `queryAllElementsBySchema`, `getElementLinks`, `getStore`, `isDeletedElement`
183
184
  - **Ignored nodes:** `isIgnoredAttribute`, `isIgnoredElement`, `IGNORED_ATTRIBUTES`, `IGNORED_ELEMENT_SELECTORS`
184
- - **Validation:** `validateXml`
185
+ - **Validation:** `validateXml`, `validateXmlAsync`
185
186
  - **Shared constants:** `ElementLabel`, global attribute constants, dependents forbidden elements
186
187
 
187
188
  ## Usage examples
@@ -255,6 +256,30 @@ It also runs per-element checks for:
255
256
 
256
257
  Schema-based attribute and child validation only runs for codes listed in `schemasToValidateAgainst`.
257
258
 
259
+ ### Validate a large document without freezing the page
260
+
261
+ ```ts
262
+ import { validateXmlAsync } from "pro-editor-schema";
263
+
264
+ const controller = new AbortController();
265
+ const errors = await validateXmlAsync(
266
+ rootElement.cloneNode(true) as Element,
267
+ elementsToLink,
268
+ linkElements,
269
+ ["para", "heading"],
270
+ { signal: controller.signal },
271
+ );
272
+ ```
273
+
274
+ `validateXmlAsync` returns the same issues as `validateXml`, in the same order, but works in short slices and hands the main thread back between them (`scheduler.yield()` where available, otherwise `setTimeout`).
275
+
276
+ - `signal` — aborting it rejects the promise with the signal's reason, for example when a newer edit makes the run outdated.
277
+ - `timeBudgetMs` — how long to work before yielding. Defaults to 8 ms.
278
+
279
+ Pass a copy of the document if it can change while validation runs.
280
+
281
+ Listing `referenceBibliomixed` checks each bibliography entry against the schema of its reference type instead (see [Reference schemas](#reference-schemas)).
282
+
258
283
  ## How validation works
259
284
 
260
285
  - `validateXml` traverses the XML tree and delegates checks per element.
@@ -273,6 +298,25 @@ Validation results use `ValidationError`:
273
298
  - `level` (`blocker` | `warning` | `info`)
274
299
  - `kind` (`unlinked` | `forbidden` | `missing` | `converted`)
275
300
  - `description`
301
+ - `elements` (optional) — the elements the issue is about, when it is about specific ones. Reference issues set it; it is empty for an issue about the reference as a whole.
302
+
303
+ ## Reference schemas
304
+
305
+ A `bibliomixed` is mixed content, so its structure is described by two schemas on top of the element schemas of its parts (`bibliomset`, `pubdate`, `publishername`, and so on):
306
+
307
+ - `REFERENCE_FIELD_SCHEMAS` — every bibliographic field (`title`, `year`, `publisher`, ...), and the element schemas that can express it. Any field may be tagged more than once.
308
+ - `REFERENCE_TYPE_SCHEMAS` — one schema per reference type, keyed by the DocBook `role` of the `bibliomixed` (`monograph`, `article`, ...), with the fields the type allows and requires. Legacy roles such as `book` and `journal` resolve to the type they stand for.
309
+
310
+ Helpers:
311
+
312
+ - `findReferenceTypeSchemaByElement(bibliomixed)` — the type schema a reference declares.
313
+ - `findReferenceFieldByElement(element)` — the field a tagged part expresses. The same element can express different fields: a `title1` inside a `book` or `journal` block is the container title, a `date` with `role="accessed"` is the access date.
314
+ - `getReferenceParts(bibliomixed)` — the outermost tagged parts of a reference. Content inside a tracked deletion is left out and pending insertions count.
315
+ - `getReferenceFieldElements(bibliomixed)` — the fields those parts express, each with its element.
316
+ - `getReferenceStructureIssueElements(bibliomixed, issue)` — the elements of that reference an issue is about, also when the issue was found on a copy of it. Empty for an issue about the reference as a whole, such as a missing field.
317
+ - `validateReferenceStructure(bibliomixed)` — structured issues for editors that present them their own way. `unknown_type`, `missing` and `not_allowed` describe the fields of the type. `wrong_element` names a tag the type or DocBook does not permit and the tag to use instead, and `markup` names a DocBook tagging rule that is broken (a missing `xmlid`, a `bibliomset` relation the type does not use or repeats, a `personname` without a name order, a `uri` outside a link, and so on); both carry the offending elements.
318
+
319
+ `validateXml` reports the same issues as `warning`s when `referenceBibliomixed` is in `schemasToValidateAgainst`. It checks entries inside a `bibliography` that have at least one tagged part; plain-text entries and deleted entries are skipped.
276
320
 
277
321
  ## Adding or updating a schema
278
322
 
package/dist/index.d.mts CHANGED
@@ -21,7 +21,7 @@ type Schema<TRequiredAttributes = readonly AttributeDefinition[], TOptionalAttri
21
21
  matchesElement?: (element: Element) => boolean;
22
22
  };
23
23
  type SchemaCode = ElementSchemaCode | InlineSchemaCode | AtomSchemaCode;
24
- type ElementSchemaCode = "referenceBibliomixed" | "referenceBibliography" | "bibliodiv" | "degrees" | "email" | "equation" | "fignote" | "figsource" | "firstname" | "footnote" | "footnoteno" | "honorific" | "img" | "informalfigure" | "keyword" | "label1" | "li" | "line" | "linegroup" | "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";
24
+ type ElementSchemaCode = "referenceBibliomixed" | "referenceBibliography" | "bibliodiv" | "bibliomset" | "editor" | "othercredit" | "translator" | "collab" | "pubdate" | "date" | "publishername" | "address" | "city" | "volumenum" | "issuenum" | "pagenums" | "pagenum" | "edition" | "pubId" | "biblioid" | "bibliomisc" | "confgroup" | "conftitle" | "degrees" | "email" | "equation" | "fignote" | "figsource" | "firstname" | "footnote" | "footnoteno" | "honorific" | "img" | "informalfigure" | "keyword" | "label1" | "li" | "line" | "linegroup" | "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";
25
25
  type AtomSchemaCode = "mark" | "indexterm" | "primary" | "secondary" | "tertiary" | "quaternary" | "bookmark" | "see" | "commentQuerySection" | "comment" | "content" | "query" | "reply" | "deletion" | "lineGroupRemoval" | "emphasis" | "highlightmark" | "i" | "insertion" | "sc" | "strike" | "sub" | "sup" | "u" | "b" | "referenceMark" | "abbreviation";
26
26
  type InlineSchemaCode = "footnote1" | "inlineequation" | "link" | "uri" | "phrase";
27
27
 
@@ -47,11 +47,7 @@ declare const SCHEMAS: {
47
47
  readonly defaultValue: "added";
48
48
  }]>;
49
49
  phrase: Schema<readonly ["store", "ele-id", "xml:lang"], readonly []>;
50
- bibliodiv: Schema<readonly ["store", "ele-id", {
51
- readonly name: "role";
52
- readonly values: readonly ["H1", "H2", "H3", "H4", "H5", "H6"];
53
- readonly defaultValue: "H1";
54
- }], readonly []>;
50
+ bibliodiv: Schema<readonly ["store", "ele-id", "role"], readonly []>;
55
51
  referenceBibliography: Schema<readonly ["store", "ele-id", "xmlid", {
56
52
  readonly name: "role";
57
53
  readonly values: readonly ["chapterend"];
@@ -62,6 +58,30 @@ declare const SCHEMAS: {
62
58
  readonly defaultValue: "doc-bibliography";
63
59
  }], readonly []>;
64
60
  referenceBibliomixed: Schema<readonly ["store", "ele-id", "xmlid", "role"], readonly ["track-role", "data-userid", "data-date"]>;
61
+ bibliomset: Schema<readonly [{
62
+ readonly name: "relation";
63
+ readonly values: readonly ["part", "article", "book", "journal"];
64
+ readonly defaultValue: "part";
65
+ }], readonly ["store", "ele-id"]>;
66
+ editor: Schema<readonly [], readonly ["store", "ele-id"]>;
67
+ othercredit: Schema<readonly [], readonly ["store", "ele-id", "class", "otherclass"]>;
68
+ translator: Schema<readonly [], readonly ["store", "ele-id"]>;
69
+ collab: Schema<readonly [], readonly ["store", "ele-id"]>;
70
+ pubdate: Schema<readonly [], readonly ["store", "ele-id"]>;
71
+ date: Schema<readonly [], readonly ["store", "ele-id", "role"]>;
72
+ publishername: Schema<readonly [], readonly ["store", "ele-id"]>;
73
+ address: Schema<readonly [], readonly ["store", "ele-id"]>;
74
+ city: Schema<readonly [], readonly ["store", "ele-id"]>;
75
+ volumenum: Schema<readonly [], readonly ["store", "ele-id"]>;
76
+ issuenum: Schema<readonly [], readonly ["store", "ele-id"]>;
77
+ pagenums: Schema<readonly [], readonly ["store", "ele-id"]>;
78
+ pagenum: Schema<readonly [], readonly ["store", "ele-id"]>;
79
+ edition: Schema<readonly [], readonly ["store", "ele-id"]>;
80
+ pubId: Schema<readonly [], readonly ["store", "ele-id", "pub-id-type", "assigning-authority"]>;
81
+ biblioid: Schema<readonly [], readonly ["store", "ele-id", "class", "otherclass"]>;
82
+ bibliomisc: Schema<readonly [], readonly ["store", "ele-id", "role"]>;
83
+ confgroup: Schema<readonly [], readonly ["store", "ele-id"]>;
84
+ conftitle: Schema<readonly [], readonly ["store", "ele-id"]>;
65
85
  para: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date", "data-alignment", "data-left-indent", "data-right-indent", "data-special-indent", "data-space-above", "data-space-below", "data-indent-type", "data-layout-user", "data-paragraph-style", "xmlid", "role", "data-pos"]>;
66
86
  title1: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date", "data-alignment", "data-left-indent", "data-right-indent", "data-special-indent", "data-space-above", "data-space-below", "data-indent-type", "data-layout-user", "data-paragraph-style", "role", {
67
87
  readonly name: "fm-role";
@@ -69,7 +89,7 @@ declare const SCHEMAS: {
69
89
  readonly defaultValue: "false";
70
90
  }, {
71
91
  readonly name: "title";
72
- readonly values: readonly ["H1", "H2", "H3", "H4", "H5", "H6", "foot_note"];
92
+ readonly values: readonly [...string[], "foot_note"];
73
93
  readonly defaultValue: "H1";
74
94
  }]>;
75
95
  footnote: Schema<readonly ["store", "ele-id", "label", "xmlid", {
@@ -248,7 +268,7 @@ declare const SCHEMAS: {
248
268
  }]>;
249
269
  sidebar: Schema<readonly ["store", "ele-id", {
250
270
  readonly name: "status";
251
- readonly values: readonly ["box1", "box2", "box3", "box4", "box5"];
271
+ readonly values: string[];
252
272
  readonly defaultValue: "box1";
253
273
  }], readonly ["data-username", "data-userid", "data-time", "data-date", "xmlid", {
254
274
  readonly name: "role";
@@ -290,7 +310,7 @@ declare const SCHEMAS: {
290
310
  sc: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date"]>;
291
311
  emphasis: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date", {
292
312
  readonly name: "role";
293
- readonly values: readonly ["lowercase", "uppercase", "initialcaps"];
313
+ readonly values: readonly ["lowercase", "uppercase", "initialcaps", "Non breaking space"];
294
314
  readonly defaultValue: "lowercase";
295
315
  }]>;
296
316
  strike: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date"]>;
@@ -358,6 +378,235 @@ declare const isAttributeRestricted: (attr: AttributeDefinition) => attr is Rest
358
378
 
359
379
  declare const isTrackChangesSchema: (schema: Schema) => boolean;
360
380
 
381
+ type ReferenceTypeCode = "monograph" | "serial" | "contribution" | "article" | "message" | "website" | "unpublished" | "case" | "legislation" | "other" | "recording" | "film";
382
+ type ReferenceFieldCode = "author" | "editor" | "title" | "year" | "containerTitle" | "publisherPlace" | "publisher" | "volume" | "issue" | "pages" | "doi" | "url" | "accessDate" | "genre" | "eventTitle" | "eventPlace" | "documentNumber" | "pubmedId";
383
+ type RequiredReferenceField = "title" | "containerTitle" | "creators" | "year";
384
+ type BibliomsetRelation = "part" | "book" | "article" | "journal";
385
+ type ReferenceElementReplacement = {
386
+ tag: string;
387
+ replacement?: string;
388
+ };
389
+ type ReferenceFieldSchema = {
390
+ code: ReferenceFieldCode;
391
+ label: string;
392
+ elementCodes: readonly SchemaCode[];
393
+ };
394
+ type ReferenceTypeSchema = {
395
+ code: ReferenceTypeCode;
396
+ label: string;
397
+ legacyRoles: readonly string[];
398
+ allowedFields: readonly ReferenceFieldCode[];
399
+ requiredFields: readonly RequiredReferenceField[];
400
+ bibliomsetRelations?: readonly BibliomsetRelation[];
401
+ replacedElements?: readonly ReferenceElementReplacement[];
402
+ fieldLabels?: Partial<Record<ReferenceFieldCode, string>>;
403
+ };
404
+
405
+ declare const findReferenceTypeSchemaByElement: (reference: Element) => ReferenceTypeSchema | undefined;
406
+
407
+ declare const findReferenceFieldByElement: (element: Element) => ReferenceFieldCode | undefined;
408
+
409
+ declare const REFERENCE_FIELD_SCHEMAS: {
410
+ author: {
411
+ code: "author";
412
+ label: string;
413
+ elementCodes: ("othercredit" | "author")[];
414
+ };
415
+ editor: {
416
+ code: "editor";
417
+ label: string;
418
+ elementCodes: "editor"[];
419
+ };
420
+ title: {
421
+ code: "title";
422
+ label: string;
423
+ elementCodes: "title1"[];
424
+ };
425
+ year: {
426
+ code: "year";
427
+ label: string;
428
+ elementCodes: ("pubdate" | "date" | "confgroup")[];
429
+ };
430
+ containerTitle: {
431
+ code: "containerTitle";
432
+ label: string;
433
+ elementCodes: "title1"[];
434
+ };
435
+ publisherPlace: {
436
+ code: "publisherPlace";
437
+ label: string;
438
+ elementCodes: "address"[];
439
+ };
440
+ publisher: {
441
+ code: "publisher";
442
+ label: string;
443
+ elementCodes: ("publishername" | "orgname")[];
444
+ };
445
+ volume: {
446
+ code: "volume";
447
+ label: string;
448
+ elementCodes: "volumenum"[];
449
+ };
450
+ issue: {
451
+ code: "issue";
452
+ label: string;
453
+ elementCodes: "issuenum"[];
454
+ };
455
+ pages: {
456
+ code: "pages";
457
+ label: string;
458
+ elementCodes: "pagenums"[];
459
+ };
460
+ doi: {
461
+ code: "doi";
462
+ label: string;
463
+ elementCodes: "link"[];
464
+ };
465
+ url: {
466
+ code: "url";
467
+ label: string;
468
+ elementCodes: "link"[];
469
+ };
470
+ accessDate: {
471
+ code: "accessDate";
472
+ label: string;
473
+ elementCodes: "date"[];
474
+ };
475
+ genre: {
476
+ code: "genre";
477
+ label: string;
478
+ elementCodes: "bibliomisc"[];
479
+ };
480
+ eventTitle: {
481
+ code: "eventTitle";
482
+ label: string;
483
+ elementCodes: "confgroup"[];
484
+ };
485
+ eventPlace: {
486
+ code: "eventPlace";
487
+ label: string;
488
+ elementCodes: "address"[];
489
+ };
490
+ documentNumber: {
491
+ code: "documentNumber";
492
+ label: string;
493
+ elementCodes: "bibliomisc"[];
494
+ };
495
+ pubmedId: {
496
+ code: "pubmedId";
497
+ label: string;
498
+ elementCodes: "biblioid"[];
499
+ };
500
+ };
501
+
502
+ declare const REFERENCE_TYPE_SCHEMAS: {
503
+ monograph: {
504
+ code: "monograph";
505
+ label: string;
506
+ legacyRoles: string[];
507
+ allowedFields: ("editor" | "author" | "title" | "year" | "publisherPlace" | "publisher" | "volume" | "doi" | "url")[];
508
+ requiredFields: ("title" | "creators")[];
509
+ fieldLabels: {
510
+ title: string;
511
+ };
512
+ };
513
+ serial: {
514
+ code: "serial";
515
+ label: string;
516
+ legacyRoles: never[];
517
+ allowedFields: ("title" | "year" | "volume" | "issue" | "doi" | "url")[];
518
+ requiredFields: "title"[];
519
+ };
520
+ contribution: {
521
+ code: "contribution";
522
+ label: string;
523
+ legacyRoles: string[];
524
+ allowedFields: ("editor" | "author" | "title" | "year" | "containerTitle" | "publisherPlace" | "publisher" | "pages" | "doi" | "url")[];
525
+ requiredFields: ("title" | "containerTitle" | "creators")[];
526
+ bibliomsetRelations: ("book" | "part")[];
527
+ fieldLabels: {
528
+ title: string;
529
+ containerTitle: string;
530
+ };
531
+ };
532
+ article: {
533
+ code: "article";
534
+ label: string;
535
+ legacyRoles: string[];
536
+ allowedFields: ("editor" | "author" | "title" | "year" | "containerTitle" | "publisherPlace" | "publisher" | "volume" | "issue" | "pages" | "doi" | "url" | "accessDate" | "genre" | "pubmedId")[];
537
+ requiredFields: ("title" | "containerTitle")[];
538
+ bibliomsetRelations: ("article" | "journal")[];
539
+ fieldLabels: {
540
+ title: string;
541
+ containerTitle: string;
542
+ };
543
+ };
544
+ message: {
545
+ code: "message";
546
+ label: string;
547
+ legacyRoles: never[];
548
+ allowedFields: ("author" | "title" | "year" | "doi" | "url")[];
549
+ requiredFields: "title"[];
550
+ };
551
+ website: {
552
+ code: "website";
553
+ label: string;
554
+ legacyRoles: never[];
555
+ allowedFields: ("author" | "title" | "year" | "doi" | "url" | "accessDate")[];
556
+ requiredFields: "title"[];
557
+ };
558
+ unpublished: {
559
+ code: "unpublished";
560
+ label: string;
561
+ legacyRoles: never[];
562
+ allowedFields: ("author" | "title" | "year" | "publisher" | "doi" | "url" | "genre" | "eventTitle" | "eventPlace")[];
563
+ requiredFields: "title"[];
564
+ replacedElements: {
565
+ tag: string;
566
+ replacement: string;
567
+ }[];
568
+ };
569
+ case: {
570
+ code: "case";
571
+ label: string;
572
+ legacyRoles: never[];
573
+ allowedFields: ("title" | "year" | "doi" | "url" | "documentNumber")[];
574
+ requiredFields: "title"[];
575
+ };
576
+ legislation: {
577
+ code: "legislation";
578
+ label: string;
579
+ legacyRoles: never[];
580
+ allowedFields: ("title" | "year" | "publisherPlace" | "doi" | "url" | "documentNumber")[];
581
+ requiredFields: "title"[];
582
+ };
583
+ other: {
584
+ code: "other";
585
+ label: string;
586
+ legacyRoles: never[];
587
+ allowedFields: readonly ["author", "editor", "title", "year", "containerTitle", "publisherPlace", "publisher", "volume", "issue", "pages", "accessDate", "genre", "eventTitle", "eventPlace", "documentNumber", "pubmedId", "doi", "url"];
588
+ requiredFields: "title"[];
589
+ };
590
+ recording: {
591
+ code: "recording";
592
+ label: string;
593
+ legacyRoles: never[];
594
+ allowedFields: ("author" | "title" | "year" | "doi" | "url")[];
595
+ requiredFields: ("title" | "year")[];
596
+ replacedElements: {
597
+ tag: string;
598
+ replacement: string;
599
+ }[];
600
+ };
601
+ film: {
602
+ code: "film";
603
+ label: string;
604
+ legacyRoles: never[];
605
+ allowedFields: ("title" | "year" | "doi" | "url")[];
606
+ requiredFields: "title"[];
607
+ };
608
+ };
609
+
361
610
  declare const ElementLabel: Record<SchemaCode, string>;
362
611
 
363
612
  type DependentForbiddenElement = {
@@ -379,6 +628,7 @@ declare const FIGURE_PLACEMENT_ATTRIBUTE = "data-figure-placement";
379
628
  declare const LAYOUT_CELL_WIDTH_ATTRIBUTE = "data-cell-width";
380
629
  declare const LAYOUT_TABLE_ORIENTATION_ATTRIBUTE = "data-table-orientation";
381
630
  declare const LAYOUT_TABLE_PLACEMENT_ATTRIBUTE = "data-table-placement";
631
+ declare const VALIDATION_IGNORED_ATTRIBUTE = "data-validation-ignored";
382
632
  declare const LAYOUT_ATTRIBUTES: readonly ["data-alignment", "data-left-indent", "data-right-indent", "data-special-indent", "data-space-above", "data-space-below", "data-indent-type", "data-layout-user", "data-paragraph-style"];
383
633
  declare const TRACK_CHANGES_ATTR_DATA_USERNAME = "data-username";
384
634
  declare const TRACK_CHANGES_ATTR_DATA_USERID = "data-userid";
@@ -392,11 +642,7 @@ declare const LINKEND_ATTRIBUTE = "linkend";
392
642
  declare const ID_ATTRS: readonly ["store", "ele-id"];
393
643
 
394
644
  declare const ELEMENT_SCHEMAS: {
395
- bibliodiv: Schema<readonly ["store", "ele-id", {
396
- readonly name: "role";
397
- readonly values: readonly ["H1", "H2", "H3", "H4", "H5", "H6"];
398
- readonly defaultValue: "H1";
399
- }], readonly []>;
645
+ bibliodiv: Schema<readonly ["store", "ele-id", "role"], readonly []>;
400
646
  referenceBibliography: Schema<readonly ["store", "ele-id", "xmlid", {
401
647
  readonly name: "role";
402
648
  readonly values: readonly ["chapterend"];
@@ -407,6 +653,30 @@ declare const ELEMENT_SCHEMAS: {
407
653
  readonly defaultValue: "doc-bibliography";
408
654
  }], readonly []>;
409
655
  referenceBibliomixed: Schema<readonly ["store", "ele-id", "xmlid", "role"], readonly ["track-role", "data-userid", "data-date"]>;
656
+ bibliomset: Schema<readonly [{
657
+ readonly name: "relation";
658
+ readonly values: readonly ["part", "article", "book", "journal"];
659
+ readonly defaultValue: "part";
660
+ }], readonly ["store", "ele-id"]>;
661
+ editor: Schema<readonly [], readonly ["store", "ele-id"]>;
662
+ othercredit: Schema<readonly [], readonly ["store", "ele-id", "class", "otherclass"]>;
663
+ translator: Schema<readonly [], readonly ["store", "ele-id"]>;
664
+ collab: Schema<readonly [], readonly ["store", "ele-id"]>;
665
+ pubdate: Schema<readonly [], readonly ["store", "ele-id"]>;
666
+ date: Schema<readonly [], readonly ["store", "ele-id", "role"]>;
667
+ publishername: Schema<readonly [], readonly ["store", "ele-id"]>;
668
+ address: Schema<readonly [], readonly ["store", "ele-id"]>;
669
+ city: Schema<readonly [], readonly ["store", "ele-id"]>;
670
+ volumenum: Schema<readonly [], readonly ["store", "ele-id"]>;
671
+ issuenum: Schema<readonly [], readonly ["store", "ele-id"]>;
672
+ pagenums: Schema<readonly [], readonly ["store", "ele-id"]>;
673
+ pagenum: Schema<readonly [], readonly ["store", "ele-id"]>;
674
+ edition: Schema<readonly [], readonly ["store", "ele-id"]>;
675
+ pubId: Schema<readonly [], readonly ["store", "ele-id", "pub-id-type", "assigning-authority"]>;
676
+ biblioid: Schema<readonly [], readonly ["store", "ele-id", "class", "otherclass"]>;
677
+ bibliomisc: Schema<readonly [], readonly ["store", "ele-id", "role"]>;
678
+ confgroup: Schema<readonly [], readonly ["store", "ele-id"]>;
679
+ conftitle: Schema<readonly [], readonly ["store", "ele-id"]>;
410
680
  para: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date", "data-alignment", "data-left-indent", "data-right-indent", "data-special-indent", "data-space-above", "data-space-below", "data-indent-type", "data-layout-user", "data-paragraph-style", "xmlid", "role", "data-pos"]>;
411
681
  title1: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date", "data-alignment", "data-left-indent", "data-right-indent", "data-special-indent", "data-space-above", "data-space-below", "data-indent-type", "data-layout-user", "data-paragraph-style", "role", {
412
682
  readonly name: "fm-role";
@@ -414,7 +684,7 @@ declare const ELEMENT_SCHEMAS: {
414
684
  readonly defaultValue: "false";
415
685
  }, {
416
686
  readonly name: "title";
417
- readonly values: readonly ["H1", "H2", "H3", "H4", "H5", "H6", "foot_note"];
687
+ readonly values: readonly [...string[], "foot_note"];
418
688
  readonly defaultValue: "H1";
419
689
  }]>;
420
690
  footnote: Schema<readonly ["store", "ele-id", "label", "xmlid", {
@@ -593,7 +863,7 @@ declare const ELEMENT_SCHEMAS: {
593
863
  }]>;
594
864
  sidebar: Schema<readonly ["store", "ele-id", {
595
865
  readonly name: "status";
596
- readonly values: readonly ["box1", "box2", "box3", "box4", "box5"];
866
+ readonly values: string[];
597
867
  readonly defaultValue: "box1";
598
868
  }], readonly ["data-username", "data-userid", "data-time", "data-date", "xmlid", {
599
869
  readonly name: "role";
@@ -662,7 +932,7 @@ declare const ATOM_SCHEMAS: {
662
932
  sc: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date"]>;
663
933
  emphasis: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date", {
664
934
  readonly name: "role";
665
- readonly values: readonly ["lowercase", "uppercase", "initialcaps"];
935
+ readonly values: readonly ["lowercase", "uppercase", "initialcaps", "Non breaking space"];
666
936
  readonly defaultValue: "lowercase";
667
937
  }]>;
668
938
  strike: Schema<readonly ["store", "ele-id"], readonly ["data-username", "data-userid", "data-time", "data-date"]>;
@@ -721,16 +991,18 @@ type ValidationErrorLevel = "blocker" | "warning" | "info";
721
991
  type ValidationErrorKind = "unlinked" | "uncited" | "forbidden" | "missing" | "converted" | "possible-url" | "unreachable-url";
722
992
  type ValidationError = {
723
993
  id: string;
724
- store: string;
994
+ store?: string;
725
995
  title: string;
726
996
  level: ValidationErrorLevel;
727
997
  kind: ValidationErrorKind;
728
998
  description: string;
999
+ ignored: boolean;
1000
+ elements?: Element[];
729
1001
  };
730
1002
 
731
1003
  /**
732
1004
  * Validates the XML document against the schema.
733
-
1005
+
734
1006
  * @param xml - The XML document to validate.
735
1007
  * @param elementsToLink - The elements IDs that are linked to.
736
1008
  * @param linkElements - The elements IDs that are linked to.
@@ -739,6 +1011,82 @@ type ValidationError = {
739
1011
  * @returns The validation errors.
740
1012
  */
741
1013
  declare const validateXml: (xml: Element, elementsToLink: string[], linkElements: string[], schemasToValidateAgainst: SchemaCode[]) => ValidationError[];
1014
+ type ValidateXmlAsyncOptions = {
1015
+ /** Rejects with the signal's reason once aborted. */
1016
+ signal?: AbortSignal;
1017
+ /** How long to work before handing the main thread back. Defaults to 8 ms. */
1018
+ timeBudgetMs?: number;
1019
+ };
1020
+ /**
1021
+ * Same result as `validateXml`, but works in short slices and hands the main
1022
+ * thread back between them, so large documents do not freeze the page.
1023
+ *
1024
+ * Pass a copy of the document if it can change while validation runs.
1025
+ */
1026
+ declare const validateXmlAsync: (xml: Element, elementsToLink: string[], linkElements: string[], schemasToValidateAgainst: SchemaCode[], { signal, timeBudgetMs }?: ValidateXmlAsyncOptions) => Promise<ValidationError[]>;
1027
+
1028
+ type LinkIds = readonly string[] | ReadonlySet<string>;
1029
+
1030
+ declare const findElementLinkedTo: (linkend: string, elementsToLink: LinkIds) => boolean;
1031
+ declare const LINK_TO_CROSS_CHECK: string[];
1032
+ declare const LINK_BLOCKER_ROLES: string[];
1033
+ declare const validateLinkend: (linkElement: Element, elementsToLink: LinkIds) => ValidationError[];
1034
+
1035
+ /** Work split into steps: each `yield` is a point where a caller may pause. */
1036
+ type Steps<T> = Generator<void, T, void>;
1037
+
1038
+ declare const POSSIBLE_WEBLINK_CLASS = "possible-weblink";
1039
+ declare const POSSIBLE_WEBLINK_EXCLUDE_SELECTORS: string[];
1040
+ type PossibleWeblink = {
1041
+ weblink: string;
1042
+ elements: Element[];
1043
+ };
1044
+ declare const getPossibleWeblinks: (root: Element) => Map<string, PossibleWeblink>;
1045
+ declare const markPossibleWeblinks: (editor: HTMLElement) => Map<string, PossibleWeblink>;
1046
+ declare function validatePossibleWeblinksSteps(root: Element): Steps<ValidationError[]>;
1047
+ declare const validatePossibleWeblinks: (root: Element) => ValidationError[];
1048
+ declare const clearWeblinkMatches: (editor: HTMLElement) => void;
1049
+
1050
+ declare const validateOlink: (element: Element) => ValidationError[];
1051
+
1052
+ type ElementHierarchy = "heading" | "box";
1053
+ declare const validateHierarchy: (element: Element, elementHierarchy: ElementHierarchy) => ValidationError[];
1054
+
1055
+ declare const extractFootnoteNumber: (footnote: Element | null) => number | "no label";
1056
+ declare const validateFootnoteNumber: (footnoteElement: Element) => ValidationError[];
1057
+ declare const validateConsecutiveFootnotes: (root: Element | Document) => ValidationError[];
1058
+ declare const validateConsecutiveFootnoteCues: (root: Element | Document) => ValidationError[];
1059
+
1060
+ declare const validateElementToLinkTo: (element: Element, linkElements: LinkIds) => ValidationError[];
1061
+
1062
+ declare const validateElementAgainstSchema: (element: Element, schema: Schema) => ValidationError[];
1063
+ declare const getEffectiveChildElements: (element: Element) => Element[];
1064
+
1065
+ declare const validateAttributes: (element: Element, schema: Schema) => ValidationError[];
1066
+
1067
+ type ReferenceMarkupRule = "missing_id" | "bibliomset_relation" | "bibliomset_missing" | "bibliomset_repeated" | "bibliomset_title" | "bibliomset_nested" | "part_editor" | "personname_role" | "name_outside_personname" | "othercredit_artist" | "link_without_target" | "doi_inside_uri" | "doi_outside_doi_org" | "uri_outside_link" | "confgroup_text" | "confdates_outside_confgroup";
1068
+ type ReferenceMarkupIssue = {
1069
+ code: "wrong_element";
1070
+ tag: string;
1071
+ replacement?: string;
1072
+ elements: Element[];
1073
+ } | {
1074
+ code: "markup";
1075
+ rule: ReferenceMarkupRule;
1076
+ elements: Element[];
1077
+ };
1078
+
1079
+ type ReferenceStructureIssue = {
1080
+ code: "unknown_type";
1081
+ } | {
1082
+ code: "missing";
1083
+ field: RequiredReferenceField;
1084
+ } | {
1085
+ code: "not_allowed";
1086
+ field: ReferenceFieldCode;
1087
+ } | ReferenceMarkupIssue;
1088
+ declare const validateReferenceStructure: (reference: Element) => ReferenceStructureIssue[];
1089
+ declare const getReferenceStructureIssueElements: (reference: Element, issue: ReferenceStructureIssue) => Element[];
742
1090
 
743
1091
  declare const getElementLinks: (contentChaptersToValidate: string[]) => {
744
1092
  elementsToLink: string[];
@@ -785,4 +1133,12 @@ type GetAdjacentElementOptions = {
785
1133
  };
786
1134
  declare const getAdjacentElement: ({ element, direction, code, }: GetAdjacentElementOptions) => HTMLElement | undefined;
787
1135
 
788
- export { ALIGNMENT_ATTRIBUTE, ATOM_SCHEMAS, type AllowedChildren, type AtomSchemaCode, type AttributeDefinition, DEPENDENT_FORBIDDEN_ELEMENTS, ELEMENT_SCHEMAS, ELE_ID_ATTRIBUTE, ElementLabel, type ElementSchemaCode, FIGURE_PLACEMENT_ATTRIBUTE, 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, LINKEND_ATTRIBUTE, RIGHT_INDENT_ATTRIBUTE, type RestrictedAttribute, SCHEMAS, SPACE_ABOVE_ATTRIBUTE, SPACE_BELOW_ATTRIBUTE, SPECIAL_INDENT_ATTRIBUTE, STORE_ATTRIBUTE, STYLE_NAME_ATTRIBUTE, type Schema, type SchemaAttributes, type SchemaCode, type SchemaKind, type SchemasByCode, 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, XMLID_ATTRIBUTE, closestElementBySchema, createElement, findAttributeDefinitionByName, findSchemaByCode, findSchemaByElement, getAdjacentElement, getAttributeName, getElementLinks, getStore, isAttributeRestricted, isDeletedElement, isIgnoredAttribute, isIgnoredElement, isTrackChangesSchema, queryAllElementsBySchema, queryElementBySchema, validateXml };
1136
+ type ReferenceFieldElement = {
1137
+ field: ReferenceFieldCode;
1138
+ element: HTMLElement;
1139
+ };
1140
+ declare const REFERENCE_PART_SELECTOR: string;
1141
+ declare const getReferenceParts: (reference: Element) => HTMLElement[];
1142
+ declare const getReferenceFieldElements: (reference: Element) => ReferenceFieldElement[];
1143
+
1144
+ export { ALIGNMENT_ATTRIBUTE, ATOM_SCHEMAS, type AllowedChildren, type AtomSchemaCode, type AttributeDefinition, type BibliomsetRelation, DEPENDENT_FORBIDDEN_ELEMENTS, ELEMENT_SCHEMAS, ELE_ID_ATTRIBUTE, ElementLabel, type ElementSchemaCode, FIGURE_PLACEMENT_ATTRIBUTE, 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, LINKEND_ATTRIBUTE, LINK_BLOCKER_ROLES, LINK_TO_CROSS_CHECK, POSSIBLE_WEBLINK_CLASS, POSSIBLE_WEBLINK_EXCLUDE_SELECTORS, REFERENCE_FIELD_SCHEMAS, REFERENCE_PART_SELECTOR, REFERENCE_TYPE_SCHEMAS, RIGHT_INDENT_ATTRIBUTE, type ReferenceElementReplacement, type ReferenceFieldCode, type ReferenceFieldElement, type ReferenceFieldSchema, type ReferenceMarkupIssue, type ReferenceMarkupRule, type ReferenceStructureIssue, type ReferenceTypeCode, type ReferenceTypeSchema, type RequiredReferenceField, type RestrictedAttribute, SCHEMAS, SPACE_ABOVE_ATTRIBUTE, SPACE_BELOW_ATTRIBUTE, SPECIAL_INDENT_ATTRIBUTE, STORE_ATTRIBUTE, STYLE_NAME_ATTRIBUTE, type Schema, type SchemaAttributes, type SchemaCode, type SchemaKind, type SchemasByCode, TRACK_CHANGES_ATTRS, TRACK_CHANGES_ATTR_DATA_DATE, TRACK_CHANGES_ATTR_DATA_TIME, TRACK_CHANGES_ATTR_DATA_USERID, TRACK_CHANGES_ATTR_DATA_USERNAME, VALIDATION_IGNORED_ATTRIBUTE, type ValidateXmlAsyncOptions, type ValidationError, type ValidationErrorKind, type ValidationErrorLevel, XMLID_ATTRIBUTE, clearWeblinkMatches, closestElementBySchema, createElement, extractFootnoteNumber, findAttributeDefinitionByName, findElementLinkedTo, findReferenceFieldByElement, findReferenceTypeSchemaByElement, findSchemaByCode, findSchemaByElement, getAdjacentElement, getAttributeName, getEffectiveChildElements, getElementLinks, getPossibleWeblinks, getReferenceFieldElements, getReferenceParts, getReferenceStructureIssueElements, getStore, isAttributeRestricted, isDeletedElement, isIgnoredAttribute, isIgnoredElement, isTrackChangesSchema, markPossibleWeblinks, queryAllElementsBySchema, queryElementBySchema, validateAttributes, validateConsecutiveFootnoteCues, validateConsecutiveFootnotes, validateElementAgainstSchema, validateElementToLinkTo, validateFootnoteNumber, validateHierarchy, validateLinkend, validateOlink, validatePossibleWeblinks, validatePossibleWeblinksSteps, validateReferenceStructure, validateXml, validateXmlAsync };