@openleaf-editor/core 0.1.0-beta.2 → 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.map +1 -1
- package/dist/autolink.js +45 -7
- package/dist/autolink.js.map +1 -1
- 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 +15 -61
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +295 -343
- package/dist/commands.js.map +1 -1
- package/dist/css.d.ts +1 -175
- package/dist/css.d.ts.map +1 -1
- package/dist/css.js +1 -516
- 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 +1 -51
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.js +1 -115
- package/dist/embed.js.map +1 -1
- 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 +272 -52
- package/dist/extensions.js.map +1 -1
- package/dist/formats.d.ts.map +1 -1
- package/dist/formats.js +19 -7
- package/dist/formats.js.map +1 -1
- 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 +21 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -6
- 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/noneditable.d.ts.map +1 -1
- package/dist/noneditable.js +18 -4
- package/dist/noneditable.js.map +1 -1
- 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 +48 -17
- package/dist/preserve.d.ts.map +1 -1
- package/dist/preserve.js +214 -43
- 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 +157 -28
- package/dist/schema.js.map +1 -1
- package/dist/structure.d.ts +32 -0
- package/dist/structure.d.ts.map +1 -1
- package/dist/structure.js +53 -10
- package/dist/structure.js.map +1 -1
- package/dist/tables.d.ts +47 -1
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +417 -40
- 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 +8 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +54 -6
- package/dist/tokens.js.map +1 -1
- 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 +11 -1
- package/dist/visual-aids.d.ts.map +1 -1
- package/dist/visual-aids.js +124 -36
- package/dist/visual-aids.js.map +1 -1
- package/package.json +15 -1
package/dist/html.d.ts
CHANGED
|
@@ -13,9 +13,39 @@ export interface HtmlIOOptions {
|
|
|
13
13
|
/** Schema to parse against. Defaults to the built-in one. */
|
|
14
14
|
schema?: Schema;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* How deep a parsed tree may nest.
|
|
18
|
+
*
|
|
19
|
+
* ProseMirror's DOM parser recurses once per element, and so does the serializer
|
|
20
|
+
* on the way back, so a document deep enough overflows the JavaScript stack
|
|
21
|
+
* before either finishes. Measured on Node 26 at the default stack size:
|
|
22
|
+
* `'<div>'.repeat(5000)` -- 30 KB of markup -- throws `RangeError: Maximum call
|
|
23
|
+
* stack size exceeded`, while a 2 MB *flat* document parses without complaint.
|
|
24
|
+
* Depth is the problem, not size, which is what makes it reachable by an
|
|
25
|
+
* attacker with a small payload.
|
|
26
|
+
*
|
|
27
|
+
* 500 is far above anything authored and far below where any engine gives out.
|
|
28
|
+
* The deepest structure real content produces is quoted email, and that runs to
|
|
29
|
+
* tens of levels, not hundreds.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MAX_PARSE_DEPTH = 500;
|
|
32
|
+
/**
|
|
33
|
+
* Parse an HTML string into an OpenLeaf document.
|
|
34
|
+
*
|
|
35
|
+
* Throws `OpenLeafError` with code `invalid-argument` for a non-string, and
|
|
36
|
+
* `depth-limit` for input nested past {@link MAX_PARSE_DEPTH}. It used to coerce
|
|
37
|
+
* anything at all -- `parseHtml(42)` returned an empty document -- which turned
|
|
38
|
+
* a caller's type error into silent content loss.
|
|
39
|
+
*/
|
|
17
40
|
export declare function parseHtml(html: string, opts?: HtmlIOOptions): PMNode;
|
|
18
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Serialize an OpenLeaf document back to an HTML string.
|
|
43
|
+
*
|
|
44
|
+
* Throws `OpenLeafError` with code `invalid-argument` for anything that is not a
|
|
45
|
+
* ProseMirror node. `serializeHtml(null)` used to surface a raw
|
|
46
|
+
* `TypeError: Cannot read properties of null (reading 'type')` from inside
|
|
47
|
+
* ProseMirror, with nothing in it naming OpenLeaf or the call that was wrong.
|
|
48
|
+
*/
|
|
19
49
|
export declare function serializeHtml(node: PMNode, opts?: HtmlIOOptions): string;
|
|
20
50
|
/** Convenience: one full parse/serialize cycle. */
|
|
21
51
|
export declare function roundTrip(html: string, opts?: HtmlIOOptions): string;
|
package/dist/html.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA4B,KAAK,IAAI,IAAI,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA4B,KAAK,IAAI,IAAI,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAuC9F,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAcD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,MAAM,CAAA;AAkClC;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CA2BpE;AA8GD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CAqBxE;AAED,mDAAmD;AACnD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,MAAM,CAEpE"}
|
package/dist/html.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import { DOMParser, DOMSerializer } from 'prosemirror-model';
|
|
10
10
|
import { isInsidePreserved, withSerializationDocument } from './preserve.js';
|
|
11
11
|
import { coreSchema } from './extensions.js';
|
|
12
|
+
import { OpenLeafError } from './errors.js';
|
|
13
|
+
import { tableSectionRowCounts } from './tables.js';
|
|
12
14
|
/**
|
|
13
15
|
* Parsers and serializers are resolved per schema rather than built once.
|
|
14
16
|
*
|
|
@@ -42,61 +44,212 @@ function serializerFor(target) {
|
|
|
42
44
|
function resolveDocument(opts) {
|
|
43
45
|
const doc = opts?.document ?? (typeof document !== 'undefined' ? document : undefined);
|
|
44
46
|
if (!doc) {
|
|
45
|
-
throw new
|
|
47
|
+
throw new OpenLeafError('no-document', '@openleaf-editor/core: no Document available. Pass { document } when ' +
|
|
46
48
|
'running outside a browser.');
|
|
47
49
|
}
|
|
48
50
|
return doc;
|
|
49
51
|
}
|
|
50
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* How deep a parsed tree may nest.
|
|
54
|
+
*
|
|
55
|
+
* ProseMirror's DOM parser recurses once per element, and so does the serializer
|
|
56
|
+
* on the way back, so a document deep enough overflows the JavaScript stack
|
|
57
|
+
* before either finishes. Measured on Node 26 at the default stack size:
|
|
58
|
+
* `'<div>'.repeat(5000)` -- 30 KB of markup -- throws `RangeError: Maximum call
|
|
59
|
+
* stack size exceeded`, while a 2 MB *flat* document parses without complaint.
|
|
60
|
+
* Depth is the problem, not size, which is what makes it reachable by an
|
|
61
|
+
* attacker with a small payload.
|
|
62
|
+
*
|
|
63
|
+
* 500 is far above anything authored and far below where any engine gives out.
|
|
64
|
+
* The deepest structure real content produces is quoted email, and that runs to
|
|
65
|
+
* tens of levels, not hundreds.
|
|
66
|
+
*/
|
|
67
|
+
export const MAX_PARSE_DEPTH = 500;
|
|
68
|
+
/**
|
|
69
|
+
* Reject over-deep input before the recursive parse meets it.
|
|
70
|
+
*
|
|
71
|
+
* An explicit stack, so measuring the depth cannot itself overflow. Two parallel
|
|
72
|
+
* arrays rather than an array of pairs: a 2 MB document has ~110,000 elements
|
|
73
|
+
* and the object churn was measurable where two number pushes are not.
|
|
74
|
+
*/
|
|
75
|
+
function assertDepthWithin(root, limit) {
|
|
76
|
+
const nodes = [];
|
|
77
|
+
const depths = [];
|
|
78
|
+
for (const child of Array.from(root.children)) {
|
|
79
|
+
nodes.push(child);
|
|
80
|
+
depths.push(1);
|
|
81
|
+
}
|
|
82
|
+
while (nodes.length > 0) {
|
|
83
|
+
const node = nodes.pop();
|
|
84
|
+
const depth = depths.pop();
|
|
85
|
+
if (depth > limit) {
|
|
86
|
+
throw new OpenLeafError('depth-limit', `@openleaf-editor/core: HTML nests more than ${limit} elements deep. Parsing it ` +
|
|
87
|
+
'recurses once per level and would overflow the stack. This is almost always ' +
|
|
88
|
+
'adversarial input rather than a document somebody wrote.');
|
|
89
|
+
}
|
|
90
|
+
for (const child of Array.from(node.children)) {
|
|
91
|
+
nodes.push(child);
|
|
92
|
+
depths.push(depth + 1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Parse an HTML string into an OpenLeaf document.
|
|
98
|
+
*
|
|
99
|
+
* Throws `OpenLeafError` with code `invalid-argument` for a non-string, and
|
|
100
|
+
* `depth-limit` for input nested past {@link MAX_PARSE_DEPTH}. It used to coerce
|
|
101
|
+
* anything at all -- `parseHtml(42)` returned an empty document -- which turned
|
|
102
|
+
* a caller's type error into silent content loss.
|
|
103
|
+
*/
|
|
51
104
|
export function parseHtml(html, opts) {
|
|
105
|
+
if (typeof html !== 'string') {
|
|
106
|
+
throw new OpenLeafError('invalid-argument', `@openleaf-editor/core: parseHtml expects an HTML string, received ${typeof html}.`);
|
|
107
|
+
}
|
|
52
108
|
const doc = resolveDocument(opts);
|
|
53
109
|
const tpl = doc.createElement('template');
|
|
54
|
-
|
|
110
|
+
// The DOM parser is itself recursive and gives out at around 20,000 levels,
|
|
111
|
+
// which is *before* the depth check below could run. Its `RangeError` says
|
|
112
|
+
// nothing about what happened or which call caused it, so it is converted
|
|
113
|
+
// rather than allowed to escape.
|
|
114
|
+
try {
|
|
115
|
+
tpl.innerHTML = html;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw new OpenLeafError('depth-limit', '@openleaf-editor/core: the HTML could not be parsed -- it is nested too deeply, or too ' +
|
|
119
|
+
'large, for this DOM implementation to handle.', { cause: error });
|
|
120
|
+
}
|
|
121
|
+
assertDepthWithin(tpl.content, MAX_PARSE_DEPTH);
|
|
55
122
|
return parserFor(opts?.schema ?? coreSchema()).parse(tpl.content, {
|
|
56
123
|
preserveWhitespace: false,
|
|
57
124
|
});
|
|
58
125
|
}
|
|
59
126
|
/**
|
|
60
|
-
* Collapse `<
|
|
127
|
+
* Collapse a sole attribute-free `<p>` back to its container's direct children.
|
|
61
128
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
129
|
+
* Several containers hold block content (`table_cell` is `block+`, `list_item`
|
|
130
|
+
* is `paragraph block*`, `blockquote` is `block+`, `details` is `summary
|
|
131
|
+
* block+`). Parsing the overwhelmingly common legacy form -- `<td>text</td>`,
|
|
132
|
+
* `<li>text</li>`, `<blockquote>quoted</blockquote>`, a details body that is
|
|
133
|
+
* just text -- therefore produces a paragraph, and serializing it back would
|
|
134
|
+
* write the wrapper into every list, quote, disclosure and table in a CMS the
|
|
135
|
+
* first time each post is opened and saved.
|
|
67
136
|
*
|
|
68
137
|
* That is a normalization rather than information loss, but "we changed every
|
|
69
|
-
*
|
|
70
|
-
*
|
|
138
|
+
* list in your archive" is not a thing this project gets to do quietly. So a
|
|
139
|
+
* container whose modelled content is exactly one attribute-free paragraph is
|
|
140
|
+
* unwrapped on the way out. For `<details>` that means the body after
|
|
141
|
+
* `<summary>`, not the whole element.
|
|
71
142
|
*
|
|
72
|
-
* The
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
143
|
+
* The same rule as cells still applies to mixed content: `<li>a<ul><li>b</li>
|
|
144
|
+
* </ul></li>` parses to a paragraph plus a nested list, so the outer paragraph
|
|
145
|
+
* stays. The inner item is a sole paragraph and unwraps.
|
|
146
|
+
*
|
|
147
|
+
* The asymmetry is deliberate and worth stating: a container that was authored
|
|
148
|
+
* as `<li><p>text</p></li>` also comes back as `<li>text</li>`. That form is
|
|
149
|
+
* rare in the content this editor inherits, and the alternative is rewriting
|
|
150
|
+
* the common case instead of the rare one.
|
|
76
151
|
*/
|
|
77
|
-
function
|
|
78
|
-
for (const
|
|
79
|
-
// Never reach inside preserved markup. A
|
|
152
|
+
function unwrapSoleParagraph(host) {
|
|
153
|
+
for (const container of Array.from(host.querySelectorAll('td, th, li, blockquote, details'))) {
|
|
154
|
+
// Never reach inside preserved markup. A list nested in an unrecognised
|
|
80
155
|
// wrapper is content we undertook to return byte-identical, and a
|
|
81
|
-
// normalization that is right for our own
|
|
82
|
-
if (isInsidePreserved(
|
|
156
|
+
// normalization that is right for our own nodes is a broken promise there.
|
|
157
|
+
if (isInsidePreserved(container))
|
|
83
158
|
continue;
|
|
84
|
-
|
|
159
|
+
const only = soleAttributeFreeParagraph(container);
|
|
160
|
+
if (!only)
|
|
85
161
|
continue;
|
|
86
|
-
|
|
87
|
-
|
|
162
|
+
while (only.firstChild)
|
|
163
|
+
container.insertBefore(only.firstChild, only);
|
|
164
|
+
container.removeChild(only);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The paragraph this pass is allowed to unwrap, or null.
|
|
169
|
+
*
|
|
170
|
+
* `details` always has a `<summary>` sibling, so "entire content is one `<p>`"
|
|
171
|
+
* would never fire there. Everything else uses the cell rule: one child node,
|
|
172
|
+
* and it is an attribute-free `<p>`.
|
|
173
|
+
*/
|
|
174
|
+
function soleAttributeFreeParagraph(container) {
|
|
175
|
+
const candidates = container.nodeName === 'DETAILS'
|
|
176
|
+
? Array.from(container.childNodes).filter((node) => !(node.nodeType === 1 && node.nodeName === 'SUMMARY'))
|
|
177
|
+
: Array.from(container.childNodes);
|
|
178
|
+
if (candidates.length !== 1)
|
|
179
|
+
return null;
|
|
180
|
+
const only = candidates[0];
|
|
181
|
+
if (!only || only.nodeType !== 1)
|
|
182
|
+
return null;
|
|
183
|
+
const el = only;
|
|
184
|
+
if (el.nodeName !== 'P' || el.attributes.length > 0)
|
|
185
|
+
return null;
|
|
186
|
+
return el;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Put a table's rows back into the `<thead>` and `<tfoot>` they came from.
|
|
190
|
+
*
|
|
191
|
+
* A table node holds nothing but rows -- `prosemirror-tables` requires that, see
|
|
192
|
+
* tables.ts -- and a node renders through a single `contentDOM`, so `toDOM` can
|
|
193
|
+
* emit one section and no more. The grouping is therefore restored here, from
|
|
194
|
+
* the row counts tables.ts recorded against the element it built.
|
|
195
|
+
*
|
|
196
|
+
* Only for tables that HAD a section. Deriving a `<thead>` from the presence of
|
|
197
|
+
* `<th>` cells would look like an improvement and would rewrite every table in
|
|
198
|
+
* an archive that never used one, which is the change `unwrapSoleParagraph`
|
|
199
|
+
* argues at length this project does not get to make quietly.
|
|
200
|
+
*
|
|
201
|
+
* The counts are clamped rather than trusted, because the document can have
|
|
202
|
+
* changed since it was parsed: an author who deletes the header row of a table
|
|
203
|
+
* whose node still says `headerRows: 1` gets a table with one fewer section, not
|
|
204
|
+
* a `<thead>` built out of their first data row and not a thrown error. The
|
|
205
|
+
* `<tbody>` goes away entirely if every row left it, so a table that was all
|
|
206
|
+
* `<thead>` does not come back with an empty body it never had.
|
|
207
|
+
*/
|
|
208
|
+
function restoreTableSections(host, doc) {
|
|
209
|
+
for (const table of Array.from(host.querySelectorAll('table'))) {
|
|
210
|
+
// Same rule as the cell pass: a table inside preserved markup is content we
|
|
211
|
+
// undertook to hand back byte-identical, and its sections are already in the
|
|
212
|
+
// preserved string. Restructuring there would be a broken promise.
|
|
213
|
+
if (isInsidePreserved(table))
|
|
88
214
|
continue;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (cell.childNodes.length !== 1)
|
|
215
|
+
const counts = tableSectionRowCounts(table);
|
|
216
|
+
if (!counts)
|
|
92
217
|
continue;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
218
|
+
const tbody = Array.from(table.children).find((child) => child.nodeName === 'TBODY');
|
|
219
|
+
if (!tbody)
|
|
220
|
+
continue;
|
|
221
|
+
const rows = Array.from(tbody.children).filter((child) => child.nodeName === 'TR');
|
|
222
|
+
const header = Math.min(counts.header, rows.length);
|
|
223
|
+
const footer = Math.min(counts.footer, rows.length - header);
|
|
224
|
+
if (header > 0) {
|
|
225
|
+
const thead = doc.createElement('thead');
|
|
226
|
+
for (const row of rows.slice(0, header))
|
|
227
|
+
thead.appendChild(row);
|
|
228
|
+
table.insertBefore(thead, tbody);
|
|
229
|
+
}
|
|
230
|
+
if (footer > 0) {
|
|
231
|
+
const tfoot = doc.createElement('tfoot');
|
|
232
|
+
for (const row of rows.slice(rows.length - footer))
|
|
233
|
+
tfoot.appendChild(row);
|
|
234
|
+
table.insertBefore(tfoot, tbody.nextSibling);
|
|
235
|
+
}
|
|
236
|
+
if (!tbody.hasChildNodes())
|
|
237
|
+
table.removeChild(tbody);
|
|
96
238
|
}
|
|
97
239
|
}
|
|
98
|
-
/**
|
|
240
|
+
/**
|
|
241
|
+
* Serialize an OpenLeaf document back to an HTML string.
|
|
242
|
+
*
|
|
243
|
+
* Throws `OpenLeafError` with code `invalid-argument` for anything that is not a
|
|
244
|
+
* ProseMirror node. `serializeHtml(null)` used to surface a raw
|
|
245
|
+
* `TypeError: Cannot read properties of null (reading 'type')` from inside
|
|
246
|
+
* ProseMirror, with nothing in it naming OpenLeaf or the call that was wrong.
|
|
247
|
+
*/
|
|
99
248
|
export function serializeHtml(node, opts) {
|
|
249
|
+
if (node === null || typeof node !== 'object' || !('type' in node) || !('content' in node)) {
|
|
250
|
+
throw new OpenLeafError('invalid-argument', '@openleaf-editor/core: serializeHtml expects a ProseMirror node, such as ' +
|
|
251
|
+
'`view.state.doc`.');
|
|
252
|
+
}
|
|
100
253
|
const doc = resolveDocument(opts);
|
|
101
254
|
return withSerializationDocument(doc, () => {
|
|
102
255
|
// Taken from the document itself, so a document built on an extended schema
|
|
@@ -106,7 +259,8 @@ export function serializeHtml(node, opts) {
|
|
|
106
259
|
const fragment = serializerFor(target).serializeFragment(node.content, { document: doc });
|
|
107
260
|
const host = doc.createElement('div');
|
|
108
261
|
host.appendChild(fragment);
|
|
109
|
-
|
|
262
|
+
unwrapSoleParagraph(host);
|
|
263
|
+
restoreTableSections(host, doc);
|
|
110
264
|
return host.innerHTML;
|
|
111
265
|
});
|
|
112
266
|
}
|
package/dist/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAoC,MAAM,mBAAmB,CAAA;AAC9F,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../src/html.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAoC,MAAM,mBAAmB,CAAA;AAC9F,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,GAAG,IAAI,OAAO,EAAqB,CAAA;AAChD,MAAM,WAAW,GAAG,IAAI,OAAO,EAAyB,CAAA;AAExD,SAAS,SAAS,CAAC,MAAc;IAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,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IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAA;QAC/C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAA;QACzF,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAC1B,mBAAmB,CAAC,IAAI,CAAC,CAAA;QACzB,oBAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,IAAoB;IAC1D,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;AACnD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProseMirror types re-exported so a plugin needs no direct dependency on
|
|
3
|
+
* ProseMirror to be written against this API.
|
|
4
|
+
*
|
|
5
|
+
* Type-only, so they add nothing to any bundle. Without them, writing a
|
|
6
|
+
* `Command` or a `NodeSpec` meant adding `prosemirror-state` and
|
|
7
|
+
* `prosemirror-model` to the plugin's own package -- and getting a *second*
|
|
8
|
+
* copy of either of them is how a node built by one schema stops being a node
|
|
9
|
+
* type the editor accepts.
|
|
10
|
+
*/
|
|
11
|
+
export type { Command } from 'prosemirror-state';
|
|
12
|
+
export type { MarkSpec, NodeSpec, Schema } from 'prosemirror-model';
|
|
13
|
+
export { OpenLeafError, isOpenLeafError, type OpenLeafErrorCode } from './errors.js';
|
|
1
14
|
export { baseSchema, coreMarks, coreNodes } from './schema.js';
|
|
2
15
|
export { ALIGNMENTS, COLOUR_PROPERTIES, FONT_FAMILIES, FONT_SIZE_PRESETS, INDENT_EM, INLINE_STYLE_PROPERTIES, LINE_HEIGHT_PRESETS, LIST_STYLES, MAX_INDENT, MODELLED_PROPERTIES, indentCss, indentLevels, isFullyModelledStyle, modelledValue, parseDeclarations, safeAlign, safeColor, safeDir, safeFontFamily, safeFontSize, safeLang, safeLineHeight, safeListStyle, serializeDeclarations, type Align, type Dir, type ListStyle, } from './css.js';
|
|
3
|
-
export { parseHtml, serializeHtml, roundTrip, type HtmlIOOptions } from './html.js';
|
|
4
|
-
export { isLosslesslyUnwrappable, unknownBlock, unknownInline } from './preserve.js';
|
|
16
|
+
export { MAX_PARSE_DEPTH, parseHtml, serializeHtml, roundTrip, type HtmlIOOptions } from './html.js';
|
|
17
|
+
export { isLosslesslyUnwrappable, isInsidePreserved, unknownBlock, unknownInline, } from './preserve.js';
|
|
5
18
|
export { URL_ATTRIBUTES, isEventHandlerAttribute, isSafeUrl, safeUrlOrNull, } from './url.js';
|
|
6
|
-
export { EMBED_HOSTS, isAllowedEmbedSrc, safeAllowList, safeEmbedSrc, type EmbedHostRule, } from './embed.js';
|
|
19
|
+
export { EMBED_HOSTS, embedSrcFor, isAllowedEmbedSrc, safeAllowList, safeEmbedSrc, type EmbedHostRule, } from './embed.js';
|
|
7
20
|
export { IMAGE_ALIGNMENTS, IMAGE_ALIGN_CLASS, IMAGE_ALIGN_CLASSES, imageAlignFromClass, safeClassList, safeId, type ImageAlign, } from './tokens.js';
|
|
8
|
-
export { activeBackgroundColor, activeDir, activeFontFamily, activeFontSize, activeHeadingLevel, activeIndent, activeLanguage, activeLineHeight, activeLink, activeListStyle, activeTextAlign, activeTextColor, canInsert, canRedo, canUndo, isMarkActive, isNodeActive, toggleBold, toggleInlineCode, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, clearBackgroundColor, clearTextColor, setBackgroundColor, setTextColor, setFontFamily, setFontSize, setLanguage, clearFormatting, insertHorizontalRule, setDir, setHeading, setLineHeight, setParagraph, setTextAlign, toggleBlockquote, toggleCodeBlock, toggleDir, toggleHeading, toggleTextAlign, wrapInBlockquote, insertAudio, insertDetails, insertHtml, insertIframe, insertNamedAnchor, insertNonBreakingSpace, insertPageBreak, insertText, insertVideo, setHeadingId, indent, indentListItem, outdent, outdentListItem, setListStyle, splitListItemCommand, toggleBulletList, toggleOrderedList, insertImage, setLink, unsetLink, type ImageAttrs, type LinkAttrs, type MediaAttrs, redo, undo, } from './commands.js';
|
|
21
|
+
export { activeBackgroundColor, activeDir, activeFontFamily, activeFontSize, activeHeadingLevel, activeIndent, activeLanguage, activeLineHeight, activeLink, activeListStyle, activeTextAlign, activeTextColor, canInsert, canRedo, canUndo, isMarkActive, isNodeActive, toggleBold, toggleInlineCode, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline, clearBackgroundColor, clearTextColor, setBackgroundColor, setTextColor, setFontFamily, setFontSize, setLanguage, clearFormatting, insertHorizontalRule, setDir, setHeading, setLineHeight, setParagraph, setTextAlign, toggleBlockquote, toggleCodeBlock, toggleDir, toggleHeading, toggleTextAlign, wrapInBlockquote, insertAudio, insertDetails, insertHtml, insertIframe, insertNamedAnchor, insertNonBreakingSpace, insertPageBreak, insertText, insertVideo, setHeadingId, indent, indentListItem, outdent, outdentListItem, setListStyle, splitListItemCommand, toggleBulletList, toggleOrderedList, insertImage, selectedImage, selectedMedia, setLink, unsetLink, updateImage, updateMedia, type ImageAttrs, type LinkAttrs, type MediaAttrs, type MediaSource, type SelectedImage, type SelectedMedia, redo, undo, } from './commands.js';
|
|
9
22
|
export { buildKeymap, shortcutFor, shortcuts, type Shortcut, } from './keymap.js';
|
|
10
23
|
export { autolinkPlugin, hrefFromTypedUrl } from './autolink.js';
|
|
11
24
|
export { visualAidsPlugin } from './visual-aids.js';
|
|
25
|
+
export { disclosurePlugin } from './disclosure.js';
|
|
26
|
+
export { clampIsolatingTextSelection, innermostIsolatingDepth, isolatingSelectionPlugin, textSelectionCrossesIsolating, } from './isolating-selection.js';
|
|
12
27
|
export { isNonEditableNode, nonEditablePlugin } from './noneditable.js';
|
|
13
28
|
export { activeBlockClass, carriedClass, formatParts, parseFormatList, setBlockClass, type FormatParts, type FormatSpec, } from './formats.js';
|
|
14
29
|
export { createRegisteredPlugins, onEditorPluginsChange, registerEditorPlugin, type EditorPluginFactory, } from './plugins.js';
|
|
15
|
-
export { safeTableStyleValue,
|
|
16
|
-
export {
|
|
30
|
+
export { safeTableStyleValue, tableCaptionPlugin } from './tables.js';
|
|
31
|
+
export { coreSchema, createSchema, onSchemaExtensionsChange, registerSchemaExtension, registeredSchemaExtensions, type SchemaExtension, } from './extensions.js';
|
|
17
32
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,uBAAuB,EACvB,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,mBAAmB,EACnB,SAAS,EACT,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,OAAO,EACP,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,SAAS,GACf,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,YAAY,EAAE,OAAO,EAAE,MAAM,mBAAmB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0B,CAAA;AACjC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,eAAe,EACf,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAA;AASrB,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAKrE,OAAO,EACL,UAAU,EACV,YAAY,EAMZ,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
export { OpenLeafError, isOpenLeafError } from './errors.js';
|
|
1
2
|
export { baseSchema, coreMarks, coreNodes } from './schema.js';
|
|
2
3
|
export { ALIGNMENTS, COLOUR_PROPERTIES, FONT_FAMILIES, FONT_SIZE_PRESETS, INDENT_EM, INLINE_STYLE_PROPERTIES, LINE_HEIGHT_PRESETS, LIST_STYLES, MAX_INDENT, MODELLED_PROPERTIES, indentCss, indentLevels, isFullyModelledStyle, modelledValue, parseDeclarations, safeAlign, safeColor, safeDir, safeFontFamily, safeFontSize, safeLang, safeLineHeight, safeListStyle, serializeDeclarations, } from './css.js';
|
|
3
|
-
export { parseHtml, serializeHtml, roundTrip } from './html.js';
|
|
4
|
-
export { isLosslesslyUnwrappable,
|
|
4
|
+
export { MAX_PARSE_DEPTH, parseHtml, serializeHtml, roundTrip } from './html.js';
|
|
5
|
+
export { isLosslesslyUnwrappable,
|
|
6
|
+
// Required reading for plugin authors -- `docs/authoring-plugins.md` §4.1 tells
|
|
7
|
+
// a command to call this before touching a node, because editing inside
|
|
8
|
+
// preserved markup breaks the byte-identical promise the layer exists to keep.
|
|
9
|
+
// It was documented as mandatory and was not exported.
|
|
10
|
+
isInsidePreserved, unknownBlock, unknownInline, } from './preserve.js';
|
|
5
11
|
export { URL_ATTRIBUTES, isEventHandlerAttribute, isSafeUrl, safeUrlOrNull, } from './url.js';
|
|
6
|
-
export { EMBED_HOSTS, isAllowedEmbedSrc, safeAllowList, safeEmbedSrc, } from './embed.js';
|
|
12
|
+
export { EMBED_HOSTS, embedSrcFor, isAllowedEmbedSrc, safeAllowList, safeEmbedSrc, } from './embed.js';
|
|
7
13
|
export { IMAGE_ALIGNMENTS, IMAGE_ALIGN_CLASS, IMAGE_ALIGN_CLASSES, imageAlignFromClass, safeClassList, safeId, } from './tokens.js';
|
|
8
14
|
export {
|
|
9
15
|
// predicates
|
|
@@ -19,15 +25,35 @@ insertHorizontalRule, setDir, setHeading, setLineHeight, setParagraph, setTextAl
|
|
|
19
25
|
// lists
|
|
20
26
|
indent, indentListItem, outdent, outdentListItem, setListStyle, splitListItemCommand, toggleBulletList, toggleOrderedList,
|
|
21
27
|
// links and images
|
|
22
|
-
insertImage, setLink, unsetLink,
|
|
28
|
+
insertImage, selectedImage, selectedMedia, setLink, unsetLink, updateImage, updateMedia,
|
|
23
29
|
// history
|
|
24
30
|
redo, undo, } from './commands.js';
|
|
25
31
|
export { buildKeymap, shortcutFor, shortcuts, } from './keymap.js';
|
|
26
32
|
export { autolinkPlugin, hrefFromTypedUrl } from './autolink.js';
|
|
27
33
|
export { visualAidsPlugin } from './visual-aids.js';
|
|
34
|
+
export { disclosurePlugin } from './disclosure.js';
|
|
35
|
+
export { clampIsolatingTextSelection, innermostIsolatingDepth, isolatingSelectionPlugin, textSelectionCrossesIsolating, } from './isolating-selection.js';
|
|
28
36
|
export { isNonEditableNode, nonEditablePlugin } from './noneditable.js';
|
|
29
37
|
export { activeBlockClass, carriedClass, formatParts, parseFormatList, setBlockClass, } from './formats.js';
|
|
30
38
|
export { createRegisteredPlugins, onEditorPluginsChange, registerEditorPlugin, } from './plugins.js';
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
// The table node specs themselves are no longer exported. They were raw,
|
|
40
|
+
// mutable `NodeSpec` objects, and a consumer holding one could edit the schema
|
|
41
|
+
// every editor on the page is built from. `coreSchema().nodes['table']` is the
|
|
42
|
+
// supported way to reach a table node type, and nothing outside this package
|
|
43
|
+
// ever imported the specs. `safeTableStyleValue` stays: the property dialogs in
|
|
44
|
+
// @openleaf-editor/plugins-table share it with the parse path, so a dialog
|
|
45
|
+
// writing attributes directly cannot disagree with the schema about an
|
|
46
|
+
// acceptable padding -- which is how `padding: 0;position:fixed;inset:0` got in.
|
|
47
|
+
export { safeTableStyleValue, tableCaptionPlugin } from './tables.js';
|
|
48
|
+
// `CARRIED_ATTR` is no longer exported. Its own docstring said "it is not for
|
|
49
|
+
// plugin authors", and it names an internal attribute slot whose contents the
|
|
50
|
+
// carry mechanism owns; a plugin writing to it corrupts the residue that keeps
|
|
51
|
+
// unmodelled attributes alive across a round trip.
|
|
52
|
+
export { coreSchema, createSchema,
|
|
53
|
+
// Kept, and both are load-bearing across a package boundary: the element
|
|
54
|
+
// subscribes to `onSchemaExtensionsChange` to warn about a schema that
|
|
55
|
+
// arrived too late, and `registeredSchemaExtensions` returns a fresh array
|
|
56
|
+
// rather than the registry, so it publishes what is installed without
|
|
57
|
+
// publishing the ability to change it.
|
|
58
|
+
onSchemaExtensionsChange, registerSchemaExtension, registeredSchemaExtensions, } from './extensions.js';
|
|
33
59
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,eAAe,EAA0B,MAAM,aAAa,CAAA;AACpF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa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