pro-editor-schema 0.0.1-alpha.0 → 0.0.1-alpha.1

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
@@ -1,5 +1,37 @@
1
- declare const schemas: {
2
- [k: string]: any;
1
+ declare enum ELEMENT_ROLE {
2
+ QUERYCOMMENTSWRAPPER = "QUERYCOMMENTSWRAPPER",
3
+ HEADING = "HEADING",
4
+ INS = "INS",
5
+ DEL = "DEL"
6
+ }
7
+ type SchemaKind = "element" | "atom" | "inline" | "group";
8
+ type FreeAttribute = string;
9
+ type RestrictedAttribute<T extends readonly string[] = readonly string[]> = {
10
+ name: string;
11
+ values: T;
12
+ defaultValue: string;
3
13
  };
14
+ type AttributeDefinition<T extends readonly string[] = readonly string[]> = FreeAttribute | RestrictedAttribute<T>;
15
+ type Schema<TRequiredAttributes extends readonly AttributeDefinition[] = readonly AttributeDefinition[], TOptionalAttributes extends readonly AttributeDefinition[] = readonly AttributeDefinition[]> = {
16
+ kind: SchemaKind;
17
+ tag: string;
18
+ role?: ELEMENT_ROLE;
19
+ requiredAttributes: TRequiredAttributes;
20
+ optionalAttributes: TOptionalAttributes;
21
+ allowedChildTagNames: ReadonlySet<string>;
22
+ };
23
+
24
+ declare const SCHEMAS: Schema[];
25
+
26
+ declare const IGNORED_ATTRIBUTES: string[];
27
+
28
+ declare const isIgnoredAttribute: (attribute: string) => boolean;
29
+ declare const isIgnoredElement: (element: Element) => boolean;
30
+ declare const findSchemaByTag: (element: Element) => Schema | undefined;
31
+
32
+ declare const IGNORED_ELEMENT_SELECTORS: string[];
33
+
34
+ declare const TRACK_CHANGES_ATTRS: readonly ["data-username", "data-userid", "data-time", "data-date"];
35
+ declare const ID_ATTRS: readonly ["store", "ele-id"];
4
36
 
5
- export { schemas };
37
+ export { ID_ATTRS, IGNORED_ATTRIBUTES, IGNORED_ELEMENT_SELECTORS, type Schema, TRACK_CHANGES_ATTRS, findSchemaByTag, isIgnoredAttribute, isIgnoredElement, SCHEMAS as schemas };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,37 @@
1
- declare const schemas: {
2
- [k: string]: any;
1
+ declare enum ELEMENT_ROLE {
2
+ QUERYCOMMENTSWRAPPER = "QUERYCOMMENTSWRAPPER",
3
+ HEADING = "HEADING",
4
+ INS = "INS",
5
+ DEL = "DEL"
6
+ }
7
+ type SchemaKind = "element" | "atom" | "inline" | "group";
8
+ type FreeAttribute = string;
9
+ type RestrictedAttribute<T extends readonly string[] = readonly string[]> = {
10
+ name: string;
11
+ values: T;
12
+ defaultValue: string;
3
13
  };
14
+ type AttributeDefinition<T extends readonly string[] = readonly string[]> = FreeAttribute | RestrictedAttribute<T>;
15
+ type Schema<TRequiredAttributes extends readonly AttributeDefinition[] = readonly AttributeDefinition[], TOptionalAttributes extends readonly AttributeDefinition[] = readonly AttributeDefinition[]> = {
16
+ kind: SchemaKind;
17
+ tag: string;
18
+ role?: ELEMENT_ROLE;
19
+ requiredAttributes: TRequiredAttributes;
20
+ optionalAttributes: TOptionalAttributes;
21
+ allowedChildTagNames: ReadonlySet<string>;
22
+ };
23
+
24
+ declare const SCHEMAS: Schema[];
25
+
26
+ declare const IGNORED_ATTRIBUTES: string[];
27
+
28
+ declare const isIgnoredAttribute: (attribute: string) => boolean;
29
+ declare const isIgnoredElement: (element: Element) => boolean;
30
+ declare const findSchemaByTag: (element: Element) => Schema | undefined;
31
+
32
+ declare const IGNORED_ELEMENT_SELECTORS: string[];
33
+
34
+ declare const TRACK_CHANGES_ATTRS: readonly ["data-username", "data-userid", "data-time", "data-date"];
35
+ declare const ID_ATTRS: readonly ["store", "ele-id"];
4
36
 
5
- export { schemas };
37
+ export { ID_ATTRS, IGNORED_ATTRIBUTES, IGNORED_ELEMENT_SELECTORS, type Schema, TRACK_CHANGES_ATTRS, findSchemaByTag, isIgnoredAttribute, isIgnoredElement, SCHEMAS as schemas };
package/dist/index.js CHANGED
@@ -20,7 +20,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- schemas: () => schemas
23
+ ID_ATTRS: () => ID_ATTRS,
24
+ IGNORED_ATTRIBUTES: () => IGNORED_ATTRIBUTES,
25
+ IGNORED_ELEMENT_SELECTORS: () => IGNORED_ELEMENT_SELECTORS,
26
+ TRACK_CHANGES_ATTRS: () => TRACK_CHANGES_ATTRS,
27
+ findSchemaByTag: () => findSchemaByTag,
28
+ isIgnoredAttribute: () => isIgnoredAttribute,
29
+ isIgnoredElement: () => isIgnoredElement,
30
+ schemas: () => SCHEMAS
24
31
  });
