@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.
- package/README.md +115 -0
- package/dist/autolink.d.ts +12 -0
- package/dist/autolink.d.ts.map +1 -0
- package/dist/autolink.js +136 -0
- package/dist/autolink.js.map +1 -0
- package/dist/command-helpers.d.ts +8 -0
- package/dist/command-helpers.d.ts.map +1 -0
- package/dist/command-helpers.js +36 -0
- package/dist/command-helpers.js.map +1 -0
- package/dist/commands.d.ts +43 -22
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +513 -115
- package/dist/commands.js.map +1 -1
- package/dist/css.d.ts +1 -123
- package/dist/css.d.ts.map +1 -1
- package/dist/css.js +1 -214
- package/dist/css.js.map +1 -1
- package/dist/disclosure.d.ts +21 -0
- package/dist/disclosure.d.ts.map +1 -0
- package/dist/disclosure.js +144 -0
- package/dist/disclosure.js.map +1 -0
- package/dist/elements.d.ts +2 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +2 -0
- package/dist/elements.js.map +1 -0
- package/dist/embed.d.ts +2 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +2 -0
- package/dist/embed.js.map +1 -0
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +40 -0
- package/dist/errors.js.map +1 -0
- package/dist/extensions.d.ts +46 -5
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +292 -65
- package/dist/extensions.js.map +1 -1
- package/dist/formats.d.ts +44 -0
- package/dist/formats.d.ts.map +1 -0
- package/dist/formats.js +123 -0
- package/dist/formats.js.map +1 -0
- package/dist/html.d.ts +32 -2
- package/dist/html.d.ts.map +1 -1
- package/dist/html.js +185 -31
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +27 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -10
- package/dist/index.js.map +1 -1
- package/dist/insert-commands.d.ts +172 -0
- package/dist/insert-commands.d.ts.map +1 -0
- package/dist/insert-commands.js +560 -0
- package/dist/insert-commands.js.map +1 -0
- package/dist/isolating-selection.d.ts +41 -0
- package/dist/isolating-selection.d.ts.map +1 -0
- package/dist/isolating-selection.js +162 -0
- package/dist/isolating-selection.js.map +1 -0
- package/dist/keymap.d.ts.map +1 -1
- package/dist/keymap.js +6 -3
- package/dist/keymap.js.map +1 -1
- package/dist/noneditable.d.ts +14 -0
- package/dist/noneditable.d.ts.map +1 -0
- package/dist/noneditable.js +107 -0
- package/dist/noneditable.js.map +1 -0
- package/dist/plugins.d.ts +20 -2
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +27 -2
- package/dist/plugins.js.map +1 -1
- package/dist/preserve.d.ts +76 -0
- package/dist/preserve.d.ts.map +1 -1
- package/dist/preserve.js +308 -58
- package/dist/preserve.js.map +1 -1
- package/dist/schema.d.ts +15 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +356 -76
- package/dist/schema.js.map +1 -1
- package/dist/structure.d.ts +76 -0
- package/dist/structure.d.ts.map +1 -0
- package/dist/structure.js +422 -0
- package/dist/structure.js.map +1 -0
- package/dist/tables.d.ts +60 -1
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +617 -35
- package/dist/tables.js.map +1 -1
- package/dist/testing.d.ts +3 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +3 -0
- package/dist/testing.js.map +1 -0
- package/dist/tokens.d.ts +36 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +116 -0
- package/dist/tokens.js.map +1 -0
- package/dist/url.d.ts +1 -25
- package/dist/url.d.ts.map +1 -1
- package/dist/url.js +1 -77
- package/dist/url.js.map +1 -1
- package/dist/visual-aids.d.ts +20 -0
- package/dist/visual-aids.d.ts.map +1 -0
- package/dist/visual-aids.js +149 -0
- package/dist/visual-aids.js.map +1 -0
- 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"}
|
package/dist/elements.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../src/elements.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAA"}
|
package/dist/embed.d.ts
ADDED
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"embed.js","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA"}
|
package/dist/errors.d.ts
ADDED
|
@@ -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"}
|
package/dist/extensions.d.ts
CHANGED
|
@@ -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
|
|
55
|
-
* the
|
|
56
|
-
* attribute on it; afterwards the spec keeps only what it declares.
|
|
57
|
-
* node modelling `class` silently drops `id` and `data-analytics`
|
|
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
|
package/dist/extensions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAGH,OAAO,EAEL,MAAM,EAEN,KAAK,QAAQ,EACb,KAAK,QAAQ,EAGd,MAAM,mBAAmB,CAAA;AAqB1B,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,gEAAgE;IAChE,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IACnD,iCAAiC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IACnD,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACrC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAC1C;AAED,gFAAgF;AAChF,eAAO,MAAM,YAAY,sBAAsB,CAAA;AAmB/C;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,IAAI,CAoB9E;AAED,wBAAgB,0BAA0B,IAAI,SAAS,eAAe,EAAE,CAEvE;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKzE;AAED,gDAAgD;AAChD,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C;AAmdD,wBAAgB,YAAY,CAAC,IAAI,GAAE,SAAS,eAAe,EAAO,GAAG,MAAM,CA4B1E;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,UAAU,IAAI,MAAM,CASnC"}
|