pro-editor-schema 0.0.1-alpha.7 → 0.0.1-alpha.9

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,8 @@ declare const SCHEMA_MAP: Map<string, Schema>;
26
26
 
27
27
  declare const isIgnoredAttribute: (attribute: string) => boolean;
28
28
  declare const isIgnoredElement: (element: Element) => boolean;
29
- declare const findSchemaByTag: (element: Element) => Schema | undefined;
29
+ declare const findSchemaByTag: (tagName: string, role?: string) => Schema | undefined;
30
+ declare const findSchemaByElement: (element: Element) => Schema | undefined;
30
31
  declare const isAttributeRestricted: (attr: AttributeDefinition) => attr is RestrictedAttribute;
31
32
  declare const getAttributeName: (attribute: AttributeDefinition) => string;
32
33
  declare const findAttributeDefinitionByName: (definitions: readonly AttributeDefinition[], name: string) => AttributeDefinition | undefined;
@@ -34,6 +35,7 @@ declare const findAttributeDefinitionByName: (definitions: readonly AttributeDef
34
35
  declare const IGNORED_ELEMENT_SELECTORS: string[];
35
36
 
36
37
  declare const IGNORED_ATTRIBUTES: string[];
38
+ declare const IGNORED_ATTRIBUTES_STARTS_WITH: string[];
37
39
 
38
40
  declare const TRACK_CHANGES_ATTR_DATA_USERNAME = "data-username";
39
41
  declare const TRACK_CHANGES_ATTR_DATA_USERID = "data-userid";
@@ -76,4 +78,4 @@ declare const INLINE_ELEMENT_SCHEMAS: ReadonlyArray<Schema>;
76
78
 
77
79
  declare const ATOM_SCHEMAS: ReadonlyArray<Schema>;
78
80
 
79
- export { ATOM_SCHEMAS, type AttributeDefinition, ELEMENT_ROLE, ELEMENT_SCHEMAS, type FreeAttribute, GROUP_ELEMENT_SCHEMAS, ID_ATTRS, IGNORED_ATTRIBUTES, IGNORED_ELEMENT_SELECTORS, INLINE_ELEMENT_SCHEMAS, PARA_SCHEMA, type RestrictedAttribute, SCHEMAS, SCHEMA_MAP, SECTION_SCHEMA, type Schema, type SchemaKind, TITLE_SCHEMA, TRACK_CHANGES_ATTRS, TRACK_CHANGES_ATTR_DATA_DATE, TRACK_CHANGES_ATTR_DATA_TIME, TRACK_CHANGES_ATTR_DATA_USERID, TRACK_CHANGES_ATTR_DATA_USERNAME, createElement, findAttributeDefinitionByName, findSchemaByTag, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement };
81
+ export { ATOM_SCHEMAS, type AttributeDefinition, ELEMENT_ROLE, ELEMENT_SCHEMAS, type FreeAttribute, GROUP_ELEMENT_SCHEMAS, ID_ATTRS, IGNORED_ATTRIBUTES, IGNORED_ATTRIBUTES_STARTS_WITH, IGNORED_ELEMENT_SELECTORS, INLINE_ELEMENT_SCHEMAS, PARA_SCHEMA, type RestrictedAttribute, SCHEMAS, SCHEMA_MAP, SECTION_SCHEMA, type Schema, type SchemaKind, TITLE_SCHEMA, TRACK_CHANGES_ATTRS, TRACK_CHANGES_ATTR_DATA_DATE, TRACK_CHANGES_ATTR_DATA_TIME, TRACK_CHANGES_ATTR_DATA_USERID, TRACK_CHANGES_ATTR_DATA_USERNAME, createElement, findAttributeDefinitionByName, findSchemaByElement, findSchemaByTag, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement };
package/dist/index.d.ts CHANGED
@@ -26,7 +26,8 @@ declare const SCHEMA_MAP: Map<string, Schema>;
26
26
 
27
27
  declare const isIgnoredAttribute: (attribute: string) => boolean;
28
28
  declare const isIgnoredElement: (element: Element) => boolean;
29
- declare const findSchemaByTag: (element: Element) => Schema | undefined;
29
+ declare const findSchemaByTag: (tagName: string, role?: string) => Schema | undefined;
30
+ declare const findSchemaByElement: (element: Element) => Schema | undefined;
30
31
  declare const isAttributeRestricted: (attr: AttributeDefinition) => attr is RestrictedAttribute;
31
32
  declare const getAttributeName: (attribute: AttributeDefinition) => string;
32
33
  declare const findAttributeDefinitionByName: (definitions: readonly AttributeDefinition[], name: string) => AttributeDefinition | undefined;
@@ -34,6 +35,7 @@ declare const findAttributeDefinitionByName: (definitions: readonly AttributeDef
34
35
  declare const IGNORED_ELEMENT_SELECTORS: string[];
35
36
 
36
37
  declare const IGNORED_ATTRIBUTES: string[];
38
+ declare const IGNORED_ATTRIBUTES_STARTS_WITH: string[];
37
39
 
38
40
  declare const TRACK_CHANGES_ATTR_DATA_USERNAME = "data-username";
39
41
  declare const TRACK_CHANGES_ATTR_DATA_USERID = "data-userid";
@@ -76,4 +78,4 @@ declare const INLINE_ELEMENT_SCHEMAS: ReadonlyArray<Schema>;
76
78
 
77
79
  declare const ATOM_SCHEMAS: ReadonlyArray<Schema>;
78
80
 
79
- export { ATOM_SCHEMAS, type AttributeDefinition, ELEMENT_ROLE, ELEMENT_SCHEMAS, type FreeAttribute, GROUP_ELEMENT_SCHEMAS, ID_ATTRS, IGNORED_ATTRIBUTES, IGNORED_ELEMENT_SELECTORS, INLINE_ELEMENT_SCHEMAS, PARA_SCHEMA, type RestrictedAttribute, SCHEMAS, SCHEMA_MAP, SECTION_SCHEMA, type Schema, type SchemaKind, TITLE_SCHEMA, TRACK_CHANGES_ATTRS, TRACK_CHANGES_ATTR_DATA_DATE, TRACK_CHANGES_ATTR_DATA_TIME, TRACK_CHANGES_ATTR_DATA_USERID, TRACK_CHANGES_ATTR_DATA_USERNAME, createElement, findAttributeDefinitionByName, findSchemaByTag, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement };
81
+ export { ATOM_SCHEMAS, type AttributeDefinition, ELEMENT_ROLE, ELEMENT_SCHEMAS, type FreeAttribute, GROUP_ELEMENT_SCHEMAS, ID_ATTRS, IGNORED_ATTRIBUTES, IGNORED_ATTRIBUTES_STARTS_WITH, IGNORED_ELEMENT_SELECTORS, INLINE_ELEMENT_SCHEMAS, PARA_SCHEMA, type RestrictedAttribute, SCHEMAS, SCHEMA_MAP, SECTION_SCHEMA, type Schema, type SchemaKind, TITLE_SCHEMA, TRACK_CHANGES_ATTRS, TRACK_CHANGES_ATTR_DATA_DATE, TRACK_CHANGES_ATTR_DATA_TIME, TRACK_CHANGES_ATTR_DATA_USERID, TRACK_CHANGES_ATTR_DATA_USERNAME, createElement, findAttributeDefinitionByName, findSchemaByElement, findSchemaByTag, getAttributeName, isAttributeRestricted, isIgnoredAttribute, isIgnoredElement };
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ __export(index_exports, {
26
26
  GROUP_ELEMENT_SCHEMAS: () => GROUP_ELEMENT_SCHEMAS,
27
27
  ID_ATTRS: () => ID_ATTRS,
28
28
  IGNORED_ATTRIBUTES: () => IGNORED_ATTRIBUTES,
29
+ IGNORED_ATTRIBUTES_STARTS_WITH: () => IGNORED_ATTRIBUTES_STARTS_WITH,
29
30
  IGNORED_ELEMENT_SELECTORS: () => IGNORED_ELEMENT_SELECTORS,
30
31
  INLINE_ELEMENT_SCHEMAS: () => INLINE_ELEMENT_SCHEMAS,
31
32
  PARA_SCHEMA: () => PARA_SCHEMA,
@@ -40,6 +41,7 @@ __export(index_exports, {
40
41
  TRACK_CHANGES_ATTR_DATA_USERNAME: () => TRACK_CHANGES_ATTR_DATA_USERNAME,
41
42
  createElement: () => createElement,
42
43
  findAttributeDefinitionByName: () => findAttributeDefinitionByName,
44
+ findSchemaByElement: () => findSchemaByElement,
43
45
  findSchemaByTag: () => findSchemaByTag,
44
46
  getAttributeName: () => getAttributeName,
45
47
  isAttributeRestricted: () => isAttributeRestricted,
@@ -459,7 +461,10 @@ var SCHEMAS = [
459
461
  ...INLINE_ELEMENT_SCHEMAS
460
462
  ];
461
463
  var SCHEMA_MAP = new Map(
462
- SCHEMAS.map((schema) => [schema.tag + schema.role, schema])
464
+ SCHEMAS.map((schema) => [
465
+ schema.tag.toUpperCase() + (schema.role?.toUpperCase() ?? ""),
466
+ schema
467
+ ])
463
468
  );
464
469
 
465
470
  // src/schema/shared/ignoredElements.ts
@@ -487,11 +492,20 @@ var IGNORED_ATTRIBUTES = [
487
492
  "dir",
488
493
  "hidden"
489
494
  ];
495
+ var IGNORED_ATTRIBUTES_STARTS_WITH = ["er-"];
490
496
 
491
497
  // src/schema/shared/utils.ts
492
- var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute);
498
+ var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute) || IGNORED_ATTRIBUTES_STARTS_WITH.some(
499
+ (startsWith) => attribute.startsWith(startsWith)
500
+ );
493
501
  var isIgnoredElement = (element) => IGNORED_ELEMENT_SELECTORS.some((selector) => element.matches(selector));
494
- var findSchemaByTag = (element) => {
502
+ var findSchemaByTag = (tagName, role) => {
503
+ if (role) {
504
+ return SCHEMA_MAP.get(tagName.toUpperCase() + role);
505
+ }
506
+ return SCHEMA_MAP.get(tagName.toUpperCase());
507
+ };
508
+ var findSchemaByElement = (element) => {
495
509
  const isInsertion = element.classList.contains("ins");
496
510
  const isDeletion = element.classList.contains("del");
497
511
  const isQueryComment = element.classList.contains("cmtQurySection");
@@ -545,6 +559,7 @@ var createElement = ({
545
559
  GROUP_ELEMENT_SCHEMAS,
546
560
  ID_ATTRS,
547
561
  IGNORED_ATTRIBUTES,
562
+ IGNORED_ATTRIBUTES_STARTS_WITH,
548
563
  IGNORED_ELEMENT_SELECTORS,
549
564
  INLINE_ELEMENT_SCHEMAS,
550
565
  PARA_SCHEMA,
@@ -559,6 +574,7 @@ var createElement = ({
559
574
  TRACK_CHANGES_ATTR_DATA_USERNAME,
560
575
  createElement,
561
576
  findAttributeDefinitionByName,
577
+ findSchemaByElement,
562
578
  findSchemaByTag,
563
579
  getAttributeName,
564
580
  isAttributeRestricted,
package/dist/index.mjs CHANGED
@@ -409,7 +409,10 @@ var SCHEMAS = [
409
409
  ...INLINE_ELEMENT_SCHEMAS
410
410
  ];
411
411
  var SCHEMA_MAP = new Map(
412
- SCHEMAS.map((schema) => [schema.tag + schema.role, schema])
412
+ SCHEMAS.map((schema) => [
413
+ schema.tag.toUpperCase() + (schema.role?.toUpperCase() ?? ""),
414
+ schema
415
+ ])
413
416
  );
414
417
 
415
418
  // src/schema/shared/ignoredElements.ts
@@ -437,11 +440,20 @@ var IGNORED_ATTRIBUTES = [
437
440
  "dir",
438
441
  "hidden"
439
442
  ];
443
+ var IGNORED_ATTRIBUTES_STARTS_WITH = ["er-"];
440
444
 
441
445
  // src/schema/shared/utils.ts
442
- var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute);
446
+ var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute) || IGNORED_ATTRIBUTES_STARTS_WITH.some(
447
+ (startsWith) => attribute.startsWith(startsWith)
448
+ );
443
449
  var isIgnoredElement = (element) => IGNORED_ELEMENT_SELECTORS.some((selector) => element.matches(selector));
444
- var findSchemaByTag = (element) => {
450
+ var findSchemaByTag = (tagName, role) => {
451
+ if (role) {
452
+ return SCHEMA_MAP.get(tagName.toUpperCase() + role);
453
+ }
454
+ return SCHEMA_MAP.get(tagName.toUpperCase());
455
+ };
456
+ var findSchemaByElement = (element) => {
445
457
  const isInsertion = element.classList.contains("ins");
446
458
  const isDeletion = element.classList.contains("del");
447
459
  const isQueryComment = element.classList.contains("cmtQurySection");
@@ -494,6 +506,7 @@ export {
494
506
  GROUP_ELEMENT_SCHEMAS,
495
507
  ID_ATTRS,
496
508
  IGNORED_ATTRIBUTES,
509
+ IGNORED_ATTRIBUTES_STARTS_WITH,
497
510
  IGNORED_ELEMENT_SELECTORS,
498
511
  INLINE_ELEMENT_SCHEMAS,
499
512
  PARA_SCHEMA,
@@ -508,6 +521,7 @@ export {
508
521
  TRACK_CHANGES_ATTR_DATA_USERNAME,
509
522
  createElement,
510
523
  findAttributeDefinitionByName,
524
+ findSchemaByElement,
511
525
  findSchemaByTag,
512
526
  getAttributeName,
513
527
  isAttributeRestricted,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.9",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",