pro-editor-schema 0.0.1-alpha.2 → 0.0.1-alpha.3
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 +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +38 -3
- package/dist/index.mjs +38 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -33,14 +33,16 @@ declare namespace schema_types {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
declare const SCHEMAS: ReadonlyArray<Schema>;
|
|
36
|
+
declare const SCHEMA_MAP: Map<string, Schema>;
|
|
36
37
|
declare const schemas: {
|
|
37
38
|
[k: string]: Schema;
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
declare const schemas$1_SCHEMAS: typeof SCHEMAS;
|
|
42
|
+
declare const schemas$1_SCHEMA_MAP: typeof SCHEMA_MAP;
|
|
41
43
|
declare const schemas$1_schemas: typeof schemas;
|
|
42
44
|
declare namespace schemas$1 {
|
|
43
|
-
export { schemas$1_SCHEMAS as SCHEMAS, schemas$1_schemas as schemas };
|
|
45
|
+
export { schemas$1_SCHEMAS as SCHEMAS, schemas$1_SCHEMA_MAP as SCHEMA_MAP, schemas$1_schemas as schemas };
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
declare const ELEMENT_SCHEMAS: ReadonlyArray<Schema>;
|
|
@@ -96,13 +98,19 @@ declare namespace ignoredAttributes {
|
|
|
96
98
|
|
|
97
99
|
declare const isIgnoredAttribute: (attribute: string) => boolean;
|
|
98
100
|
declare const isIgnoredElement: (element: Element) => boolean;
|
|
99
|
-
declare const findSchemaByTag: (
|
|
101
|
+
declare const findSchemaByTag: (element: Element) => Schema | undefined;
|
|
102
|
+
declare const isAttributeRestricted: (attr: AttributeDefinition) => attr is RestrictedAttribute;
|
|
103
|
+
declare const getAttributeName: (attribute: AttributeDefinition) => string;
|
|
104
|
+
declare const findAttributeDefinitionByName: (definitions: readonly AttributeDefinition[], name: string) => AttributeDefinition | undefined;
|
|
100
105
|
|
|
106
|
+
declare const utils_findAttributeDefinitionByName: typeof findAttributeDefinitionByName;
|
|
101
107
|
declare const utils_findSchemaByTag: typeof findSchemaByTag;
|
|
108
|
+
declare const utils_getAttributeName: typeof getAttributeName;
|
|
109
|
+
declare const utils_isAttributeRestricted: typeof isAttributeRestricted;
|
|
102
110
|
declare const utils_isIgnoredAttribute: typeof isIgnoredAttribute;
|
|
103
111
|
declare const utils_isIgnoredElement: typeof isIgnoredElement;
|
|
104
112
|
declare namespace utils {
|
|
105
|
-
export { utils_findSchemaByTag as findSchemaByTag, utils_isIgnoredAttribute as isIgnoredAttribute, utils_isIgnoredElement as isIgnoredElement };
|
|
113
|
+
export { utils_findAttributeDefinitionByName as findAttributeDefinitionByName, utils_findSchemaByTag as findSchemaByTag, utils_getAttributeName as getAttributeName, utils_isAttributeRestricted as isAttributeRestricted, utils_isIgnoredAttribute as isIgnoredAttribute, utils_isIgnoredElement as isIgnoredElement };
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
declare const IGNORED_ELEMENT_SELECTORS: string[];
|
|
@@ -129,4 +137,4 @@ declare namespace globalAttributes {
|
|
|
129
137
|
export { globalAttributes_ID_ATTRS as ID_ATTRS, globalAttributes_TRACK_CHANGES_ATTRS as TRACK_CHANGES_ATTRS, globalAttributes_TRACK_CHANGES_ATTR_DATA_DATE as TRACK_CHANGES_ATTR_DATA_DATE, globalAttributes_TRACK_CHANGES_ATTR_DATA_TIME as TRACK_CHANGES_ATTR_DATA_TIME, globalAttributes_TRACK_CHANGES_ATTR_DATA_USERID as TRACK_CHANGES_ATTR_DATA_USERID, globalAttributes_TRACK_CHANGES_ATTR_DATA_USERNAME as TRACK_CHANGES_ATTR_DATA_USERNAME };
|
|
130
138
|
}
|
|
131
139
|
|
|
132
|
-
export { globalAttributes as GlobalAttributes,
|
|
140
|
+
export { globalAttributes as GlobalAttributes, ignoredAttributes as IgnoredAttributes, ignoredElements as IgnoredElements, schema_types as SchemaTypes, schemas$1 as Schemas, index as SchemasAtoms, index$3 as SchemasElements, index$2 as SchemasGroupElements, index$1 as SchemasInlineElements, utils as Utils };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,14 +33,16 @@ declare namespace schema_types {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
declare const SCHEMAS: ReadonlyArray<Schema>;
|
|
36
|
+
declare const SCHEMA_MAP: Map<string, Schema>;
|
|
36
37
|
declare const schemas: {
|
|
37
38
|
[k: string]: Schema;
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
declare const schemas$1_SCHEMAS: typeof SCHEMAS;
|
|
42
|
+
declare const schemas$1_SCHEMA_MAP: typeof SCHEMA_MAP;
|
|
41
43
|
declare const schemas$1_schemas: typeof schemas;
|
|
42
44
|
declare namespace schemas$1 {
|
|
43
|
-
export { schemas$1_SCHEMAS as SCHEMAS, schemas$1_schemas as schemas };
|
|
45
|
+
export { schemas$1_SCHEMAS as SCHEMAS, schemas$1_SCHEMA_MAP as SCHEMA_MAP, schemas$1_schemas as schemas };
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
declare const ELEMENT_SCHEMAS: ReadonlyArray<Schema>;
|
|
@@ -96,13 +98,19 @@ declare namespace ignoredAttributes {
|
|
|
96
98
|
|
|
97
99
|
declare const isIgnoredAttribute: (attribute: string) => boolean;
|
|
98
100
|
declare const isIgnoredElement: (element: Element) => boolean;
|
|
99
|
-
declare const findSchemaByTag: (
|
|
101
|
+
declare const findSchemaByTag: (element: Element) => Schema | undefined;
|
|
102
|
+
declare const isAttributeRestricted: (attr: AttributeDefinition) => attr is RestrictedAttribute;
|
|
103
|
+
declare const getAttributeName: (attribute: AttributeDefinition) => string;
|
|
104
|
+
declare const findAttributeDefinitionByName: (definitions: readonly AttributeDefinition[], name: string) => AttributeDefinition | undefined;
|
|
100
105
|
|
|
106
|
+
declare const utils_findAttributeDefinitionByName: typeof findAttributeDefinitionByName;
|
|
101
107
|
declare const utils_findSchemaByTag: typeof findSchemaByTag;
|
|
108
|
+
declare const utils_getAttributeName: typeof getAttributeName;
|
|
109
|
+
declare const utils_isAttributeRestricted: typeof isAttributeRestricted;
|
|
102
110
|
declare const utils_isIgnoredAttribute: typeof isIgnoredAttribute;
|
|
103
111
|
declare const utils_isIgnoredElement: typeof isIgnoredElement;
|
|
104
112
|
declare namespace utils {
|
|
105
|
-
export { utils_findSchemaByTag as findSchemaByTag, utils_isIgnoredAttribute as isIgnoredAttribute, utils_isIgnoredElement as isIgnoredElement };
|
|
113
|
+
export { utils_findAttributeDefinitionByName as findAttributeDefinitionByName, utils_findSchemaByTag as findSchemaByTag, utils_getAttributeName as getAttributeName, utils_isAttributeRestricted as isAttributeRestricted, utils_isIgnoredAttribute as isIgnoredAttribute, utils_isIgnoredElement as isIgnoredElement };
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
declare const IGNORED_ELEMENT_SELECTORS: string[];
|
|
@@ -129,4 +137,4 @@ declare namespace globalAttributes {
|
|
|
129
137
|
export { globalAttributes_ID_ATTRS as ID_ATTRS, globalAttributes_TRACK_CHANGES_ATTRS as TRACK_CHANGES_ATTRS, globalAttributes_TRACK_CHANGES_ATTR_DATA_DATE as TRACK_CHANGES_ATTR_DATA_DATE, globalAttributes_TRACK_CHANGES_ATTR_DATA_TIME as TRACK_CHANGES_ATTR_DATA_TIME, globalAttributes_TRACK_CHANGES_ATTR_DATA_USERID as TRACK_CHANGES_ATTR_DATA_USERID, globalAttributes_TRACK_CHANGES_ATTR_DATA_USERNAME as TRACK_CHANGES_ATTR_DATA_USERNAME };
|
|
130
138
|
}
|
|
131
139
|
|
|
132
|
-
export { globalAttributes as GlobalAttributes,
|
|
140
|
+
export { globalAttributes as GlobalAttributes, ignoredAttributes as IgnoredAttributes, ignoredElements as IgnoredElements, schema_types as SchemaTypes, schemas$1 as Schemas, index as SchemasAtoms, index$3 as SchemasElements, index$2 as SchemasGroupElements, index$1 as SchemasInlineElements, utils as Utils };
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
GlobalAttributes: () => globalAttributes_exports,
|
|
24
|
-
GlobalAttributesTypes: () => globalAttributes_exports,
|
|
25
24
|
IgnoredAttributes: () => ignoredAttributes_exports,
|
|
26
25
|
IgnoredElements: () => ignoredElements_exports,
|
|
27
26
|
SchemaTypes: () => schema_types_exports,
|
|
@@ -38,6 +37,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
37
|
var schemas_exports = {};
|
|
39
38
|
__export(schemas_exports, {
|
|
40
39
|
SCHEMAS: () => SCHEMAS,
|
|
40
|
+
SCHEMA_MAP: () => SCHEMA_MAP,
|
|
41
41
|
schemas: () => schemas
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -504,6 +504,9 @@ var SCHEMAS = [
|
|
|
504
504
|
...GROUP_ELEMENT_SCHEMAS,
|
|
505
505
|
...INLINE_ELEMENT_SCHEMAS
|
|
506
506
|
];
|
|
507
|
+
var SCHEMA_MAP = new Map(
|
|
508
|
+
SCHEMAS.map((schema) => [schema.tag, schema])
|
|
509
|
+
);
|
|
507
510
|
var schemas = Object.fromEntries(
|
|
508
511
|
SCHEMAS.map((schema) => [schema.tag, schema])
|
|
509
512
|
);
|
|
@@ -532,7 +535,10 @@ var IGNORED_ATTRIBUTES = [
|
|
|
532
535
|
// src/schema/shared/utils.ts
|
|
533
536
|
var utils_exports = {};
|
|
534
537
|
__export(utils_exports, {
|
|
538
|
+
findAttributeDefinitionByName: () => findAttributeDefinitionByName,
|
|
535
539
|
findSchemaByTag: () => findSchemaByTag,
|
|
540
|
+
getAttributeName: () => getAttributeName,
|
|
541
|
+
isAttributeRestricted: () => isAttributeRestricted,
|
|
536
542
|
isIgnoredAttribute: () => isIgnoredAttribute,
|
|
537
543
|
isIgnoredElement: () => isIgnoredElement
|
|
538
544
|
});
|
|
@@ -553,11 +559,40 @@ var IGNORED_ELEMENT_SELECTORS = [
|
|
|
553
559
|
// src/schema/shared/utils.ts
|
|
554
560
|
var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute);
|
|
555
561
|
var isIgnoredElement = (element) => IGNORED_ELEMENT_SELECTORS.some((selector) => element.matches(selector));
|
|
556
|
-
var findSchemaByTag = (
|
|
562
|
+
var findSchemaByTag = (element) => {
|
|
563
|
+
const isInsertion = element.classList.contains("ins");
|
|
564
|
+
const isDeletion = element.classList.contains("del");
|
|
565
|
+
const isQueryComment = element.classList.contains("cmtQurySection");
|
|
566
|
+
const isHeading = element.getAttribute("role")?.startsWith("H");
|
|
567
|
+
if (isHeading) {
|
|
568
|
+
return SCHEMA_MAP.get(element.tagName.toUpperCase() + "HEADING" /* HEADING */);
|
|
569
|
+
}
|
|
570
|
+
if (isInsertion) {
|
|
571
|
+
return SCHEMA_MAP.get(element.tagName.toUpperCase() + "INS" /* INS */);
|
|
572
|
+
}
|
|
573
|
+
if (isDeletion) {
|
|
574
|
+
return SCHEMA_MAP.get(element.tagName.toUpperCase() + "DEL" /* DEL */);
|
|
575
|
+
}
|
|
576
|
+
if (isQueryComment) {
|
|
577
|
+
return SCHEMA_MAP.get(
|
|
578
|
+
element.tagName.toUpperCase() + "QUERYCOMMENTSWRAPPER" /* QUERYCOMMENTSWRAPPER */
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
return SCHEMA_MAP.get(element.tagName.toUpperCase());
|
|
582
|
+
};
|
|
583
|
+
var isAttributeRestricted = (attr) => typeof attr !== "string";
|
|
584
|
+
var getAttributeName = (attribute) => typeof attribute === "string" ? attribute : attribute.name;
|
|
585
|
+
var findAttributeDefinitionByName = (definitions, name) => {
|
|
586
|
+
for (const def of definitions) {
|
|
587
|
+
if (getAttributeName(def) === name) {
|
|
588
|
+
return def;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return void 0;
|
|
592
|
+
};
|
|
557
593
|
// Annotate the CommonJS export names for ESM import in node:
|
|
558
594
|
0 && (module.exports = {
|
|
559
595
|
GlobalAttributes,
|
|
560
|
-
GlobalAttributesTypes,
|
|
561
596
|
IgnoredAttributes,
|
|
562
597
|
IgnoredElements,
|
|
563
598
|
SchemaTypes,
|
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
var schemas_exports = {};
|
|
9
9
|
__export(schemas_exports, {
|
|
10
10
|
SCHEMAS: () => SCHEMAS,
|
|
11
|
+
SCHEMA_MAP: () => SCHEMA_MAP,
|
|
11
12
|
schemas: () => schemas
|
|
12
13
|
});
|
|
13
14
|
|
|
@@ -474,6 +475,9 @@ var SCHEMAS = [
|
|
|
474
475
|
...GROUP_ELEMENT_SCHEMAS,
|
|
475
476
|
...INLINE_ELEMENT_SCHEMAS
|
|
476
477
|
];
|
|
478
|
+
var SCHEMA_MAP = new Map(
|
|
479
|
+
SCHEMAS.map((schema) => [schema.tag, schema])
|
|
480
|
+
);
|
|
477
481
|
var schemas = Object.fromEntries(
|
|
478
482
|
SCHEMAS.map((schema) => [schema.tag, schema])
|
|
479
483
|
);
|
|
@@ -502,7 +506,10 @@ var IGNORED_ATTRIBUTES = [
|
|
|
502
506
|
// src/schema/shared/utils.ts
|
|
503
507
|
var utils_exports = {};
|
|
504
508
|
__export(utils_exports, {
|
|
509
|
+
findAttributeDefinitionByName: () => findAttributeDefinitionByName,
|
|
505
510
|
findSchemaByTag: () => findSchemaByTag,
|
|
511
|
+
getAttributeName: () => getAttributeName,
|
|
512
|
+
isAttributeRestricted: () => isAttributeRestricted,
|
|
506
513
|
isIgnoredAttribute: () => isIgnoredAttribute,
|
|
507
514
|
isIgnoredElement: () => isIgnoredElement
|
|
508
515
|
});
|
|
@@ -523,10 +530,39 @@ var IGNORED_ELEMENT_SELECTORS = [
|
|
|
523
530
|
// src/schema/shared/utils.ts
|
|
524
531
|
var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute);
|
|
525
532
|
var isIgnoredElement = (element) => IGNORED_ELEMENT_SELECTORS.some((selector) => element.matches(selector));
|
|
526
|
-
var findSchemaByTag = (
|
|
533
|
+
var findSchemaByTag = (element) => {
|
|
534
|
+
const isInsertion = element.classList.contains("ins");
|
|
535
|
+
const isDeletion = element.classList.contains("del");
|
|
536
|
+
const isQueryComment = element.classList.contains("cmtQurySection");
|
|
537
|
+
const isHeading = element.getAttribute("role")?.startsWith("H");
|
|
538
|
+
if (isHeading) {
|
|
539
|
+
return SCHEMA_MAP.get(element.tagName.toUpperCase() + "HEADING" /* HEADING */);
|
|
540
|
+
}
|
|
541
|
+
if (isInsertion) {
|
|
542
|
+
return SCHEMA_MAP.get(element.tagName.toUpperCase() + "INS" /* INS */);
|
|
543
|
+
}
|
|
544
|
+
if (isDeletion) {
|
|
545
|
+
return SCHEMA_MAP.get(element.tagName.toUpperCase() + "DEL" /* DEL */);
|
|
546
|
+
}
|
|
547
|
+
if (isQueryComment) {
|
|
548
|
+
return SCHEMA_MAP.get(
|
|
549
|
+
element.tagName.toUpperCase() + "QUERYCOMMENTSWRAPPER" /* QUERYCOMMENTSWRAPPER */
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
return SCHEMA_MAP.get(element.tagName.toUpperCase());
|
|
553
|
+
};
|
|
554
|
+
var isAttributeRestricted = (attr) => typeof attr !== "string";
|
|
555
|
+
var getAttributeName = (attribute) => typeof attribute === "string" ? attribute : attribute.name;
|
|
556
|
+
var findAttributeDefinitionByName = (definitions, name) => {
|
|
557
|
+
for (const def of definitions) {
|
|
558
|
+
if (getAttributeName(def) === name) {
|
|
559
|
+
return def;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return void 0;
|
|
563
|
+
};
|
|
527
564
|
export {
|
|
528
565
|
globalAttributes_exports as GlobalAttributes,
|
|
529
|
-
globalAttributes_exports as GlobalAttributesTypes,
|
|
530
566
|
ignoredAttributes_exports as IgnoredAttributes,
|
|
531
567
|
ignoredElements_exports as IgnoredElements,
|
|
532
568
|
schema_types_exports as SchemaTypes,
|