@openleaf-editor/core 0.1.0-beta.1 → 0.1.0-beta.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.
Files changed (101) hide show
  1. package/README.md +115 -0
  2. package/dist/autolink.d.ts +12 -0
  3. package/dist/autolink.d.ts.map +1 -0
  4. package/dist/autolink.js +136 -0
  5. package/dist/autolink.js.map +1 -0
  6. package/dist/command-helpers.d.ts +8 -0
  7. package/dist/command-helpers.d.ts.map +1 -0
  8. package/dist/command-helpers.js +36 -0
  9. package/dist/command-helpers.js.map +1 -0
  10. package/dist/commands.d.ts +43 -22
  11. package/dist/commands.d.ts.map +1 -1
  12. package/dist/commands.js +513 -115
  13. package/dist/commands.js.map +1 -1
  14. package/dist/css.d.ts +1 -123
  15. package/dist/css.d.ts.map +1 -1
  16. package/dist/css.js +1 -214
  17. package/dist/css.js.map +1 -1
  18. package/dist/disclosure.d.ts +21 -0
  19. package/dist/disclosure.d.ts.map +1 -0
  20. package/dist/disclosure.js +144 -0
  21. package/dist/disclosure.js.map +1 -0
  22. package/dist/elements.d.ts +2 -0
  23. package/dist/elements.d.ts.map +1 -0
  24. package/dist/elements.js +2 -0
  25. package/dist/elements.js.map +1 -0
  26. package/dist/embed.d.ts +2 -0
  27. package/dist/embed.d.ts.map +1 -0
  28. package/dist/embed.js +2 -0
  29. package/dist/embed.js.map +1 -0
  30. package/dist/errors.d.ts +38 -0
  31. package/dist/errors.d.ts.map +1 -0
  32. package/dist/errors.js +40 -0
  33. package/dist/errors.js.map +1 -0
  34. package/dist/extensions.d.ts +46 -5
  35. package/dist/extensions.d.ts.map +1 -1
  36. package/dist/extensions.js +292 -65
  37. package/dist/extensions.js.map +1 -1
  38. package/dist/formats.d.ts +44 -0
  39. package/dist/formats.d.ts.map +1 -0
  40. package/dist/formats.js +123 -0
  41. package/dist/formats.js.map +1 -0
  42. package/dist/html.d.ts +32 -2
  43. package/dist/html.d.ts.map +1 -1
  44. package/dist/html.js +185 -31
  45. package/dist/html.js.map +1 -1
  46. package/dist/index.d.ts +27 -6
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +44 -10
  49. package/dist/index.js.map +1 -1
  50. package/dist/insert-commands.d.ts +172 -0
  51. package/dist/insert-commands.d.ts.map +1 -0
  52. package/dist/insert-commands.js +560 -0
  53. package/dist/insert-commands.js.map +1 -0
  54. package/dist/isolating-selection.d.ts +41 -0
  55. package/dist/isolating-selection.d.ts.map +1 -0
  56. package/dist/isolating-selection.js +162 -0
  57. package/dist/isolating-selection.js.map +1 -0
  58. package/dist/keymap.d.ts.map +1 -1
  59. package/dist/keymap.js +6 -3
  60. package/dist/keymap.js.map +1 -1
  61. package/dist/noneditable.d.ts +14 -0
  62. package/dist/noneditable.d.ts.map +1 -0
  63. package/dist/noneditable.js +107 -0
  64. package/dist/noneditable.js.map +1 -0
  65. package/dist/plugins.d.ts +20 -2
  66. package/dist/plugins.d.ts.map +1 -1
  67. package/dist/plugins.js +27 -2
  68. package/dist/plugins.js.map +1 -1
  69. package/dist/preserve.d.ts +76 -0
  70. package/dist/preserve.d.ts.map +1 -1
  71. package/dist/preserve.js +308 -58
  72. package/dist/preserve.js.map +1 -1
  73. package/dist/schema.d.ts +15 -0
  74. package/dist/schema.d.ts.map +1 -1
  75. package/dist/schema.js +356 -76
  76. package/dist/schema.js.map +1 -1
  77. package/dist/structure.d.ts +76 -0
  78. package/dist/structure.d.ts.map +1 -0
  79. package/dist/structure.js +422 -0
  80. package/dist/structure.js.map +1 -0
  81. package/dist/tables.d.ts +60 -1
  82. package/dist/tables.d.ts.map +1 -1
  83. package/dist/tables.js +617 -35
  84. package/dist/tables.js.map +1 -1
  85. package/dist/testing.d.ts +3 -0
  86. package/dist/testing.d.ts.map +1 -0
  87. package/dist/testing.js +3 -0
  88. package/dist/testing.js.map +1 -0
  89. package/dist/tokens.d.ts +36 -0
  90. package/dist/tokens.d.ts.map +1 -0
  91. package/dist/tokens.js +116 -0
  92. package/dist/tokens.js.map +1 -0
  93. package/dist/url.d.ts +1 -25
  94. package/dist/url.d.ts.map +1 -1
  95. package/dist/url.js +1 -77
  96. package/dist/url.js.map +1 -1
  97. package/dist/visual-aids.d.ts +20 -0
  98. package/dist/visual-aids.d.ts.map +1 -0
  99. package/dist/visual-aids.js +149 -0
  100. package/dist/visual-aids.js.map +1 -0
  101. package/package.json +16 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../src/elements.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from '@openleaf-editor/content-policy/elements';
