@openleaf-editor/core 0.1.0-beta.2 → 0.1.0-beta.4

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 (104) hide show
  1. package/README.md +127 -0
  2. package/dist/autolink.d.ts +7 -4
  3. package/dist/autolink.d.ts.map +1 -1
  4. package/dist/autolink.js +90 -11
  5. package/dist/autolink.js.map +1 -1
  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 +21 -63
  11. package/dist/commands.d.ts.map +1 -1
  12. package/dist/commands.js +430 -346
  13. package/dist/commands.js.map +1 -1
  14. package/dist/css.d.ts +1 -175
  15. package/dist/css.d.ts.map +1 -1
  16. package/dist/css.js +1 -516
  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 +1 -51
  27. package/dist/embed.d.ts.map +1 -1
  28. package/dist/embed.js +1 -115
  29. package/dist/embed.js.map +1 -1
  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 +272 -52
  37. package/dist/extensions.js.map +1 -1
  38. package/dist/figure-drag.d.ts +26 -0
  39. package/dist/figure-drag.d.ts.map +1 -0
  40. package/dist/figure-drag.js +75 -0
  41. package/dist/figure-drag.js.map +1 -0
  42. package/dist/formats.d.ts.map +1 -1
  43. package/dist/formats.js +19 -7
  44. package/dist/formats.js.map +1 -1
  45. package/dist/gapcursor.d.ts +14 -0
  46. package/dist/gapcursor.d.ts.map +1 -0
  47. package/dist/gapcursor.js +17 -0
  48. package/dist/gapcursor.js.map +1 -0
  49. package/dist/html.d.ts +32 -2
  50. package/dist/html.d.ts.map +1 -1
  51. package/dist/html.js +185 -31
  52. package/dist/html.js.map +1 -1
  53. package/dist/index.d.ts +23 -6
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +34 -6
  56. package/dist/index.js.map +1 -1
  57. package/dist/insert-commands.d.ts +172 -0
  58. package/dist/insert-commands.d.ts.map +1 -0
  59. package/dist/insert-commands.js +560 -0
  60. package/dist/insert-commands.js.map +1 -0
  61. package/dist/isolating-selection.d.ts +59 -0
  62. package/dist/isolating-selection.d.ts.map +1 -0
  63. package/dist/isolating-selection.js +251 -0
  64. package/dist/isolating-selection.js.map +1 -0
  65. package/dist/noneditable.d.ts.map +1 -1
  66. package/dist/noneditable.js +18 -4
  67. package/dist/noneditable.js.map +1 -1
  68. package/dist/plugins.d.ts +20 -2
  69. package/dist/plugins.d.ts.map +1 -1
  70. package/dist/plugins.js +27 -2
  71. package/dist/plugins.js.map +1 -1
  72. package/dist/preserve.d.ts +48 -17
  73. package/dist/preserve.d.ts.map +1 -1
  74. package/dist/preserve.js +214 -43
  75. package/dist/preserve.js.map +1 -1
  76. package/dist/schema.d.ts +15 -0
  77. package/dist/schema.d.ts.map +1 -1
  78. package/dist/schema.js +157 -28
  79. package/dist/schema.js.map +1 -1
  80. package/dist/structure.d.ts +32 -0
  81. package/dist/structure.d.ts.map +1 -1
  82. package/dist/structure.js +53 -10
  83. package/dist/structure.js.map +1 -1
  84. package/dist/tables.d.ts +47 -1
  85. package/dist/tables.d.ts.map +1 -1
  86. package/dist/tables.js +417 -40
  87. package/dist/tables.js.map +1 -1
  88. package/dist/testing.d.ts +3 -0
  89. package/dist/testing.d.ts.map +1 -0
  90. package/dist/testing.js +3 -0
  91. package/dist/testing.js.map +1 -0
  92. package/dist/tokens.d.ts +8 -0
  93. package/dist/tokens.d.ts.map +1 -1
  94. package/dist/tokens.js +54 -6
  95. package/dist/tokens.js.map +1 -1
  96. package/dist/url.d.ts +1 -25
  97. package/dist/url.d.ts.map +1 -1
  98. package/dist/url.js +1 -77
  99. package/dist/url.js.map +1 -1
  100. package/dist/visual-aids.d.ts +11 -1
  101. package/dist/visual-aids.d.ts.map +1 -1
  102. package/dist/visual-aids.js +124 -36
  103. package/dist/visual-aids.js.map +1 -1
  104. package/package.json +17 -1
