@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
@@ -39,10 +39,14 @@
39
39
  * documents in its shape. `replaces` is the explicit opt-in.
40
40
  */
41
41
  import OrderedMap from 'orderedmap';
42
- import { Schema, } from 'prosemirror-model';
43
- import { MODELLED_PROPERTIES, applyStyleAttribute, parseDeclarations, serializeDeclarations, } from './css.js';
44
- import { coreMarks, coreNodes } from './schema.js';
45
- import { URL_ATTRIBUTES, isEventHandlerAttribute, isSafeUrl } from './url.js';
42
+ import { DOMSerializer, Schema, } from 'prosemirror-model';
43
+ import { INLINE_STYLE_PROPERTIES, MODELLED_PROPERTIES, applyStyleAttribute, indentLevels, parseDeclarations, serializeDeclarations, } from './css.js';
44
+ import { OpenLeafError } from './errors.js';
45
+ import { serializationTarget } from './preserve.js';
46
+ import { coreMarks, coreNodes, listStart } from './schema.js';
47
+ import { CARRIED_STYLE_SCRUBS } from './tables.js';
48
+ import { isWritableAttributeName, safeId } from './tokens.js';
49
+ import { URL_ATTRIBUTES, isEventHandlerAttribute, isNeverCarriedAttribute, isSafeUrl, } from './url.js';
46
50
  /** Where carried attributes live. Underscored: it is not for plugin authors. */
47
51
  export const CARRIED_ATTR = '__openleafCarried';
48
52
  /* ------------------------------------------------------------------ *
@@ -74,6 +78,11 @@ export function registerSchemaExtension(extension) {
74
78
  'The second registration was ignored.');
75
79
  return () => undefined;
76
80
  }
81
+ // Build the schema this registration would produce, and throw here if it does
82
+ // not build. Without this the collision still threw -- but on some later,
83
+ // unrelated `coreSchema()` call, with a stack pointing at whichever editor
84
+ // happened to be constructed next rather than at the extension that clashed.
85
+ createSchema([...extensions.values(), extension]);
77
86
  extensions.set(extension.id, extension);
78
87
  notify();
79
88
  return () => {
@@ -104,15 +113,21 @@ function isPlainObject(value) {
104
113
  return typeof value === 'object' && value !== null && !Array.isArray(value);
105
114
  }
106
115
  /**
107
- * Residue a spec has already encoded into a modelled attribute, and so must not
108
- * carry a second copy of.
116
+ * Put an attribute back into the residue when the spec's validator refused it.
109
117
  *
110
- * `code_block` reads `language-js` from either `<pre>` or `<code>` and re-emits
111
- * it on `<code>` -- read both, write one. Carrying the `<pre>`'s class verbatim
112
- * writes it twice, so the language token is dropped from the residue while any
113
- * other class the author put there is kept. Keyed by node name because the
114
- * overlap is a property of the spec, not of the attribute.
118
+ * `accepted` is asked rather than assumed, because the two outcomes need
119
+ * opposite treatment and only the validator can tell them apart. A value the
120
+ * spec took is re-emitted from the modelled attribute and must NOT also sit in
121
+ * the residue, or it goes out twice. A value the spec refused is not re-emitted
122
+ * at all, and carrying it is the difference between "we would not store that as
123
+ * an id" -- which is our business -- and "so we deleted it", which is not.
115
124
  */