2
+ //# sourceMappingURL=elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elements.js","sourceRoot":"","sources":["../src/elements.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from '@openleaf-editor/content-policy/embed';
2
+ //# sourceMappingURL=embed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA"}
package/dist/embed.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from '@openleaf-editor/content-policy/embed';
2
+ //# sourceMappingURL=embed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.js","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The one error type OpenLeaf throws on purpose.
3
+ *
4
+ * Before this there were four styles and no way to tell them apart: `parseHtml`
5
+ * coerced anything to an empty document, `serializeHtml(null)` surfaced a raw
6
+ * ProseMirror `TypeError` with nothing naming OpenLeaf in it, a bad
7
+ * `registerEditorPlugin` argument was accepted and failed much later through
8
+ * `console.error`, and a schema collision threw on some unrelated later call.
9
+ * A `catch` block could not distinguish "the integrator passed the wrong thing"
10
+ * from "the library has a bug", so integrators either swallowed everything or
11
+ * nothing.
12
+ *
13
+ * `code` is the stable part. Messages are for people and may be reworded; the
14
+ * code is what a `catch` should switch on.
15
+ */
16
+ export type OpenLeafErrorCode =
17
+ /** A public function was called with a value it cannot accept. */
18
+ 'invalid-argument'
19
+ /** Input nests deeper than the recursive DOM walks can survive. */
20
+ | 'depth-limit'
21
+ /** Two schema extensions define the same node or mark name. */
22
+ | 'schema-conflict'
23
+ /** No `Document` was available and none was supplied. */
24
+ | 'no-document';
25
+ export declare class OpenLeafError extends Error {
26
+ readonly code: OpenLeafErrorCode;
27
+ constructor(code: OpenLeafErrorCode, message: string, options?: ErrorOptions);
28
+ }
29
+ /**
30
+ * A duck check rather than `instanceof`.
31
+ *
32
+ * Two copies of `@openleaf-editor/core` on one page -- which the plugin bundles
33
+ * exist to prevent but a mis-pinned install still produces -- have two distinct
34
+ * `OpenLeafError` classes, and `instanceof` is false across them. The code is
35
+ * what callers actually branch on, so that is what this checks.
36
+ */
37
+ export declare function isOpenLeafError(value: unknown, code?: OpenLeafErrorCode): boolean;
38
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,iBAAiB;AAC3B,kEAAkE;AAChE,kBAAkB;AACpB,mEAAmE;GACjE,aAAa;AACf,+DAA+D;GAC7D,iBAAiB;AACnB,yDAAyD;GACvD,aAAa,CAAA;AAEjB,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;gBAEpB,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAQ7E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAGjF"}
package/dist/errors.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The one error type OpenLeaf throws on purpose.
3
+ *
4
+ * Before this there were four styles and no way to tell them apart: `parseHtml`
5
+ * coerced anything to an empty document, `serializeHtml(null)` surfaced a raw
6
+ * ProseMirror `TypeError` with nothing naming OpenLeaf in it, a bad
7
+ * `registerEditorPlugin` argument was accepted and failed much later through
8
+ * `console.error`, and a schema collision threw on some unrelated later call.
9
+ * A `catch` block could not distinguish "the integrator passed the wrong thing"
10
+ * from "the library has a bug", so integrators either swallowed everything or
11
+ * nothing.
12
+ *
13
+ * `code` is the stable part. Messages are for people and may be reworded; the
14
+ * code is what a `catch` should switch on.
15
+ */
16
+ export class OpenLeafError extends Error {
17
+ code;
18
+ constructor(code, message, options) {
19
+ super(message, options);
20
+ this.code = code;
21
+ // Set explicitly rather than via a class field: a field would be an own
22
+ // property on every instance, and `name` is conventionally read off the
23
+ // prototype chain by anything formatting an error.
24
+ this.name = 'OpenLeafError';
25
+ }
26
+ }
27
+ /**
28
+ * A duck check rather than `instanceof`.
29
+ *
30
+ * Two copies of `@openleaf-editor/core` on one page -- which the plugin bundles
31
+ * exist to prevent but a mis-pinned install still produces -- have two distinct
32
+ * `OpenLeafError` classes, and `instanceof` is false across them. The code is
33
+ * what callers actually branch on, so that is what this checks.
34
+ */
35
+ export function isOpenLeafError(value, code) {
36
+ if (!(value instanceof Error) || value.name !== 'OpenLeafError')
37
+ return false;
38
+ return code === undefined || value.code === code;
39
+ }
40
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,CAAmB;IAEhC,YAAY,IAAuB,EAAE,OAAe,EAAE,OAAsB;QAC1E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,wEAAwE;QACxE,wEAAwE;QACxE,mDAAmD;QACnD,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc,EAAE,IAAwB;IACtE,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe;QAAE,OAAO,KAAK,CAAA;IAC7E,OAAO,IAAI,KAAK,SAAS,IAAK,KAAuB,CAAC,IAAI,KAAK,IAAI,CAAA;AACrE,CAAC"}
@@ -51,15 +51,28 @@ export interface SchemaExtension {
51
51
  /**
52
52
  * Re-emit attributes the spec does not model. Defaults to true.
53
53
  *
54
- * Adding a node type strictly *reduces* fidelity for the tag it claims: before
55
- * the node existed, the preservation layer kept the element and every
56
- * attribute on it; afterwards the spec keeps only what it declares. A callout
57
- * node modelling `class` silently drops `id` and `data-analytics` that used to
58
- * survive.
54
+ * Adding a node or mark type strictly *reduces* fidelity for the tag it
55
+ * claims: before the type existed, the preservation layer kept the element
56
+ * and every attribute on it; afterwards the spec keeps only what it declares.
57
+ * A callout node modelling `class` silently drops `id` and `data-analytics`
58
+ * that used to survive, and a `strong` mark used to drop `class` the same way.
59
59
  *
60
60
  * So unmodelled attributes are captured on parse and merged back on
61
61
  * serialize, by default, at schema-build time -- which means an author cannot
62
62
  * opt out by forgetting.
63
+ *
64
+ * ## Setting this to `false` is security-relevant
65
+ *
66
+ * The capture is also where `on*` handlers and unsafe URL schemes are
67
+ * filtered out of the residue -- see `withCarriedAttributes` below. Turning
68
+ * the carry off skips the wrapper entirely, and with it that filter, so a
69
+ * spec's own `getAttrs` becomes the only thing standing between pasted
70
+ * `onclick` and the stored document.
71
+ *
72
+ * It exists for specs that already model every attribute they claim, where
73
+ * carrying would emit the same value twice. It is not a performance knob, and
74
+ * a plugin that sets it is making a decision `SECURITY.md` documents under
75
+ * "Plugin trust model". If you set it, your `getAttrs` owns the scrub.
63
76
  */
64
77
  readonly carryUnknownAttributes?: boolean;
65
78
  }