@@ -0,0 +1,560 @@
1
+ import { Slice } from 'prosemirror-model';
2
+ import { NodeSelection } from 'prosemirror-state';
3
+ import { canInsertNode, markIn, nodeIn } from './command-helpers.js';
4
+ import { embedSrcFor, safeAllowList, safeEmbedSrc } from './embed.js';
5
+ import { parseHtml } from './html.js';
6
+ import { serializationTarget } from './preserve.js';
7
+ import { IMAGE_ALIGN_CLASSES, safeClassList, safeId } from './tokens.js';
8
+ import { isSafeUrl } from './url.js';
9
+ const canInsert = canInsertNode;
10
+ /**
11
+ * Apply or update a link across the selection.
12
+ *
13
+ * Removes any existing link first: without that, updating a link that only
14
+ * partially overlaps the selection leaves two adjacent links with different
15
+ * hrefs, which looks fine and is wrong.
16
+ *
17
+ * Declines an href the schema would refuse. The parse rule at `schema.ts:541`
18
+ * already rejects `javascript:`, but only on the way *in* -- so without this
19
+ * check the hostile href lives in the document, serializes into the bound
20
+ * textarea and is submitted. It disappears on the next parse, one round trip
21
+ * after the server stored it, which is the wrong side of the write.
22
+ */
23
+ export function setLink(attrs) {
24
+ return (state, dispatch) => {
25
+ if (!isSafeUrl(attrs.href))
26
+ return false;
27
+ const type = markIn(state, 'link');
28
+ if (!type)
29
+ return false;
30
+ if (state.selection.empty)
31
+ return false;
32
+ if (dispatch) {
33
+ const tr = state.tr;
34
+ const mark = type.create({
35
+ href: attrs.href,
36
+ title: attrs.title ?? null,
37
+ target: attrs.target ?? null,
38
+ rel: attrs.rel ?? null,
39
+ id: safeId(attrs.id),
40
+ });
41
+ // Per range, not across `from`..`to`: those are one range's bounds, so a
42
+ // table cell selection linked a single cell. See `selectedRanges` in
43
+ // commands.ts for the full account.
44
+ for (const range of state.selection.ranges) {
45
+ tr.removeMark(range.$from.pos, range.$to.pos, type);
46
+ tr.addMark(range.$from.pos, range.$to.pos, mark);
47
+ }
48
+ dispatch(tr.scrollIntoView());
49
+ }
50
+ return true;
51
+ };
52
+ }
53
+ export const unsetLink = (state, dispatch) => {
54
+ const type = markIn(state, 'link');
55
+ if (!type)
56
+ return false;
57
+ const ranges = state.selection.ranges;
58
+ if (state.selection.empty)
59
+ return false;
60
+ if (!ranges.some((r) => state.doc.rangeHasMark(r.$from.pos, r.$to.pos, type)))
61
+ return false;
62
+ if (dispatch) {
63
+ const tr = state.tr;
64
+ for (const range of ranges)
65
+ tr.removeMark(range.$from.pos, range.$to.pos, type);
66
+ dispatch(tr.scrollIntoView());
67
+ }
68
+ return true;
69
+ };
70
+ /**
71
+ * Insert an image, optionally wrapped in a captioned `<figure>`.
72
+ *
73
+ * Declines a `src` the schema would refuse, for the same reason `setLink` does:
74
+ * the parse rule only guards the way in, so an unchecked `javascript:` src is
75
+ * live in the document and submitted with the form before anything strips it.
76
+ */
77
+ export function insertImage(attrs) {
78
+ return (state, dispatch) => {
79
+ if (!isSafeUrl(attrs.src))
80
+ return false;
81
+ const imageType = nodeIn(state, 'image');
82
+ if (!imageType)
83
+ return false;
84
+ const image = imageType.create({
85
+ src: attrs.src,
86
+ // An absent alt and alt="" mean different things to a screen reader:
87
+ // "undescribed" versus "decorative". Never collapse them.
88
+ alt: attrs.alt ?? null,
89
+ title: attrs.title ?? null,
90
+ width: attrs.width ?? null,
91
+ height: attrs.height ?? null,
92
+ align: attrs.align ?? null,
93
+ className: safeClassList(attrs.className ?? null, IMAGE_ALIGN_CLASSES),
94
+ });
95
+ if (attrs.caption !== undefined && attrs.caption !== null) {
96
+ if (!canInsert(state, 'figure'))
97
+ return false;
98
+ const figureType = nodeIn(state, 'figure');
99
+ const captionType = nodeIn(state, 'figcaption');
100
+ if (!figureType || !captionType)
101
+ return false;
102
+ if (dispatch) {
103
+ const caption = attrs.caption === '' ? captionType.create() : captionType.create(null, state.schema.text(attrs.caption));
104
+ dispatch(state.tr.replaceSelectionWith(figureType.create(null, [image, caption])).scrollIntoView());
105
+ }
106
+ return true;
107
+ }
108
+ if (!canInsert(state, 'image'))
109
+ return false;
110
+ if (dispatch)
111
+ dispatch(state.tr.replaceSelectionWith(image).scrollIntoView());
112
+ return true;
113
+ };
114
+ }
115
+ /**
116
+ * The image the selection is on, or null.
117
+ *
118
+ * A `NodeSelection` on `image` counts, and so does one on a `figure` that
119
+ * contains an image -- clicking the picture and clicking the figure around it
120
+ * are the same author intent. A caret beside an image is not: treating that as
121
+ * a selection would let the dialog retarget a neighbour when the author meant
122
+ * to insert, the same trap `selectedMedia` refuses.
123
+ */
124
+ export function selectedImage(state) {
125
+ const selection = state.selection;
126
+ if (!(selection instanceof NodeSelection))
127
+ return null;
128
+ const node = selection.node;
129
+ if (node.type.name === 'image')
130
+ return describeImage(node, selection.from, state);
131
+ if (node.type.name !== 'figure')
132
+ return null;
133
+ let found = null;
134
+ node.forEach((child, offset) => {
135
+ if (found || child.type.name !== 'image')
136
+ return;
137
+ found = describeImage(child, selection.from + 1 + offset, state);
138
+ });
139
+ return found;
140
+ }
141
+ function describeImage(node, pos, state) {
142
+ const attrs = node.attrs;
143
+ const $pos = state.doc.resolve(pos);
144
+ let caption = null;
145
+ if ($pos.parent.type.name === 'figure') {
146
+ $pos.parent.forEach((child) => {
147
+ if (child.type.name === 'figcaption')
148
+ caption = child.textContent;
149
+ });
150
+ }
151
+ return {
152
+ pos,
153
+ src: attrs['src'],
154
+ alt: attrs['alt'] ?? null,
155
+ title: attrs['title'] ?? null,
156
+ width: attrs['width'] ?? null,
157
+ height: attrs['height'] ?? null,
158
+ align: attrs['align'] ?? null,
159
+ className: attrs['className'] ?? null,
160
+ caption,
161
+ };
162
+ }
163
+ /**
164
+ * Update the selected image in place.
165
+ *
166
+ * `setNodeMarkup` rather than replace-with-a-new-node: the surrounding
167
+ * `<figure>`, the author's `class`, and dimensions the dialog does not edit
168
+ * all survive a save that only changed the address or the alt text. Replacing
169
+ * the `NodeSelection` dropped every one of those, including the figcaption.
170
+ *
171
+ * Attributes omitted from `attrs` (`undefined`) stay as they were. `null` is
172
+ * an explicit clear -- except `src`, which must be a storeable address.
173
+ */
174
+ export function updateImage(attrs) {
175
+ return (state, dispatch) => {
176
+ if (!isSafeUrl(attrs.src))
177
+ return false;
178
+ const current = selectedImage(state);
179
+ if (!current)
180
+ return false;
181
+ const node = state.doc.nodeAt(current.pos);
182
+ if (!node || node.type.name !== 'image')
183
+ return false;
184
+ const next = {
185
+ ...node.attrs,
186
+ src: attrs.src,
187
+ alt: attrs.alt !== undefined ? attrs.alt ?? null : node.attrs['alt'],
188
+ title: attrs.title !== undefined ? attrs.title ?? null : node.attrs['title'],
189
+ width: attrs.width !== undefined ? attrs.width ?? null : node.attrs['width'],
190
+ height: attrs.height !== undefined ? attrs.height ?? null : node.attrs['height'],
191
+ align: attrs.align !== undefined ? attrs.align ?? null : node.attrs['align'],
192
+ className: attrs.className !== undefined
193
+ ? safeClassList(attrs.className ?? null, IMAGE_ALIGN_CLASSES)
194
+ : node.attrs['className'],
195
+ };
196
+ if (dispatch) {
197
+ const tr = state.tr.setNodeMarkup(current.pos, undefined, next);
198
+ if (attrs.caption !== undefined) {
199
+ const $pos = tr.doc.resolve(tr.mapping.map(current.pos));
200
+ if ($pos.parent.type.name === 'figure') {
201
+ const captionType = nodeIn(state, 'figcaption');
202
+ const wanted = attrs.caption ?? '';
203
+ $pos.parent.forEach((child, offset) => {
204
+ if (child.type.name !== 'figcaption' || child.textContent === wanted)
205
+ return;
206
+ if (!captionType)
207
+ return;
208
+ const from = $pos.before($pos.depth) + 1 + offset;
209
+ const content = wanted === '' ? undefined : state.schema.text(wanted);
210
+ tr.replaceWith(from, from + child.nodeSize, captionType.create(null, content));
211
+ });
212
+ }
213
+ }
214
+ const imagePos = tr.mapping.map(current.pos);
215
+ tr.setSelection(NodeSelection.create(tr.doc, imagePos)).scrollIntoView();
216
+ dispatch(tr);
217
+ }
218
+ return true;
219
+ };
220
+ }
221
+ export function insertText(text) {
222
+ return (state, dispatch) => {
223
+ if (text === '')
224
+ return false;
225
+ if (dispatch)
226
+ dispatch(state.tr.insertText(text).scrollIntoView());
227
+ return true;
228
+ };
229
+ }
230
+ export const insertNonBreakingSpace = insertText('\u00a0');
231
+ export const insertPageBreak = (state, dispatch) => {
232
+ if (!canInsert(state, 'page_break'))
233
+ return false;
234
+ if (dispatch) {
235
+ const type = nodeIn(state, 'page_break');
236
+ if (!type)
237
+ return false;
238
+ dispatch(state.tr.replaceSelectionWith(type.create()).scrollIntoView());
239
+ }
240
+ return true;
241
+ };
242
+ export function insertNamedAnchor(id) {
243
+ return (state, dispatch) => {
244
+ const value = safeId(id);
245
+ if (!value || !canInsert(state, 'named_anchor'))
246
+ return false;
247
+ if (dispatch) {
248
+ const type = nodeIn(state, 'named_anchor');
249
+ if (!type)
250
+ return false;
251
+ dispatch(state.tr.replaceSelectionWith(type.create({ id: value })).scrollIntoView());
252
+ }
253
+ return true;
254
+ };
255
+ }
256
+ export function setHeadingId(id) {
257
+ return (state, dispatch) => {
258
+ const type = nodeIn(state, 'heading');
259
+ if (!type)
260
+ return false;
261
+ const { $from } = state.selection;
262
+ for (let depth = $from.depth; depth >= 0; depth -= 1) {
263
+ const node = $from.node(depth);
264
+ if (node.type !== type)
265
+ continue;
266
+ if (dispatch) {
267
+ dispatch(state.tr
268
+ .setNodeMarkup($from.before(depth), undefined, { ...node.attrs, id: safeId(id) })
269
+ .scrollIntoView());
270
+ }
271
+ return true;
272
+ }
273
+ return false;
274
+ };
275
+ }
276
+ export function insertDetails(summaryText = 'Details') {
277
+ return (state, dispatch) => {
278
+ if (!canInsert(state, 'details'))
279
+ return false;
280
+ const detailsType = nodeIn(state, 'details');
281
+ const summaryType = nodeIn(state, 'summary');
282
+ const paragraphType = nodeIn(state, 'paragraph');
283
+ if (!detailsType || !summaryType || !paragraphType)
284
+ return false;
285
+ if (dispatch) {
286
+ const body = paragraphType.createAndFill();
287
+ if (!body)
288
+ return false;
289
+ const node = detailsType.create(null, [
290
+ summaryType.create(null, summaryText === '' ? undefined : state.schema.text(summaryText)),
291
+ body,
292
+ ]);
293
+ dispatch(state.tr.replaceSelectionWith(node).scrollIntoView());
294
+ }
295
+ return true;
296
+ };
297
+ }
298
+ /**
299
+ * Build the `furniture` string for a set of alternative sources.
300
+ *
301
+ * Built through the DOM rather than by concatenating markup: `setAttribute`
302
+ * escapes the value for us, so an address containing a quote cannot break out
303
+ * of the attribute and become new markup. `appendMediaFurniture` scrubs this
304
+ * again on the way into the document -- this is the belt, that is the braces.
305
+ */
306
+ function mediaFurniture(sources, keep = null) {
307
+ const doc = serializationTarget();
308
+ let html = '';
309
+ for (const source of sources ?? []) {
310
+ if (!isSafeUrl(source.src))
311
+ continue;
312
+ const el = doc.createElement('source');
313
+ el.setAttribute('src', source.src);
314
+ const type = source.type?.trim();
315
+ if (type)
316
+ el.setAttribute('type', type);
317
+ html += el.outerHTML;
318
+ }
319
+ // Sources first, then the carried furniture: `<source>` before `<track>` is
320
+ // the order the elements are specified in, and a browser picks its source by
321
+ // walking the children in order.
322
+ html += keep ?? '';
323
+ return html || null;
324
+ }
325
+ /**
326
+ * The furniture an edit is not entitled to rewrite.
327
+ *
328
+ * `updateMedia` rebuilds the `<source>` children from what its caller hands it,
329
+ * so anything else living in `furniture` would be deleted by a save the author
330
+ * thought was a title change. `<track>` captions are the case that matters: a
331
+ * dialog has no field for them, nobody notices they are gone, and the loss is
332
+ * of the accessibility furniture specifically.
333
+ *
334
+ * So the non-`<source>` children are read off the node and appended unchanged.
335
+ * They came out of `readMediaFurniture`, which already scrubbed them, and
336
+ * `appendMediaFurniture` scrubs them again on the way back in.
337
+ */
338
+ function carriedFurniture(furniture) {
339
+ if (typeof furniture !== 'string' || furniture === '')
340
+ return null;
341
+ const doc = serializationTarget();
342
+ const tpl = doc.createElement('template');
343
+ tpl.innerHTML = furniture;
344
+ let html = '';
345
+ for (const el of Array.from(tpl.content.children)) {
346
+ if (el.nodeName.toLowerCase() === 'source')
347
+ continue;
348
+ html += el.outerHTML;
349
+ }
350
+ return html || null;
351
+ }
352
+ /**
353
+ * Does this player have anything to play?
354
+ *
355
+ * The schema declines a `<video>` with neither `src` nor sources, so a command
356
+ * that builds one would insert a node the next parse throws away.
357
+ */
358
+ function playable(attrs, furniture) {
359
+ if (furniture !== null)
360
+ return true;
361
+ return typeof attrs.src === 'string' && isSafeUrl(attrs.src);
362
+ }
363
+ export function insertVideo(attrs) {
364
+ return (state, dispatch) => {
365
+ const furniture = mediaFurniture(attrs.sources);
366
+ if (!playable(attrs, furniture) || !canInsert(state, 'video'))
367
+ return false;
368
+ if (dispatch) {
369
+ const type = nodeIn(state, 'video');
370
+ if (!type)
371
+ return false;
372
+ dispatch(state.tr
373
+ .replaceSelectionWith(type.create({
374
+ src: attrs.src && isSafeUrl(attrs.src) ? attrs.src : null,
375
+ furniture,
376
+ title: attrs.title ?? null,
377
+ width: attrs.width ?? null,
378
+ height: attrs.height ?? null,
379
+ controls: attrs.controls !== false,
380
+ poster: attrs.poster && isSafeUrl(attrs.poster) ? attrs.poster : null,
381
+ }))
382
+ .scrollIntoView());
383
+ }
384
+ return true;
385
+ };
386
+ }
387
+ export function insertAudio(attrs) {
388
+ return (state, dispatch) => {
389
+ const furniture = mediaFurniture(attrs.sources);
390
+ if (!playable(attrs, furniture) || !canInsert(state, 'audio'))
391
+ return false;
392
+ if (dispatch) {
393
+ const type = nodeIn(state, 'audio');
394
+ if (!type)
395
+ return false;
396
+ dispatch(state.tr
397
+ .replaceSelectionWith(type.create({
398
+ src: attrs.src && isSafeUrl(attrs.src) ? attrs.src : null,
399
+ furniture,
400
+ title: attrs.title ?? null,
401
+ controls: attrs.controls !== false,
402
+ }))
403
+ .scrollIntoView());
404
+ }
405
+ return true;
406
+ };
407
+ }
408
+ /** The media node kinds the insert-media dialog can round-trip. */
409
+ const MEDIA_KINDS = new Set(['video', 'audio', 'iframe']);
410
+ /**
411
+ * The media node the selection is on, or null.
412
+ *
413
+ * Only a `NodeSelection` counts. A caret beside a player is not a selection of
414
+ * it, and treating it as one would let the dialog silently retarget: the author
415
+ * clicks away, opens the dialog expecting to insert, and edits the node they
416
+ * had selected a moment ago instead.
417
+ */
418
+ export function selectedMedia(state) {
419
+ const selection = state.selection;
420
+ if (!(selection instanceof NodeSelection))
421
+ return null;
422
+ const node = selection.node;
423
+ const name = node.type.name;
424
+ if (!MEDIA_KINDS.has(name))
425
+ return null;
426
+ const attrs = node.attrs;
427
+ return {
428
+ kind: name,
429
+ pos: selection.from,
430
+ src: attrs['src'] ?? null,
431
+ title: attrs['title'] ?? null,
432
+ width: attrs['width'] ?? null,
433
+ height: attrs['height'] ?? null,
434
+ controls: attrs['controls'] === true,
435
+ poster: attrs['poster'] ?? null,
436
+ sources: readMediaSources(attrs['furniture']),
437
+ };
438
+ }
439
+ /**
440
+ * Read stored furniture back into dialog rows.
441
+ *
442
+ * Parsed rather than regexed: the string is markup, and the dialog has to show
443
+ * the author the same addresses the document will play.
444
+ */
445
+ function readMediaSources(furniture) {
446
+ if (!furniture)
447
+ return [];
448
+ const doc = serializationTarget();
449
+ const tpl = doc.createElement('template');
450
+ tpl.innerHTML = furniture;
451
+ const out = [];
452
+ for (const el of Array.from(tpl.content.children)) {
453
+ if (el.nodeName.toLowerCase() !== 'source')
454
+ continue;
455
+ const src = el.getAttribute('src');
456
+ if (src === null)
457
+ continue;
458
+ out.push({ src, type: el.getAttribute('type') });
459
+ }
460
+ return out;
461
+ }
462
+ /**
463
+ * Update the selected media node in place.
464
+ *
465
+ * `setNodeMarkup` rather than replace-with-a-new-node: the position and the
466
+ * selection both survive, so the player the author was editing is still the
467
+ * selected one afterwards and a second edit does not have to find it again.
468
+ */
469
+ export function updateMedia(attrs) {
470
+ return (state, dispatch) => {
471
+ const current = selectedMedia(state);
472
+ if (!current)
473
+ return false;
474
+ const node = state.doc.nodeAt(current.pos);
475
+ if (!node)
476
+ return false;
477
+ const furniture = current.kind === 'iframe'
478
+ ? null
479
+ : mediaFurniture(attrs.sources, carriedFurniture(node.attrs['furniture']));
480
+ // An iframe has no `<source>` children, so its address is the only thing it
481
+ // can play and an unsafe one leaves nothing to fall back to. Converted the
482
+ // same way the insert path converts it: an author editing a player is
483
+ // holding the same watch-page URL as an author inserting one, and refusing
484
+ // it here made the edit a silent no-op.
485
+ const embed = current.kind === 'iframe' ? embedSrcFor(attrs.src) : null;
486
+ if (current.kind === 'iframe') {
487
+ if (!embed)
488
+ return false;
489
+ }
490
+ else if (!playable(attrs, furniture))
491
+ return false;
492
+ if (dispatch) {
493
+ const next = { ...node.attrs };
494
+ if (current.kind === 'iframe') {
495
+ next['src'] = embed;
496
+ }
497
+ else {
498
+ next['src'] = attrs.src && isSafeUrl(attrs.src) ? attrs.src : null;
499
+ next['furniture'] = furniture;
500
+ }
501
+ next['title'] = attrs.title ?? null;
502
+ // `undefined` is "as it was", not "on". A dialog with no controls field
503
+ // passes nothing, and defaulting that to on gave a control bar to every
504
+ // controls-less player whose title someone edited.
505
+ if ('controls' in node.attrs && attrs.controls !== undefined) {
506
+ next['controls'] = attrs.controls;
507
+ }
508
+ if ('width' in node.attrs)
509
+ next['width'] = attrs.width ?? null;
510
+ if ('height' in node.attrs)
511
+ next['height'] = attrs.height ?? null;
512
+ if ('poster' in node.attrs) {
513
+ next['poster'] = attrs.poster && isSafeUrl(attrs.poster) ? attrs.poster : null;
514
+ }
515
+ dispatch(state.tr.setNodeMarkup(current.pos, undefined, next));
516
+ }
517
+ return true;
518
+ };
519
+ }
520
+ export function insertIframe(attrs) {
521
+ return (state, dispatch) => {
522
+ const src = safeEmbedSrc(attrs.src);
523
+ if (!src || !canInsert(state, 'iframe'))
524
+ return false;
525
+ if (dispatch) {
526
+ const type = nodeIn(state, 'iframe');
527
+ if (!type)
528
+ return false;
529
+ dispatch(state.tr
530
+ .replaceSelectionWith(type.create({
531
+ src,
532
+ title: attrs.title ?? null,
533
+ width: attrs.width ?? null,
534
+ height: attrs.height ?? null,
535
+ allow: safeAllowList(attrs.allow),
536
+ allowfullscreen: attrs.allowfullscreen !== false,
537
+ }))
538
+ .scrollIntoView());
539
+ }
540
+ return true;
541
+ };
542
+ }
543
+ /**
544
+ * Parse HTML against the live schema and insert it.
545
+ *
546
+ * Used by the snippet picker. The HTML still goes through the same parse
547
+ * pipeline as stored content, so a snippet cannot smuggle in a `<script>`.
548
+ */
549
+ export function insertHtml(html) {
550
+ return (state, dispatch) => {
551
+ const parsed = parseHtml(html, { schema: state.schema });
552
+ if (parsed.childCount === 0)
553
+ return false;
554
+ if (dispatch) {
555
+ dispatch(state.tr.replaceSelection(new Slice(parsed.content, 0, 0)).scrollIntoView());
556
+ }
557
+ return true;
558
+ };
559
+ }
560
+ //# sourceMappingURL=insert-commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-commands.js","sourceRoot":"","sources":["../src/insert-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAa,MAAM,mBAAmB,CAAA;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,EAAmB,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,MAAM,SAAS,GAAG,aAAa,CAAA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C,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAA;QACvF,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Keep a `TextSelection` from straddling an isolating boundary.
3
+ *
4
+ * `isolating: true` already means ProseMirror will not join or lift across that
5
+ * node. `Selection.near` honours it when *finding* a caret; `TextSelection.between`
6
+ * does not when *building* a range, so Firefox and WebKit can report a selection
7
+ * that starts in a `<blockquote>` and ends in a following `<details>`. Typing
8
+ * then runs `replaceSelection`, which tries to nest the leftover `details` in
9
+ * the quote (legal: `blockquote` is `block+`, `details` is `group: 'block'`) and
10
+ * join, and `content: 'summary block+'` refuses with `TransformError`.
11
+ *
12
+ * The throw escapes the input handler. ProseMirror re-derives the document from
13
+ * the DOM, history never sees a step, and Ctrl+Z cannot undo the mangling.
14
+ *
15
+ * Chromium already clamps at the isolating boundary natively. This plugin does
16
+ * the same for every isolating node, not just `details`: after a transaction,
17
+ * a crossing `TextSelection` is narrowed to the side the anchor sits on. Input
18
+ * handlers also refuse to let a throwing replace run, so even a race with the
19
+ * native selection cannot rewrite the document outside history.
20
+ *
21
+ * `handleTextInput` is not enough on its own. When the model selection is still
22
+ * a collapsed caret, ProseMirror never calls it, and Chromium applies the
23
+ * keystroke to the *DOM* range — which can still straddle `details`. That path
24
+ * emptied `<summary>` and lifted the body out of `<details>` on a subset of
25
+ * Shift+ArrowDown runs (#163). `beforeinput` fires for every input type before
26
+ * any mutation, so it can read the DOM range (via `posAtDOM`; `state.selection`
27
+ * is untrustworthy in that tick) and apply the clamped edit itself.
28
+ *
29
+ * `CellSelection` / `AllSelection` / `NodeSelection` are left alone. Select-all
30
+ * is an `AllSelection` in the base keymap; a `TextSelection` that merely
31
+ * contains a whole isolating node (both endpoints outside it) is not crossing.
32
+ */
33
+ import type { Node as PMNode, ResolvedPos } from 'prosemirror-model';
34
+ import { Plugin, TextSelection, type Selection } from 'prosemirror-state';
35
+ /** Depth of the innermost isolating ancestor, or 0 if the pos sits in none. */
36
+ export declare function innermostIsolatingDepth($pos: ResolvedPos): number;
37
+ /**
38
+ * True when the endpoints do not share an isolating ancestor: one is inside a
39
+ * given isolating node and the other is not (or is inside a different one).
40
+ */
41
+ export declare function textSelectionCrossesIsolating(selection: Selection): boolean;
42
+ /**
43
+ * Narrow a crossing text selection to the isolating context that contains the
44
+ * anchor, or to just outside the isolating node that contains the head when the
45
+ * anchor itself sits in none. Same-context selections are returned unchanged.
46
+ */
47
+ export declare function clampIsolatingTextSelection(selection: TextSelection): TextSelection;
48
+ /**
49
+ * Given a DOM-derived (anchor, head) pair — not necessarily `state.selection` —
50
+ * return the range a keystroke must replace so the edit stays on one side of an
51
+ * isolating boundary. `null` means the range does not cross and the default
52
+ * editor path should run.
53
+ */
54
+ export declare function clampIsolatingReplaceRange(doc: PMNode, anchor: number, head: number): {
55
+ from: number;
56
+ to: number;
57
+ } | null;
58
+ export declare function isolatingSelectionPlugin(): Plugin;
59
+ //# sourceMappingURL=isolating-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isolating-selection.d.ts","sourceRoot":"","sources":["../src/isolating-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,MAAM,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,MAAM,EAAa,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAKpF,+EAA+E;AAC/E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAKjE;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAG3E;AAUD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,aAAa,GAAG,aAAa,CA4BnF;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAiBrC;AA4DD,wBAAgB,wBAAwB,IAAI,MAAM,CA6DjD"}