125
+ function carryRejected(carried, dom, name, accepted) {
126
+ const value = dom.getAttribute(name);
127
+ if (value === null || accepted(value))
128
+ return;
129
+ carried[name] = value;
130
+ }
116
131
  const CARRY_SCRUB = {
117
132
  code_block(carried) {
118
133
  const cls = carried['class'];
@@ -125,46 +140,106 @@ const CARRY_SCRUB = {
125
140
  delete carried['class'];
126
141
  },
127
142
  paragraph: scrubModelledStyle,
128
- heading: scrubModelledStyle,
143
+ heading(carried, dom) {
144
+ scrubModelledStyle(carried);
145
+ carryRejected(carried, dom, 'id', (value) => safeId(value) !== null);
146
+ },
147
+ bullet_list: scrubModelledStyle,
148
+ ordered_list(carried, dom) {
149
+ scrubModelledStyle(carried);
150
+ carryRejected(carried, dom, 'start', (value) => listStart(value) !== null);
151
+ },
152
+ link(carried, dom) {
153
+ carryRejected(carried, dom, 'id', (value) => safeId(value) !== null);
154
+ },
155
+ // Tables model a handful of declarations out of a `style` attribute they also
156
+ // declare as an attribute of their own. The scrubs are defined next to the
157
+ // validator that decides what "modelled" means for them, so the two cannot
158
+ // drift into either dropping a declaration twice or keeping it twice.
159
+ ...CARRIED_STYLE_SCRUBS,
129
160
  };
130
161
  /**
131
162
  * Drop the declarations a text block now models from its carried residue.
132
163
  *
133
- * `text-align` is the node's own `align` attribute and colour is the two colour
134
- * marks, so carrying either a second time emits both spellings of the same
135
- * intent -- and the moment an author changes the alignment, the copy that is not
136
- * modelled disagrees with the one that is. The legacy `align` attribute goes for
137
- * the same reason: it is where the value may have been read from, and it is not
138
- * where it is written back.
164
+ * `text-align` is the node's own `align` attribute, line height and indent are
165
+ * modelled the same way, and colour and font are marks, so carrying any of them
166
+ * a second time emits both spellings of the same intent. The legacy `align`
167
+ * attribute goes for the same reason.
139
168
  *
140
169
  * Anything else in the attribute stays. A paragraph stored as
141
- * `style="line-height:1.4;text-align:left"` keeps its line height, which is the
142
- * whole point of the carry mechanism.
170
+ * `style="letter-spacing:0.05em;text-align:left"` keeps its letter-spacing.
143
171
  */
144
172
  function scrubModelledStyle(carried) {
145
173
  delete carried['align'];
174
+ delete carried['type'];
146
175
  const style = carried['style'];
147
176
  if (style === undefined)
148
177
  return;
149
178
  const declarations = parseDeclarations(style);
179
+ const before = declarations.size;
150
180
  for (const name of MODELLED_PROPERTIES)
151
181
  declarations.delete(name);
182
+ // Indent aliases consumed into the `indent` attribute. Only dropped when they
183
+ // actually parsed as an indent; `padding-left:3px` is not one and must stay.
184
+ for (const name of ['padding-left', 'margin-left', 'margin-inline-start']) {
185
+ const value = declarations.get(name);
186
+ if (value !== undefined && indentLevels(value) !== null)
187
+ declarations.delete(name);
188
+ }
189
+ // Nothing was consumed, so there is nothing to rewrite. Re-serializing anyway
190
+ // would re-spell a declaration the schema does not model, which is the thing
191
+ // this whole mechanism exists to avoid: `letter-spacing: 0.08em;` is the
192
+ // author's, and `letter-spacing:0.08em` is ours.
193
+ if (declarations.size === before)
194
+ return;
152
195
  const rest = serializeDeclarations(declarations);
153
196
  if (rest !== null)
154
197
  carried['style'] = rest;
155
198
  else
156
199
  delete carried['style'];
157
200
  }
201
+ /**
202
+ * Word's `mso-*` properties, removed from residue on the way in.
203
+ *
204
+ * These are the one exception to "carry every declaration the schema does not
205
+ * model", and it needs arguing because the default is so strongly the other way.
206
+ * `mso-list:l0 level1 lfo1` is not CSS: it is Microsoft Office document-format
207
+ * metadata that happens to travel in a `style` attribute, and no engine renders
208
+ * it. Carrying it would mean the editor re-emitting Word debris it used to
209
+ * clean, on every save, forever -- "pasting a wall of vendor styling into the
210
+ * document" is the failure the paste pipeline exists to prevent, and the schema
211
+ * should not reintroduce it from behind.
212
+ *
213
+ * It used to be removed by accident: a spec array's `style` went out through
214
+ * `dom.style.cssText`, and the CSSOM silently discards any property it cannot
215
+ * parse. That filter was never intentional and was never safe -- it also
216
+ * discarded valid CSS that a given engine did not happen to know -- so it is
217
+ * gone (see the array branch of `withCarriedAttributes`), and what was worth
218
+ * keeping about it is stated here instead, narrowly and on purpose.
219
+ *
220
+ * Returns the string unchanged when there is nothing to remove, so a residue
221
+ * with no Office metadata in it keeps the author's exact spelling.
222
+ */
223
+ function withoutOfficeMetadata(style) {
224
+ if (!/(?:^|[;\s])mso-/i.test(style))
225
+ return style;
226
+ const declarations = parseDeclarations(style);
227
+ for (const name of [...declarations.keys()]) {
228
+ if (name.startsWith('mso-'))
229
+ declarations.delete(name);
230
+ }
231
+ return serializeDeclarations(declarations);
232
+ }
158
233
  /**
159
234
  * Merge carried residue with the attributes a spec produced.
160
235
  *
161
236
  * Modelled attributes win, because the spec is the authority on the names it
162
237
  * declared -- except for `style`, where winning wholesale is a content-loss bug.
163
- * A paragraph whose stored style was `line-height:1.4;text-align:left` has the
164
- * line height in its residue and the alignment in its `align` attribute; a plain
165
- * object spread replaces the residue's `style` with the spec's and the line
166
- * height is gone. So `style` is merged one declaration at a time, residue first
167
- * so the modelled value overrides a stale copy of itself.
238
+ * A paragraph whose stored style was `letter-spacing:0.05em;text-align:left`
239
+ * has the letter-spacing in its residue and the alignment in its `align`
240
+ * attribute; a plain object spread replaces the residue's `style` with the
241
+ * spec's and the letter-spacing is gone. So `style` is merged one declaration
242
+ * at a time, residue first so the modelled value overrides a stale copy of itself.
168
243
  */
169
244
  /**
170
245
  * Merge carried residue onto an element a spec built for itself.
@@ -172,19 +247,28 @@ function scrubModelledStyle(carried) {
172
247
  * The array path below cannot cover this case, and it is not hypothetical: a
173
248
  * paragraph carrying CSS returns a real element from `toDOM` so that its `style`
174
249
  * attribute is not rewritten by the CSSOM. That element has to be given the
175
- * residue too, or modelling `text-align` would silently drop the `line-height`
250
+ * residue too, or modelling `text-align` would silently drop the `letter-spacing`
176
251
  * next to it -- the exact loss the carry mechanism exists to prevent,
177
252
  * reintroduced from a new direction.
178
253
  */
179
254
  function applyCarriedToElement(el, carried) {
180
255
  for (const [name, value] of Object.entries(carried)) {
181
256
  if (name === 'style') {
257
+ const own = parseDeclarations(el.getAttribute('style'));
258
+ // Nothing of the spec's own to merge with, so the residue goes out exactly
259
+ // as it was stored. Round-tripping it through the declaration parser would
260
+ // re-spell CSS the schema does not model, for no gain -- and the whole
261
+ // reason this branch exists rather than letting the serializer do it is to
262
+ // stop the author's spelling being rewritten.
263
+ if (own.size === 0) {
264
+ applyStyleAttribute(el, value);
265
+ continue;
266
+ }
182
267
  const declarations = parseDeclarations(value);
183
268
  // Residue first, then what the spec wrote, so a modelled declaration wins
184
269
  // over a stale copy of itself while everything else survives.
185
- for (const [property, css] of parseDeclarations(el.getAttribute('style'))) {
270
+ for (const [property, css] of own)
186
271
  declarations.set(property, css);
187
- }
188
272
  const style = serializeDeclarations(declarations);
189
273
  if (style !== null)
190
274
  applyStyleAttribute(el, style);
@@ -196,57 +280,132 @@ function applyCarriedToElement(el, carried) {
196
280
  }
197
281
  }
198
282
  function mergeCarried(carried, modelled) {
199
- const merged = { ...carried, ...modelled };
200
- const before = carried['style'];
201
- const after = modelled['style'];
202
- if (typeof before === 'string' && typeof after === 'string') {
203
- const declarations = parseDeclarations(before);
204
- for (const [name, value] of parseDeclarations(after))
205
- declarations.set(name, value);
206
- const style = serializeDeclarations(declarations);
207
- if (style !== null)
208
- merged['style'] = style;
209
- else
210
- delete merged['style'];
283
+ // Modelled names first so `<a href>` stays `href` then `class`, not the
284
+ // reverse -- residue used to be spread first and HTML attribute order is
285
+ // load-bearing for byte-identical round trips.
286
+ const merged = { ...modelled };
287
+ for (const [name, value] of Object.entries(carried)) {
288
+ if (name === 'style' && typeof merged['style'] === 'string') {
289
+ const declarations = parseDeclarations(value);
290
+ for (const [property, css] of parseDeclarations(merged['style'])) {
291
+ declarations.set(property, css);
292
+ }
293
+ const style = serializeDeclarations(declarations);
294
+ if (style !== null)
295
+ merged['style'] = style;
296
+ else
297
+ delete merged['style'];
298
+ continue;
299
+ }
300
+ if (!(name in modelled))
301
+ merged[name] = value;
211
302
  }
212
303
  return merged;
213
304
  }
214
305
  /**
215
- * Wrap a node spec so attributes it does not model survive the round trip.
306
+ * Wrap a spec so attributes it does not model survive the round trip.
307
+ *
308
+ * Applied to extension nodes and marks unless they opt out: they only ever
309
+ * claim markup the preservation layer previously kept in full, so carrying the
310
+ * residue is a pure improvement over the alternative of silently dropping it.
216
311
  *
217
- * Applied to extension nodes unconditionally: they only ever claim markup the
218
- * preservation layer previously kept in full, so carrying the residue is a pure
219
- * improvement over the alternative of silently dropping it.
312
+ * Style parse rules are left alone. They match a declaration, not an element,
313
+ * so there is no attribute list to harvest -- and wrapping them would pass a
314
+ * CSS string into a collector that expects `HTMLElement.attributes`.
220
315
  */
221
- function withCarriedAttributes(name, spec) {
316
+ function isTagParseRule(rule) {
317
+ return typeof rule.tag === 'string';
318
+ }
319
+ function withCarriedAttributes(name, spec, kind) {
222
320
  const modelled = new Set(Object.keys(spec.attrs ?? {}));
223
321
  const attrs = { ...(spec.attrs ?? {}), [CARRIED_ATTR]: { default: null } };
224
- // A node's parse rules are always tag rules -- only marks may match styles --
225
- // so the narrower type is the accurate one and keeps the map total.
226
322
  const parseDOM = (spec.parseDOM ?? []).map((rule) => {
323
+ if (!isTagParseRule(rule))
324
+ return rule;
227
325
  const original = rule.getAttrs;
228
326
  return {
229
327
  ...rule,
230
328
  getAttrs(dom) {
231
329
  const base = original ? original.call(rule, dom) : (rule.attrs ?? {});
232
- if (base === false || base === null || base === undefined)
233
- return base;
330
+ /*
331
+ * Only `false` is a decline.
332
+ *
333
+ * `null` and `undefined` are ProseMirror's "this rule matches, with the
334
+ * type's default attributes" -- a very different statement, and treating
335
+ * them as a decline meant the wrapper handed the element straight back
336
+ * with no residue at all. `<hr class="page-rule" id="sep">` came back as
337
+ * a bare `<hr>`, because `horizontal_rule`'s rule returns `null` for
338
+ * every rule that is not a page break. Every attribute on the element,
339
+ * gone, from a branch that reads like a guard.
340
+ */
341
+ if (base === false)
342
+ return false;
234
343
  const carried = {};
235
344
  for (const attr of Array.from(dom.attributes ?? [])) {
236
- if (modelled.has(attr.name))
345
+ // `style` is never treated as modelled, even by a spec that declares
346
+ // an attribute of that name. It is the one COMPOSITE attribute in
347
+ // HTML: a node models individual declarations, not the whole string,
348
+ // so "the spec claimed it" is not the same statement it is for `class`
349
+ // or `colspan`. Table cells declare `style` and keep two properties
350
+ // out of it, and the skip below therefore threw away everything else
351
+ // with no residue at all -- `<td style="border:1px solid red">` came
352
+ // back as `<td>`, and `border` and `border-collapse` are how fifteen
353
+ // years of CMS tables are styled. The declarations a spec really did
354
+ // consume are removed by that node's CARRY_SCRUB instead, which is
355
+ // already how `<p style="text-align:center">` avoids being emitted
356
+ // twice.
357
+ // Before every other test, because it is the only one about whether
358
+ // the attribute can exist at all. The HTML parser accepts names
359
+ // `setAttribute` refuses -- `<p ="v">` parses to an attribute named
360
+ // `="v"` -- and carrying one meant the throw landed later, in the
361
+ // middle of rendering the document, from a name no author wrote.
362
+ if (!isWritableAttributeName(attr.name))
363
+ continue;
364
+ if (attr.name !== 'style' && modelled.has(attr.name))
237
365
  continue;
238
366
  // Same scrub as the preservation layer: carrying `onclick` or a
239
367
  // `javascript:` URL would reintroduce exactly the executable content
240
368
  // core promises to drop.
241
369
  if (isEventHandlerAttribute(attr.name))
242
370
  continue;
371
+ // Markup-bearing attributes are refused outright rather than
372
+ // scheme-checked. This path never reaches scrub(): the iframe node
373
+ // claims an allowlisted player, and `srcdoc` -- which the HTML spec
374
+ // gives precedence over `src` -- rode in here as residue, so the
375
+ // frame rendered the attacker's document and never fetched YouTube.
376
+ if (isNeverCarriedAttribute(attr.name))
377
+ continue;
243
378
  if (URL_ATTRIBUTES.has(attr.name.toLowerCase()) && !isSafeUrl(attr.value))
244
379
  continue;
380
+ // Google Docs wraps a paste in `<b id="docs-internal-guid-...">`.
381
+ // The paste pipeline strips that id; this is the schema-level
382
+ // backstop on the `strong` mark that claims that wrapper -- not on
383
+ // every node, or `<p id="docs-internal-guidelines">` would lose a
384
+ // legitimate id.
385
+ if (kind === 'mark' &&
386
+ name === 'strong' &&
387
+ attr.name === 'id' &&
388
+ /^docs-internal-guid/i.test(attr.value)) {
389
+ continue;
390
+ }
391
+ if (attr.name === 'style') {
392
+ let css = withoutOfficeMetadata(attr.value);
393
+ if (css !== null && kind === 'mark') {
394
+ const declarations = parseDeclarations(css);
395
+ for (const property of INLINE_STYLE_PROPERTIES) {
396
+ declarations.delete(property);
397
+ }
398
+ css = serializeDeclarations(declarations);
399
+ }
400
+ if (css !== null)
401
+ carried['style'] = css;
402
+ continue;
403
+ }
245
404
  carried[attr.name] = attr.value;
246
405
  }
247
- CARRY_SCRUB[name]?.(carried);
406
+ CARRY_SCRUB[name]?.(carried, dom);
248
407
  return {
249
- ...base,
408
+ ...(base ?? {}),
250
409
  [CARRIED_ATTR]: Object.keys(carried).length > 0 ? carried : null,
251
410
  };
252
411
  },
@@ -254,9 +413,9 @@ function withCarriedAttributes(name, spec) {
254
413
  });
255
414
  const originalToDOM = spec.toDOM;
256
415
  const toDOM = originalToDOM
257
- ? (node) => {
258
- const out = originalToDOM(node);
259
- const carried = node.attrs[CARRIED_ATTR];
416
+ ? (first, ...rest) => {
417
+ const out = originalToDOM(first, ...rest);
418
+ const carried = first.attrs[CARRIED_ATTR];
260
419
  if (!carried)
261
420
  return out;
262
421
  if (!Array.isArray(out)) {
@@ -267,6 +426,29 @@ function withCarriedAttributes(name, spec) {
267
426
  applyCarriedToElement(dom, carried);
268
427
  return out;
269
428
  }
429
+ /*
430
+ * Residue holding CSS cannot go out on a spec array.
431
+ *
432
+ * prosemirror-model writes a spec array's `style` with
433
+ * `dom.style.cssText = value`, which is a CSSOM parse and therefore a
434
+ * rewrite: `margin-bottom:0` comes back `margin-bottom: 0px`. `0` to
435
+ * `0px` is a change to the VALUE, not just the spelling, and it happens
436
+ * to every paragraph carrying an unmodelled declaration on its first
437
+ * save. css.ts argues at length that silently rewriting an archive's CSS
438
+ * is not a diff this project gets to put in a revision history;
439
+ * `applyStyleAttribute` exists to prevent exactly this and was reachable
440
+ * only from the element path.
441
+ *
442
+ * So when -- and only when -- there is CSS to carry, the array is
443
+ * rendered here and the residue applied to the real element, which is
444
+ * the same route `elementWithStyle` in schema.ts already takes. Specs
445
+ * with no CSS residue keep the cheaper array path.
446
+ */
447
+ if (typeof carried['style'] === 'string') {
448
+ const rendered = DOMSerializer.renderSpec(serializationTarget(), out);
449
+ applyCarriedToElement(rendered.dom, carried);
450
+ return (rendered.contentDOM ? rendered : rendered.dom);
451
+ }
270
452
  const result = [...out];
271
453
  if (isPlainObject(result[1])) {
272
454
  result[1] = mergeCarried(carried, result[1]);
@@ -285,7 +467,7 @@ function withCarriedAttributes(name, spec) {
285
467
  function assertRulePriorities(extensionId, name, spec) {
286
468
  for (const rule of (spec.parseDOM ?? [])) {
287
469
  if (rule.priority !== undefined && rule.priority <= 1) {
288
- throw new Error(`@openleaf-editor/core: extension "${extensionId}" gives "${name}" a parse rule at ` +
470
+ throw new OpenLeafError('invalid-argument', `@openleaf-editor/core: extension "${extensionId}" gives "${name}" a parse rule at ` +
289
471
  `priority ${rule.priority}. The preservation layer's catch-all rules sit at ` +
290
472
  'priority 0 and 1, so this rule would tie with them and the winner would be ' +
291
473
  'decided by insertion order. Remove the priority: the default already wins.');
@@ -296,13 +478,13 @@ function claim(claimed, kind, name, extension, existsInCore) {
296
478
  const replaces = new Set(extension.replaces ?? []);
297
479
  const previous = claimed.get(`${kind}:${name}`);
298
480
  if (previous && !replaces.has(name)) {
299
- throw new Error(`@openleaf-editor/core: extensions "${previous}" and "${extension.id}" both define the ` +
481
+ throw new OpenLeafError('schema-conflict', `@openleaf-editor/core: extensions "${previous}" and "${extension.id}" both define the ` +
300
482
  `${kind} "${name}". A ${kind} type is a storage format, not a preference: two ` +
301
483
  'definitions mean two serializations of the same content chosen by load order. ' +
302
484
  `If replacing it is intended, declare replaces: ['${name}'].`);
303
485
  }
304
486
  if (existsInCore && !replaces.has(name)) {
305
- throw new Error(`@openleaf-editor/core: extension "${extension.id}" defines the ${kind} "${name}", which ` +
487
+ throw new OpenLeafError('schema-conflict', `@openleaf-editor/core: extension "${extension.id}" defines the ${kind} "${name}", which ` +
306
488
  `already exists in the base schema. If replacing it is intended, declare ` +
307
489
  `replaces: ['${name}'].`);
308
490
  }
@@ -327,13 +509,23 @@ function coreNodesWithCarriedAttributes() {
327
509
  // it is how `<p class="lead">` became `<p>` on the first save.
328
510
  let nodes = OrderedMap.from({});
329
511
  for (const [name, spec] of Object.entries(coreNodes)) {
330
- nodes = nodes.addToEnd(name, SKIP_CARRY.has(name) ? spec : withCarriedAttributes(name, spec));
512
+ nodes = nodes.addToEnd(name, SKIP_CARRY.has(name) ? spec : withCarriedAttributes(name, spec, 'node'));
331
513
  }
332
514
  return nodes;
333
515
  }
516
+ function coreMarksWithCarriedAttributes() {
517
+ // The same hole as core nodes, on the other half of the schema: `<strong
518
+ // class="brand-name">` became `<strong>` because a mark spec kept the tag and
519
+ // nothing else, and the carry wrapper never ran.
520
+ let marks = OrderedMap.from({});
521
+ for (const [name, spec] of Object.entries(coreMarks)) {
522
+ marks = marks.addToEnd(name, withCarriedAttributes(name, spec, 'mark'));
523
+ }
524
+ return marks;
525
+ }
334
526
  export function createSchema(list = []) {
335
527
  let nodes = coreNodesWithCarriedAttributes();
336
- let marks = OrderedMap.from(coreMarks);
528
+ let marks = coreMarksWithCarriedAttributes();
337
529
  const claimed = new Map();
338
530
  for (const extension of list) {
339
531
  for (const [name, spec] of Object.entries(extension.nodes ?? {})) {
@@ -341,7 +533,7 @@ export function createSchema(list = []) {
341
533
  claim(claimed, 'node', name, extension, Object.hasOwn(coreNodes, name));
342
534
  const prepared = extension.carryUnknownAttributes === false
343
535
  ? spec
344
- : withCarriedAttributes(name, spec);
536
+ : withCarriedAttributes(name, spec, 'node');
345
537
  // addToEnd, never prepend: a leading block node becomes the document's
346
538
  // defaultType and every new document would start with it.
347
539
  nodes = nodes.remove(name).addToEnd(name, prepared);
@@ -349,12 +541,16 @@ export function createSchema(list = []) {
349
541
  for (const [name, spec] of Object.entries(extension.marks ?? {})) {
350
542
  assertRulePriorities(extension.id, name, spec);
351
543
  claim(claimed, 'mark', name, extension, Object.hasOwn(coreMarks, name));
352
- marks = marks.remove(name).addToEnd(name, spec);
544
+ const prepared = extension.carryUnknownAttributes === false
545
+ ? spec
546
+ : withCarriedAttributes(name, spec, 'mark');
547
+ marks = marks.remove(name).addToEnd(name, prepared);
353
548
  }
354
549
  }
355
550
  return new Schema({ nodes, marks });
356
551
  }
357
552
  let cached = null;
553
+ let subscribed = false;
358
554
  /**
359
555
  * The schema for the currently registered extensions.
360
556
  *
@@ -362,13 +558,44 @@ let cached = null;
362
558
  * "bind to this" and would be captured at import by every consumer, which is
363
559
  * exactly what made the schema impossible to extend. Memoized, and invalidated
364
560
  * whenever the registry changes.
561
+ *
562
+ * ## Why the subscription is in here and not at module scope
563
+ *
564
+ * This package declares `"sideEffects": false`, which is a literal promise that
565
+ * evaluating a module for its own sake changes nothing observable. The bare
566
+ * top-level `onSchemaExtensionsChange(() => { cached = null })` that used to sit
567
+ * below this function broke that promise: it mutates the listener set in the
568
+ * registry above, which is observable by anything that calls `notify()`.
569
+ *
570
+ * What it did *not* do, measured rather than assumed, is actually get dropped.
571
+ * Both rollup 4 (`treeshake.moduleSideEffects: false`) and webpack 5
572
+ * (`optimization.sideEffects`) keep the statement, because the arrow function
573
+ * writes `cached` and `cached` is read by this function -- so the tree-shaker
574
+ * can see the statement contributes to a live export and retains it. A probe
575
+ * that warms the memo, registers an extension and re-reads the schema returns
576
+ * the plugin's node type under both bundlers, before and after this change.
577
+ *
578
+ * It is moved anyway, because the retention depended entirely on that linkage
579
+ * being visible. It is not a property of the invalidator; it is a property of
580
+ * this particular pair of statements, and it would quietly stop holding the
581
+ * moment the memo is refactored -- at which point the failure is silent and
582
+ * total, since `coreSchema()` would keep handing back a schema built before the
583
+ * first `registerSchemaExtension` call. Registering on the first call costs a
584
+ * boolean and makes the flag true instead of true-by-luck.
585
+ *
586
+ * There is no window in which the invalidator is missing: the subscription is
587
+ * installed before the value it guards ever exists, and nothing can reach the
588
+ * memo except through here.
365
589
  */
366
590
  export function coreSchema() {
591
+ if (!subscribed) {
592
+ subscribed = true;
593
+ onSchemaExtensionsChange(() => {
594
+ cached = null;
595
+ });
596
+ }
367
597
  if (!cached)
368
598
  cached = createSchema(registeredSchemaExtensions());
369
599
  return cached;
370
600
  }
371
- onSchemaExtensionsChange(() => {
372
- cached = null;
373
- });
374
601
  //# sourceMappingURL=extensions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.js","sourceRoot":"","sources":["../src/extensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EACL,MAAM,GAMP,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE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G;AACH,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,IAAI,CAAA;QACjB,wBAAwB,CAAC,GAAG,EAAE;YAC5B,MAAM,GAAG,IAAI,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,CAAC,MAAM;QAAE,MAAM,GAAG,YAAY,CAAC,0BAA0B,EAAE,CAAC,CAAA;IAChE,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Block formats: a class on the current text block, stored as carried residue.
3
+ *
4
+ * OpenLeaf does not invent a format vocabulary. The host page's content CSS
5
+ * already names the classes that survive publish (`lead`, `callout`, a CMS
6
+ * style pack). Applying one of those classes here is the same attribute the
7
+ * preservation layer already round-trips; the command exists so a dropdown can
8
+ * set it without the author editing HTML.
9
+ */
10
+ import type { Node as PMNode } from 'prosemirror-model';
11
+ import type { Command, EditorState } from 'prosemirror-state';
12
+ export interface FormatSpec {
13
+ /** Selector-ish token: `p.lead`, `h2`, or `.note`. */
14
+ token: string;
15
+ /** Label shown in the formats control. */
16
+ label: string;
17
+ }
18
+ /** The element and the class a format token names. Either half may be absent. */
19
+ export interface FormatParts {
20
+ /** `p`, `h1`..`h6`, or null when the token names only a class. */
21
+ element: string | null;
22
+ /** Space-separated class names, or null when the token names only an element. */
23
+ className: string | null;
24
+ }
25
+ /**
26
+ * Split a format token into the element it names and the class it names.
27
+ *
28
+ * `p.lead` is both, `h2` is an element alone, `.note` is a class alone. The
29
+ * element half was previously parsed and then thrown away, so `h2=Section` set
30
+ * `class="h2"` on whichever block held the caret instead of making it a heading,
31
+ * and `p.lead` applied its class to an h2 without turning it into a paragraph.
32
+ *
33
+ * A selector naming several classes -- `p.lead.wide` -- yields both, because
34
+ * that is what the selector means.
35
+ */
36
+ export declare function formatParts(token: string): FormatParts;
37
+ /** Parse `p.lead=Lead paragraph|h2=Section|.note=Note`. */
38
+ export declare function parseFormatList(value: string | null | undefined): FormatSpec[];
39
+ export declare function carriedClass(node: PMNode): string | null;
40
+ /** The class shared by every selected text block, or null if mixed or absent. */
41
+ export declare function activeBlockClass(state: EditorState): string | null;
42
+ /** Set or clear `class` on every text block in the selection. */
43
+ export declare function setBlockClass(className: string | null): Command;
44
+ //# sourceMappingURL=formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../src/formats.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG7D,MAAM,WAAW,UAAU;IACzB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;CACd;AAED,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,kEAAkE;IAClE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,iFAAiF;IACjF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CActD;AAED,2DAA2D;AAC3D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,EAAE,CAgB9E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIxD;AAyBD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAMlE;AAYD,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAa/D"}