@@ -86,6 +99,34 @@ export declare function createSchema(list?: readonly SchemaExtension[]): Schema;
86
99
  * "bind to this" and would be captured at import by every consumer, which is
87
100
  * exactly what made the schema impossible to extend. Memoized, and invalidated
88
101
  * whenever the registry changes.
102
+ *
103
+ * ## Why the subscription is in here and not at module scope
104
+ *
105
+ * This package declares `"sideEffects": false`, which is a literal promise that
106
+ * evaluating a module for its own sake changes nothing observable. The bare
107
+ * top-level `onSchemaExtensionsChange(() => { cached = null })` that used to sit
108
+ * below this function broke that promise: it mutates the listener set in the
109
+ * registry above, which is observable by anything that calls `notify()`.
110
+ *
111
+ * What it did *not* do, measured rather than assumed, is actually get dropped.
112
+ * Both rollup 4 (`treeshake.moduleSideEffects: false`) and webpack 5
113
+ * (`optimization.sideEffects`) keep the statement, because the arrow function
114
+ * writes `cached` and `cached` is read by this function -- so the tree-shaker
115
+ * can see the statement contributes to a live export and retains it. A probe
116
+ * that warms the memo, registers an extension and re-reads the schema returns
117
+ * the plugin's node type under both bundlers, before and after this change.
118
+ *
119
+ * It is moved anyway, because the retention depended entirely on that linkage
120
+ * being visible. It is not a property of the invalidator; it is a property of
121
+ * this particular pair of statements, and it would quietly stop holding the
122
+ * moment the memo is refactored -- at which point the failure is silent and
123
+ * total, since `coreSchema()` would keep handing back a schema built before the
124
+ * first `registerSchemaExtension` call. Registering on the first call costs a
125
+ * boolean and makes the flag true instead of true-by-luck.
126
+ *
127
+ * There is no window in which the invalidator is missing: the subscription is
128
+ * installed before the value it guards ever exists, and nothing can reach the
129
+ * memo except through here.
89
130
  */
90
131
  export declare function coreSchema(): Schema;
91
132
  //# sourceMappingURL=extensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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