25
32
  module.exports = __toCommonJS(index_exports);
26
33
 
@@ -426,15 +433,44 @@ var SCHEMAS = [
426
433
  ...INLINE_ELEMENT_SCHEMAS
427
434
  ];
428
435
 
429
- // src/index.ts
430
- var replacer = (_key, value) => value instanceof Set ? { __type: "Set", values: [...value] } : value;
431
- var schemas = Object.fromEntries(
432
- SCHEMAS.map((schema) => [
433
- schema.tag,
434
- JSON.parse(JSON.stringify(schema, replacer))
435
- ])
436
- );
436
+ // src/schema/shared/ignoredAttributes.ts
437
+ var IGNORED_ATTRIBUTES = [
438
+ // Styling & layout
439
+ "class",
440
+ "style",
441
+ // Editor state
442
+ "contenteditable",
443
+ "draggable",
444
+ "tabindex",
445
+ // Browser behaviour
446
+ "spellcheck",
447
+ "translate",
448
+ "lang",
449
+ "dir",
450
+ "hidden"
451
+ ];
452
+
453
+ // src/schema/shared/ignoredElements.ts
454
+ var IGNORED_ELEMENT_SELECTORS = [
455
+ "span.rhlabel",
456
+ "span.abstractlabel",
457
+ "span.refIcon",
458
+ "span.missLink",
459
+ "span.ref-drag"
460
+ ];
461
+
462
+ // src/schema/shared/utils.ts
463
+ var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute);
464
+ var isIgnoredElement = (element) => IGNORED_ELEMENT_SELECTORS.some((selector) => element.matches(selector));
465
+ var findSchemaByTag = (element) => SCHEMAS.find((schema) => schema.tag === element.tagName.toLowerCase());
437
466
  // Annotate the CommonJS export names for ESM import in node:
438
467
  0 && (module.exports = {
468
+ ID_ATTRS,
469
+ IGNORED_ATTRIBUTES,
470
+ IGNORED_ELEMENT_SELECTORS,
471
+ TRACK_CHANGES_ATTRS,
472
+ findSchemaByTag,
473
+ isIgnoredAttribute,
474
+ isIgnoredElement,
439
475
  schemas
440
476
  });
package/dist/index.mjs CHANGED
@@ -400,14 +400,43 @@ var SCHEMAS = [
400
400
  ...INLINE_ELEMENT_SCHEMAS
401
401
  ];
402
402
 
403
- // src/index.ts
404
- var replacer = (_key, value) => value instanceof Set ? { __type: "Set", values: [...value] } : value;
405
- var schemas = Object.fromEntries(
406
- SCHEMAS.map((schema) => [
407
- schema.tag,
408
- JSON.parse(JSON.stringify(schema, replacer))
409
- ])
410
- );
403
+ // src/schema/shared/ignoredAttributes.ts
404
+ var IGNORED_ATTRIBUTES = [
405
+ // Styling & layout
406
+ "class",
407
+ "style",
408
+ // Editor state
409
+ "contenteditable",
410
+ "draggable",
411
+ "tabindex",
412
+ // Browser behaviour
413
+ "spellcheck",
414
+ "translate",
415
+ "lang",
416
+ "dir",
417
+ "hidden"
418
+ ];
419
+
420
+ // src/schema/shared/ignoredElements.ts
421
+ var IGNORED_ELEMENT_SELECTORS = [
422
+ "span.rhlabel",
423
+ "span.abstractlabel",
424
+ "span.refIcon",
425
+ "span.missLink",
426
+ "span.ref-drag"
427
+ ];
428
+
429
+ // src/schema/shared/utils.ts
430
+ var isIgnoredAttribute = (attribute) => IGNORED_ATTRIBUTES.includes(attribute);
431
+ var isIgnoredElement = (element) => IGNORED_ELEMENT_SELECTORS.some((selector) => element.matches(selector));
432
+ var findSchemaByTag = (element) => SCHEMAS.find((schema) => schema.tag === element.tagName.toLowerCase());
411
433
  export {
412
- schemas
434
+ ID_ATTRS,
435
+ IGNORED_ATTRIBUTES,
436
+ IGNORED_ELEMENT_SELECTORS,
437
+ TRACK_CHANGES_ATTRS,
438
+ findSchemaByTag,
439
+ isIgnoredAttribute,
440
+ isIgnoredElement,
441
+ SCHEMAS as schemas
413
442
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "0.0.1-alpha.0",
3
+ "version": "0.0.1-alpha.1",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",