foldkit-richtext-dom 0.4.0 → 0.5.0

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 (43) hide show
  1. package/README.md +100 -29
  2. package/dist/editor-bundle.d.mts +1659 -79
  3. package/dist/editor-bundle.d.mts.map +1 -1
  4. package/dist/editor-bundle.mjs +114 -10
  5. package/dist/editor-bundle.mjs.map +1 -1
  6. package/dist/{editor-DbYswARG.d.mts → editor-gCZiXgG4.d.mts} +406 -11
  7. package/dist/editor-gCZiXgG4.d.mts.map +1 -0
  8. package/dist/editor.d.mts +2 -2
  9. package/dist/editor.mjs +179 -25
  10. package/dist/editor.mjs.map +1 -1
  11. package/dist/{events-Dasls6a_.d.mts → events-DLi6ecvD.d.mts} +20 -5
  12. package/dist/events-DLi6ecvD.d.mts.map +1 -0
  13. package/dist/events.d.mts +1 -1
  14. package/dist/events.mjs +334 -15
  15. package/dist/events.mjs.map +1 -1
  16. package/dist/filler-D2_wc_8Z.mjs +8 -0
  17. package/dist/filler-D2_wc_8Z.mjs.map +1 -0
  18. package/dist/{host-1dtxuKIA.d.mts → host-Cp2Zz-bO.d.mts} +27 -8
  19. package/dist/host-Cp2Zz-bO.d.mts.map +1 -0
  20. package/dist/host.d.mts +2 -2
  21. package/dist/host.mjs +25 -8
  22. package/dist/host.mjs.map +1 -1
  23. package/dist/html.d.mts.map +1 -1
  24. package/dist/html.mjs +2 -0
  25. package/dist/html.mjs.map +1 -1
  26. package/dist/index-DDV_JesZ.d.mts.map +1 -1
  27. package/dist/index.mjs +52 -19
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/input.d.mts +259 -3
  30. package/dist/input.d.mts.map +1 -1
  31. package/dist/input.mjs +2 -1
  32. package/dist/input.mjs.map +1 -1
  33. package/dist/toolbar.d.mts +7 -0
  34. package/dist/toolbar.d.mts.map +1 -1
  35. package/dist/toolbar.mjs +135 -14
  36. package/dist/toolbar.mjs.map +1 -1
  37. package/dist/view.d.mts.map +1 -1
  38. package/dist/view.mjs +26 -2
  39. package/dist/view.mjs.map +1 -1
  40. package/package.json +7 -7
  41. package/dist/editor-DbYswARG.d.mts.map +0 -1
  42. package/dist/events-Dasls6a_.d.mts.map +0 -1
  43. package/dist/host-1dtxuKIA.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"editor-bundle.d.mts","names":[],"sources":["../src/editor-bundle.ts"],"mappings":";;;;;;;;;;;qBA6Ca,aAAW,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBZ,qBAAqB,YAAY;qBAEhC,OAAK,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAGN,SAAM,SAAa,YAAU;qBAC7B,QAAK,iBAAmB;qBACxB,UAAO,oDAAsD;qBAE7D,UAAO,iBAAmB;qBAC1B,UAAO,MAAU,SAAS,YAAU;qBAEpC,UAAO,iBAAmB;qBAC1B,UAAO,OAAW,SAAS,cAAY;qBAEvC,UAAO,YAAgB,cAAc,SAAS,eAAa;qBAE3D,YAAS,IAAQ,SAAS,cAAY;qBAEtC,cAAa;qBACb,QAAK,MAAU,SAAS,QAAM,IAAM,SAAS,WAAS;qBAEtD,WAAQ,OAAW,SAAS,OAAK,KAAO,SAAS,WAAS;qBAE1D,UAAO,MAAU,SAAS,WAAS;qBAEnC,eAAY,MAAU,SAAS,QAAM,OAAS,OAAO,eAAa;qBAElE,WAAQ,WAAe,SAAS,qBAAmB;qBAEnD,cAAa;qBACb,cAAa;qBACb,eAAc"}
@@ -1,5 +1,5 @@
1
- import { decorationsFor, inputRulesFor, placeDecorations, placeInputRules, placeOverlay, placePlaceholder, placeRendering, placeServerRendered, placeVocabulary, renderingFor, serverRenderedFor, vocabularyFor } from "./host.mjs";
2
- import { Message, events, heldDocument, patchEditor, redecorateEditor, slashEntries, slashMenu } from "./editor.mjs";
1
+ import { decorationsFor, inputRulesFor, placeDecorations, placeInputRules, placeKeymap, placeOverlay, placePlaceholders, placeRendering, placeServerRendered, placeSlashEntries, placeVocabulary, renderingFor, serverRenderedFor, slashEntriesFor, vocabularyFor } from "./host.mjs";
2
+ import { Message, events, focusEditor, heldDocument, patchEditor, redecorateEditor, slashEntries, slashMenu, slashQuery } from "./editor.mjs";
3
3
  import { renderEditable } from "./view.mjs";
4
4
  import * as RichText from "foldkit-richtext";
5
5
  import { Effect, Equal, Match, Option, Schema } from "effect";
@@ -32,6 +32,8 @@ const EditorState = Schema.Struct({
32
32
  * `update` resolves Enter against it.
33
33
  */
34
34
  menuIndex: Schema.Number,
35
+ /** The slash of the query whose menu Escape closed; it stays closed until that query ends. */
36
+ slashDismissed: Schema.OptionFromNullOr(RichText.Position),
35
37
  /**
36
38
  * The host element the view renders and the patch Command finds (§118). It is
37
39
  * per-placement, so it arrives as the Bundle's args and is carried here
@@ -51,6 +53,7 @@ const EditorView = Schema.Struct({
51
53
  history: RichText.History,
52
54
  storedMarks: Schema.NullOr(Schema.Array(Schema.String)),
53
55
  menuIndex: Schema.Number,
56
+ slashDismissed: Schema.OptionFromNullOr(RichText.Position),
54
57
  hostId: Schema.String
55
58
  });
56
59
  /** Every block and run of a document by id, nested ones included, with where it stands. */
@@ -164,6 +167,48 @@ const toCommand = (message) => {
164
167
  node: message.node,
165
168
  to: message.to
166
169
  };
170
+ case "InsertedBlock": return {
171
+ type: "InsertBlock",
172
+ block: message.block,
173
+ to: message.to
174
+ };
175
+ case "DeletedBlock": return {
176
+ type: "DeleteBlock",
177
+ node: message.node
178
+ };
179
+ case "ChangedProps": return {
180
+ type: "SetProps",
181
+ node: message.node,
182
+ props: message.props
183
+ };
184
+ case "InsertedRow": return {
185
+ type: "InsertRow",
186
+ where: message.where
187
+ };
188
+ case "InsertedColumn": return {
189
+ type: "InsertColumn",
190
+ where: message.where
191
+ };
192
+ case "DeletedRow": return { type: "DeleteRow" };
193
+ case "DeletedColumn": return { type: "DeleteColumn" };
194
+ case "Indented": return { type: "Indent" };
195
+ case "ReplacedText": return {
196
+ type: "Replace",
197
+ query: message.query,
198
+ replacement: message.replacement,
199
+ caseSensitive: message.caseSensitive,
200
+ at: message.at
201
+ };
202
+ case "InsertedFootnote": return {
203
+ type: "InsertFootnote",
204
+ text: message.text
205
+ };
206
+ case "RenamedFootnote": return {
207
+ type: "RenameFootnote",
208
+ from: message.from,
209
+ to: message.to
210
+ };
211
+ case "Outdented": return { type: "Outdent" };
167
212
  case "Selected": return {
168
213
  type: "SetSelection",
169
214
  selection: message.selection
@@ -196,6 +241,21 @@ const textBeforeOf = (model) => {
196
241
  const start = RichText.rangeStart(model.document, model.selection);
197
242
  return start === void 0 ? "" : RichText.textBefore(model.document, start);
198
243
  };
244
+ /** Where the slash of the caret's live query is: none outside a query. */
245
+ const slashOf = (model) => {
246
+ const query = slashQuery(textBeforeOf(model));
247
+ if (query === void 0 || model.selection?.type !== "Range") return Option.none();
248
+ const start = RichText.rangeStart(model.document, model.selection);
249
+ const range = start === void 0 ? void 0 : RichText.textRangeBefore(model.document, start, query.length + 1);
250
+ return range?.type === "Range" ? Option.some(range.anchor) : Option.none();
251
+ };
252
+ const dismissed = (model) => Option.exists(model.slashDismissed, (slash) => Option.exists(slashOf(model), (live) => live.node === slash.node && live.offset === slash.offset));
253
+ /**
254
+ * The text a slash menu reads: the text before the caret, or nothing once Escape has closed
255
+ * the menu of the query the caret is in. Enter resolves against it, and an application's menu
256
+ * view reads it too, so the two agree on whether a menu is open.
257
+ */
258
+ const menuTextOf = (model) => dismissed(model) ? "" : textBeforeOf(model);
199
259
  /**
200
260
  * The kinds of the node blocks around the caret's block, innermost first; a range is read
201
261
  * from its start, as `textBeforeOf` reads it.
@@ -288,6 +348,15 @@ const overlay = (hostId, decorations) => ({
288
348
  }), Message.Patched())
289
349
  });
290
350
  /**
351
+ * Focuses the editor at `hostId` with `selection` in the browser, brought into view: for a
352
+ * control outside the editor that sends the reader into the text, such as a table of contents.
353
+ * The browser reports the selection back as `Selected`, so the Model follows it either way.
354
+ */
355
+ const focus = (hostId, selection) => ({
356
+ name: "RichText.focus",
357
+ effect: Effect.as(Effect.sync(() => focusEditor(hostId, selection)), Message.Patched())
358
+ });
359
+ /**
291
360
  * The host element the editor mounts into, and whose id the patch Command finds (§118). It is a
292
361
  * custom element so hydration leaves what is inside it alone (§145): on the server it holds the
293
362
  * document's markup, which the editor adopts; in the browser the view declares it empty, and the
@@ -310,10 +379,18 @@ const transition = (model, incoming) => {
310
379
  selection: model.selection
311
380
  };
312
381
  const vocabulary = vocabularyFor(model.hostId);
313
- const menu = incoming._tag === "Entered" ? slashMenu(slashEntries, textBeforeOf(model), model.menuIndex) : void 0;
382
+ const menu = incoming._tag === "Entered" ? slashMenu(slashEntriesFor(model.hostId) ?? slashEntries, menuTextOf(model), model.menuIndex) : void 0;
314
383
  const message = menu?.highlighted?.message ?? incoming;
315
384
  return Match.value(message).pipe(Match.withReturnType(), Match.tags({
316
385
  Patched: () => ({ model }),
386
+ ActivatedAdornment: () => ({ model }),
387
+ DismissedSlash: () => {
388
+ const slash = slashOf(model);
389
+ return Option.isNone(slash) || dismissed(model) ? { model } : { model: {
390
+ ...model,
391
+ slashDismissed: slash
392
+ } };
393
+ },
317
394
  Undone: (undone) => travel(model, state, undone),
318
395
  Redone: (redone) => travel(model, state, redone)
319
396
  }), Match.orElse((message) => {
@@ -337,7 +414,7 @@ const transition = (model, incoming) => {
337
414
  marks: vocabulary.marks,
338
415
  nodes: vocabulary.nodes
339
416
  });
340
- const ruled = queryRange === void 0 && message._tag === "Typed" ? RichText.applyInputRules(inputRulesFor(model.hostId), {
417
+ const ruled = queryRange === void 0 && message._tag === "Typed" ? RichText.resolveInputRules(inputRulesFor(model.hostId), {
341
418
  textBefore: textBeforeOf(model),
342
419
  text: message.text,
343
420
  insertion: command,
@@ -350,7 +427,7 @@ const transition = (model, incoming) => {
350
427
  },
351
428
  { type: "DeleteBackward" },
352
429
  command
353
- ] : ruled ?? [command]);
430
+ ] : ruled?.action ?? [command]);
354
431
  const fallback = !attempt.ok && ruled !== void 0;
355
432
  if (fallback) nextId = model.nextId;
356
433
  const result = fallback ? runAction([command]) : attempt;
@@ -368,7 +445,7 @@ const transition = (model, incoming) => {
368
445
  ...model,
369
446
  selection: result.state.selection,
370
447
  nextId,
371
- storedMarks: message._tag === "Selected" ? null : storedMarks,
448
+ storedMarks: message._tag === "Selected" ? null : (fallback ? void 0 : ruled?.storedMarks) ?? storedMarks,
372
449
  history: contentChanged ? RichText.commit(model.history, state, { group: RichText.groupFor(command) }) : model.history
373
450
  },
374
451
  outMessage: {
@@ -421,13 +498,25 @@ const Editor = Bundle.make({
421
498
  history: RichText.emptyHistory,
422
499
  storedMarks: null,
423
500
  menuIndex: 0,
501
+ slashDismissed: Option.none(),
424
502
  hostId: args.hostId
425
503
  } }),
426
504
  update: (model, incoming) => {
427
505
  const result = transition(model, incoming);
428
506
  const out = result.outMessage;
429
- if (out?._tag === "Edited" || out?._tag === "Replaced") carryKey(model.hostId, model.document, out.state.document);
430
- return result;
507
+ const committed = out !== void 0 && "state" in out ? out.state : void 0;
508
+ if (committed !== void 0) carryKey(model.hostId, model.document, committed.document);
509
+ const after = {
510
+ ...result.model,
511
+ document: committed?.document ?? result.model.document
512
+ };
513
+ return Option.isSome(result.model.slashDismissed) && !dismissed(after) ? {
514
+ ...result,
515
+ model: {
516
+ ...result.model,
517
+ slashDismissed: Option.none()
518
+ }
519
+ } : result;
431
520
  },
432
521
  view: editorView
433
522
  });
@@ -441,6 +530,7 @@ const editorLink = Link.make({
441
530
  history: parent.editor.history,
442
531
  storedMarks: parent.editor.storedMarks,
443
532
  menuIndex: parent.editor.menuIndex,
533
+ slashDismissed: parent.editor.slashDismissed,
444
534
  hostId: parent.editor.hostId
445
535
  }),
446
536
  write: (parent, { document: _document, ...editor }) => {
@@ -463,7 +553,12 @@ const placeEditor = (hostId, placement) => {
463
553
  placeInputRules(hostId, placement.inputRules ?? []);
464
554
  placeDecorations(hostId, placement.decorate ?? (() => []));
465
555
  placeOverlay(hostId, []);
466
- placePlaceholder(hostId, placement.placeholder);
556
+ placePlaceholders(hostId, {
557
+ placeholder: placement.placeholder,
558
+ lineHint: placement.lineHint
559
+ });
560
+ placeSlashEntries(hostId, placement.slashEntries);
561
+ placeKeymap(hostId, placement.keymap ?? []);
467
562
  placeServerRendered(hostId, placement.serverRendered ?? (() => false));
468
563
  };
469
564
  /**
@@ -504,11 +599,20 @@ const moved = (node, to) => edited(Message.MovedBlock({
504
599
  node,
505
600
  to
506
601
  }));
602
+ const inserted = (block, to) => edited(Message.InsertedBlock(to === void 0 ? { block } : {
603
+ block,
604
+ to
605
+ }));
606
+ const deleted = (node) => edited(Message.DeletedBlock({ node }));
607
+ const changedProps = (node, props) => edited(Message.ChangedProps({
608
+ node,
609
+ props
610
+ }));
507
611
  const selected = (selection) => edited(Message.Selected({ selection }));
508
612
  const undone = () => edited(Message.Undone());
509
613
  const redone = () => edited(Message.Redone());
510
614
  const patched = () => edited(Message.Patched());
511
615
  //#endregion
512
- export { Editor, EditorState, EditorView, Model, ParentMessage, application, applied, cleared, converted, edited, editor, editorAt, editorView, lifted, moved, overlay, patchTo, patched, placeEditor, pressed, redone, replaceChangeSet, retyped, selected, toggled, typed, undone, update, wrapped };
616
+ export { Editor, EditorState, EditorView, Model, ParentMessage, application, applied, changedProps, cleared, converted, deleted, edited, editor, editorAt, editorView, focus, inserted, lifted, menuTextOf, moved, overlay, patchTo, patched, placeEditor, pressed, redone, replaceChangeSet, retyped, selected, toggled, typed, undone, update, wrapped };
513
617
 
514
618
  //# sourceMappingURL=editor-bundle.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor-bundle.mjs","names":[],"sources":["../src/editor-bundle.ts"],"sourcesContent":["/**\n * The controlled-editor feasibility harness (§27): the authoritative Document\n * lives in the parent Model, the editor Bundle reads it through its Link, and a\n * single parent transition commits both the document and the interaction state.\n *\n * No DOM, no persistence, no collaboration: this exists to answer whether Bundle\n * ownership can hold a rich-text editor without a second synchronized document\n * copy or a Command that commits half the transition.\n */\nimport { Effect, Equal, Match, Option, Schema } from 'effect'\nimport { define } from 'foldkit/customElement'\nimport { defineMessageUnion } from 'foldkit/message'\nimport { Bundle, Link, type Wrapped } from 'foldkit-bundle'\nimport * as RichText from 'foldkit-richtext'\nimport * as Submodel from 'foldkit/submodel'\nimport type * as Command from 'foldkit/command'\nimport type * as Update from 'foldkit/update'\nimport {\n heldDocument,\n events,\n Message,\n patchEditor,\n redecorateEditor,\n slashEntries,\n slashMenu,\n} from './editor.js'\nimport {\n decorationsFor,\n inputRulesFor,\n placeDecorations,\n placeInputRules,\n placeOverlay,\n placePlaceholder,\n placeRendering,\n placeServerRendered,\n placeVocabulary,\n renderingFor,\n serverRenderedFor,\n type Vocabulary,\n vocabularyFor,\n} from './host.js'\nimport type { Decorate } from './events.js'\nimport { renderEditable } from './view.js'\n\n/** Interaction state the parent owns beside the document. */\nexport const EditorState = Schema.Struct({\n selection: Schema.NullOr(RichText.Selection),\n /** Caller-owned identity source: a live edit mints, replay never does. */\n nextId: Schema.Number,\n /** Local undo history: snapshots of document plus selection. */\n history: RichText.History,\n /** Null inherits neighboring marks; an array explicitly sets them, even when empty. */\n storedMarks: Schema.NullOr(Schema.Array(Schema.String)),\n /**\n * The highlighted entry in a live slash menu (§123). The document says whether the\n * caret is in a query and what matches; this is the one thing the menu owns, and\n * `update` resolves Enter against it.\n */\n menuIndex: Schema.Number,\n /**\n * The host element the view renders and the patch Command finds (§118). It is\n * per-placement, so it arrives as the Bundle's args and is carried here\n * because `read` re-projects the whole child from the parent.\n */\n hostId: Schema.String,\n})\nexport type EditorState = typeof EditorState.Type\n\nexport const Model = Schema.Struct({\n document: RichText.Document,\n editor: EditorState,\n})\nexport type Model = typeof Model.Type\n\n/** What the child reads: the parent's document passes through, never stored. */\nexport const EditorView = Schema.Struct({\n document: RichText.Document,\n selection: Schema.NullOr(RichText.Selection),\n nextId: Schema.Number,\n history: RichText.History,\n storedMarks: Schema.NullOr(Schema.Array(Schema.String)),\n menuIndex: Schema.Number,\n hostId: Schema.String,\n})\nexport type EditorView = typeof EditorView.Type\n\n/** The committed edit, or the diagnostic that refused it. */\nexport type OutMessage =\n | {\n readonly _tag: 'Edited'\n readonly state: RichText.EditorState\n readonly changeSet: RichText.ChangeSet\n /** What the edit applied, in order, as `RichText.run` returns them. */\n readonly transactions: ReadonlyArray<RichText.Transaction>\n }\n | {\n /** Undo and redo replace the document wholesale; nothing was incremental. */\n readonly _tag: 'Replaced'\n readonly state: RichText.EditorState\n readonly changeSet: RichText.ChangeSet\n }\n | { readonly _tag: 'Rejected'; readonly error: string }\n\n/** Where a node stands: the block holding it (null at the top), and its index there. */\ninterface Placed {\n readonly node: RichText.Block | RichText.Text\n readonly parent: RichText.NodeId | null\n readonly index: number\n}\n\n/** Every block and run of a document by id, nested ones included, with where it stands. */\nconst nodesOf = (content: RichText.Document): ReadonlyMap<RichText.NodeId, Placed> => {\n const nodes = new Map<RichText.NodeId, Placed>()\n const visit = (blocks: ReadonlyArray<RichText.Block>, parent: RichText.NodeId | null): void => {\n for (const [index, block] of blocks.entries()) {\n nodes.set(block.id, { node: block, parent, index })\n for (const [at, run] of block.children.entries()) {\n nodes.set(run.id, { node: run, parent: block.id, index: at })\n }\n if (block.type === 'Node' && block.blocks !== undefined) visit(block.blocks, block.id)\n }\n }\n visit(content.children, null)\n return nodes\n}\n\nconst sameMarks = (left: RichText.Text, right: RichText.Text): boolean =>\n left.marks.length === right.marks.length &&\n left.marks.every((mark, index) => RichText.sameMark(mark, right.marks[index]!))\n\n/** A block's own fields, apart from what it holds: its type, level, kind and props. */\nconst ownFields = ({ children: _runs, ...block }: RichText.Block): unknown => ({\n ...block,\n blocks: undefined,\n})\n\n/**\n * What differs between two whole documents, for a patch from one to the other, in a\n * transaction's terms: the runs whose text or marks changed and the blocks holding them,\n * blocks whose own fields changed, what came and went, and whether any block moved.\n */\nexport const replaceChangeSet = (\n previous: RichText.Document,\n next: RichText.Document,\n): RichText.ChangeSet => {\n const before = nodesOf(previous)\n const after = nodesOf(next)\n const dirtyNodes = new Set<RichText.NodeId>()\n const textChanged = new Set<RichText.NodeId>()\n let structureChanged = false\n for (const [id, placed] of after) {\n const was = before.get(id)\n if (placed.node.type === 'Text') {\n const run = placed.node\n const old = was?.node.type === 'Text' ? was.node : undefined\n if (old === undefined || old.text !== run.text) textChanged.add(id)\n if (old === undefined || old.text !== run.text || !sameMarks(old, run)) {\n dirtyNodes.add(id)\n if (placed.parent !== null) dirtyNodes.add(placed.parent)\n }\n // A run moved to another block, or to another place in its own, changes both blocks'\n // runs though the run itself did not change.\n if (was !== undefined && (was.parent !== placed.parent || was.index !== placed.index)) {\n if (placed.parent !== null) dirtyNodes.add(placed.parent)\n if (was.parent !== null && after.has(was.parent)) dirtyNodes.add(was.parent)\n }\n continue\n }\n if (was === undefined || was.parent !== placed.parent || was.index !== placed.index) {\n structureChanged = true\n }\n if (\n was === undefined ||\n !Equal.equals(ownFields(was.node as RichText.Block), ownFields(placed.node))\n ) {\n dirtyNodes.add(id)\n }\n }\n const removedNodes = new Set([...before.keys()].filter(id => !after.has(id)))\n for (const id of removedNodes) {\n const was = before.get(id)!\n if (was.node.type !== 'Text') structureChanged = true\n else if (was.parent !== null && after.has(was.parent)) dirtyNodes.add(was.parent)\n }\n return {\n dirtyNodes,\n insertedNodes: new Set([...after.keys()].filter(id => !before.has(id))),\n removedNodes,\n textChanged,\n structureChanged,\n selectionChanged: false,\n }\n}\n\ntype CommandMessage = Exclude<Message, { readonly _tag: 'Undone' | 'Redone' | 'Patched' }>\n\nconst toCommand = (message: CommandMessage): RichText.Command => {\n switch (message._tag) {\n case 'Typed':\n return { type: 'InsertText', text: message.text }\n case 'Backspace':\n return { type: 'DeleteBackward' }\n case 'DeletedForward':\n return { type: 'DeleteForward' }\n case 'Entered':\n return { type: 'SplitBlock' }\n case 'ToggledMark':\n return { type: 'ToggleMark', mark: message.mark }\n case 'AppliedMark':\n return { type: 'SetMark', mark: message.mark }\n case 'ClearedMark':\n return { type: 'ClearMark', mark: message.mark }\n case 'RetypedBlock':\n return { type: 'RetypeBlock', to: message.block }\n case 'WrappedBlock':\n return { type: 'WrapBlock', containers: message.containers }\n case 'ConvertedBlock':\n return { type: 'ConvertBlock', to: message.to }\n case 'LiftedBlock':\n return { type: 'LiftBlock' }\n case 'MovedBlock':\n return { type: 'MoveBlock', node: message.node, to: message.to }\n case 'Selected':\n return { type: 'SetSelection', selection: message.selection }\n case 'Pasted':\n return { type: 'Paste', slice: message.slice }\n }\n}\n\n/**\n * The rendering effect (§118): patch the host the view rendered, once the\n * parent's transition has committed. It commits nothing, so the one-transition\n * property the proof established is untouched.\n */\nconst patch = (hostId: string, state: RichText.EditorState, changeSet: RichText.ChangeSet) => ({\n name: 'RichText.patch',\n effect: Effect.as(\n Effect.sync(() => {\n patchEditor(hostId, state, changeSet)\n }),\n Message.Patched(),\n ),\n})\n\n/**\n * The text between the start of the caret's block and the caret, or `''` when the\n * selection names no caret. A menu and the input rules read this; nothing about the query\n * is stored. A range is read from its start, which is where what is typed over it lands,\n * whichever way it was dragged.\n */\nconst textBeforeOf = (model: EditorView): string => {\n if (model.selection?.type !== 'Range') return ''\n const start = RichText.rangeStart(model.document, model.selection)\n return start === undefined ? '' : RichText.textBefore(model.document, start)\n}\n\n/**\n * The kinds of the node blocks around the caret's block, innermost first; a range is read\n * from its start, as `textBeforeOf` reads it.\n */\nconst withinOf = (model: EditorView): ReadonlyArray<string> => {\n if (model.selection?.type !== 'Range') return []\n const start = RichText.rangeStart(model.document, model.selection)\n const run = start === undefined ? undefined : RichText.locateRun(model.document, start.node)\n if (run === undefined) return []\n const kinds: Array<string> = []\n for (let depth = run.path.length - 1; depth > 0; depth--) {\n const block = RichText.blockAtPath(model.document, run.path.slice(0, depth))\n if (block?.type === 'Node') kinds.push(block.kind)\n }\n return kinds\n}\n\nconst Host = define({ tag: 'foldkit-richtext', properties: {}, events: {} })\n\n/**\n * Each host id's keys, by the document shown. The host's Mount reads its document once, so a\n * document that did not come from an edit here (a form's fill or reset, an entry opened, a\n * revision restored) needs a fresh host. A committed edit moves its document's key to the next\n * document (`carryKey`), and the document it leaves keeps none, so returning to it is a new host\n * too. The first document a host id shows has no key, as the server's render has none.\n */\nconst lineages = new Map<\n string,\n { next: number; readonly keys: WeakMap<RichText.Document, number> }\n>()\n\nconst lineageOf = (hostId: string) => {\n const found = lineages.get(hostId)\n if (found !== undefined) return found\n const created = { next: 0, keys: new WeakMap<RichText.Document, number>() }\n lineages.set(hostId, created)\n return created\n}\n\nconst hostKey = (hostId: string, document: RichText.Document): string | undefined => {\n const lineage = lineageOf(hostId)\n const key = lineage.keys.get(document) ?? lineage.next++\n lineage.keys.set(document, key)\n return key === 0 ? undefined : `${hostId}-${key}`\n}\n\nconst carryKey = (hostId: string, from: RichText.Document, to: RichText.Document): void => {\n const keys = lineageOf(hostId).keys\n const key = keys.get(from)\n if (key === undefined || from === to) return\n keys.delete(from)\n keys.set(to, key)\n}\n\n/**\n * Patches the editor at `hostId` to `next`, a document the parent put in place of\n * `previous`, keeping the host element instead of mounting a new one. A parent that\n * replaces its document outside an edit here (another replica's change arriving) returns\n * this, in the same transition as the replacement.\n *\n * The host is found by the document the view renders, so `previous` is the object it\n * rendered and `next.document` the object it will render; building the Command hands the\n * host on from one to the other, so build it only to return it. The patch itself starts\n * from the latest state the editor holds (what it has drawn, or a state waiting on a\n * composition), and `next.selection` becomes the browser selection;\n * a replacement that changes nothing drawn leaves the DOM alone, selection included, as an\n * exchange that only confirms edits already shown does.\n */\nexport const patchTo = (\n hostId: string,\n previous: RichText.Document,\n next: RichText.EditorState,\n): Command.Command<Message> => {\n carryKey(hostId, previous, next.document)\n return {\n name: 'RichText.patch',\n effect: Effect.as(\n Effect.sync(() => {\n const held = heldDocument(hostId)\n // No editor is attached there: it went away while the transition was in flight.\n if (held === undefined) return\n const changeSet = replaceChangeSet(held, next.document)\n const unchanged =\n !changeSet.structureChanged &&\n changeSet.dirtyNodes.size === 0 &&\n changeSet.removedNodes.size === 0\n if (!unchanged) patchEditor(hostId, next, changeSet)\n }),\n Message.Patched(),\n ),\n }\n}\n\n/**\n * Draws `decorations` over the editor at `hostId`, beside what its placement draws, until the\n * next overlay replaces them: decorations an application derives from its own state, such as\n * other people's carets, which a placement's `decorate` cannot see. Their positions name the\n * document shown, so an application sets them again when that changes. The caret stays put.\n */\nexport const overlay = (\n hostId: string,\n decorations: RichText.DecorationSet,\n): Command.Command<Message> => ({\n name: 'RichText.overlay',\n effect: Effect.as(\n Effect.sync(() => {\n placeOverlay(hostId, decorations)\n redecorateEditor(hostId)\n }),\n Message.Patched(),\n ),\n})\n\n/**\n * The host element the editor mounts into, and whose id the patch Command finds (§118). It is a\n * custom element so hydration leaves what is inside it alone (§145): on the server it holds the\n * document's markup, which the editor adopts; in the browser the view declares it empty, and the\n * editor owns everything below.\n */\nexport const editorView = Submodel.defineView<EditorView, Message>((model, h) => {\n const serverRendered = serverRenderedFor(model.hostId)()\n const key = serverRendered ? undefined : hostKey(model.hostId, model.document)\n return Host.withMessage(h)(\n [\n h.Id(model.hostId),\n ...(key === undefined ? [] : [h.Key(key)]),\n // A custom element is inline until styled, and the editor inside it is a block.\n h.Style({ display: 'block' }),\n h.OnMount(events({ content: model.document })),\n ],\n serverRendered\n ? [\n renderEditable(\n model.document,\n renderingFor(model.hostId),\n decorationsFor(model.hostId)(model.document),\n ),\n ]\n : [],\n )\n})\n\n/** What a Message does to the editor; `Editor.update` carries the host's key on a commit. */\nconst transition = (\n model: EditorView,\n incoming: Message,\n): Update.ReturnWithOutMessage<EditorView, Message, OutMessage> => {\n const state: RichText.EditorState = { document: model.document, selection: model.selection }\n // The vocabulary this placement resolves edits against; both fields may be absent.\n const vocabulary = vocabularyFor(model.hostId)\n // A live query decides what Enter means before anything else reads the message\n // (§123): the highlighted entry applies as the Message a click would send, instead\n // of splitting, and a query that chooses nothing falls through to `incoming` and\n // still splits. Substituting the Message here rather than recursing is what makes a\n // mark entry update the caret's stored marks through the path a toggle already uses.\n const menu =\n incoming._tag === 'Entered'\n ? slashMenu(slashEntries, textBeforeOf(model), model.menuIndex)\n : undefined\n const message = menu?.highlighted?.message ?? incoming\n return Match.value(message).pipe(\n Match.withReturnType<Update.ReturnWithOutMessage<EditorView, Message, OutMessage>>(),\n Match.tags({\n // The patch Command's own completion: the render already happened.\n Patched: () => ({ model }),\n Undone: undone => travel(model, state, undone),\n Redone: redone => travel(model, state, redone),\n }),\n Match.orElse(message => {\n let nextId = model.nextId\n // With nothing selected, a mark toggle is the caret's own state: the next\n // typed text lands with it. A caret move ends the format it was carrying.\n const collapsed =\n model.selection?.type === 'Range' &&\n model.selection.anchor.node === model.selection.focus.node &&\n model.selection.anchor.offset === model.selection.focus.offset\n // The caret never carries a mark the vocabulary cannot type — an unknown one, or one\n // like Link whose props a bare name lacks — so it is refused here rather than at the\n // first keystroke after it.\n if (\n message._tag === 'ToggledMark' &&\n collapsed &&\n !(vocabulary.marks ?? RichText.shippedRegistry).accepts(message.mark)\n ) {\n return { model, outMessage: { _tag: 'Rejected', error: 'InvalidInput' } }\n }\n const storedMarks =\n message._tag === 'ToggledMark' && collapsed\n ? model.storedMarks?.includes(message.mark)\n ? model.storedMarks.filter(mark => mark !== message.mark)\n : [...(model.storedMarks ?? []), message.mark]\n : model.storedMarks\n const command =\n message._tag === 'Typed' && storedMarks !== null\n ? ({ type: 'InsertText', text: message.text, marks: storedMarks } as const)\n : toCommand(message)\n // Choosing an entry removes the query it was typed into and applies the choice as\n // one action (§124 §5), so one transition and one undo step cover both. The range is\n // a read, not state: `menu.query` is the text the document already holds, and the\n // `+ 1` is the slash that opened it.\n const queryRange =\n menu === undefined || menu.highlighted === undefined || model.selection?.type !== 'Range'\n ? undefined\n : RichText.textRangeBefore(model.document, model.selection.anchor, menu.query.length + 1)\n const runAction = (action: RichText.Action) =>\n RichText.runAction(\n state,\n action,\n { mint: () => `e${nextId++}` },\n { marks: vocabulary.marks, nodes: vocabulary.nodes },\n )\n // What is typed can be a block marker (§124 §4): the rules are the placement's own, so\n // the editor carries none of any syntax's vocabulary itself.\n const ruled =\n queryRange === undefined && message._tag === 'Typed'\n ? RichText.applyInputRules(inputRulesFor(model.hostId), {\n textBefore: textBeforeOf(model),\n text: message.text,\n insertion: command,\n within: withinOf(model),\n })\n : undefined\n const attempt = runAction(\n queryRange !== undefined\n ? [{ type: 'SetSelection', selection: queryRange }, { type: 'DeleteBackward' }, command]\n : (ruled ?? [command]),\n )\n // A rule the vocabulary refuses — a fence typed into bold text, say — leaves the marker\n // as the text it is, rather than refusing the keystroke along with it. The refused\n // attempt's identities are given back first.\n const fallback = !attempt.ok && ruled !== undefined\n if (fallback) nextId = model.nextId\n const result = fallback ? runAction([command]) : attempt\n if (!result.ok) {\n // A refused command changes nothing, so it does not burn identities.\n return { model, outMessage: { _tag: 'Rejected', error: result.error } }\n }\n // `runAction` returns the state it was given when nothing changed: a caret the browser\n // echoes back, or a command with nothing to act on. Keeping the Model keeps the page from\n // rendering, and a caret that did not move keeps the format it carries.\n if (result.state === state && storedMarks === model.storedMarks) return { model }\n // History holds content, not cursor movement: a selection change keeps the\n // redo stack, and a no-op edit adds no step to undo.\n const contentChanged = result.state.document !== model.document\n return {\n model: {\n ...model,\n selection: result.state.selection,\n nextId,\n // A caret move ends the format it was carrying.\n storedMarks: message._tag === 'Selected' ? null : storedMarks,\n history: contentChanged\n ? RichText.commit(model.history, state, { group: RichText.groupFor(command) })\n : model.history,\n },\n outMessage: {\n _tag: 'Edited',\n state: result.state,\n changeSet: result.changeSet,\n transactions: result.transactions,\n },\n commands: [patch(model.hostId, result.state, result.changeSet)],\n }\n }),\n )\n}\n\n/** Undo or redo: history restores content and selection, and the host is told as a replace. */\nconst travel = (\n model: EditorView,\n state: RichText.EditorState,\n message: Extract<Message, { readonly _tag: 'Undone' | 'Redone' }>,\n): Update.ReturnWithOutMessage<EditorView, Message, OutMessage> => {\n const restored =\n message._tag === 'Undone'\n ? RichText.undo(model.history, state)\n : RichText.redo(model.history, state)\n if (restored === undefined) {\n return {\n model,\n outMessage: {\n _tag: 'Rejected',\n error: message._tag === 'Undone' ? 'NothingToUndo' : 'NothingToRedo',\n },\n }\n }\n const changeSet = replaceChangeSet(model.document, restored.state.document)\n return {\n model: {\n ...model,\n selection: restored.state.selection,\n history: restored.history,\n },\n outMessage: { _tag: 'Replaced', state: restored.state, changeSet },\n commands: [patch(model.hostId, restored.state, changeSet)],\n }\n}\n\nexport const Editor = Bundle.make({\n name: 'RichTextEditor',\n Model: EditorView,\n Message,\n args: Schema.Struct({ hostId: Schema.String }),\n // A read-only projection has no initial content of its own; the placement\n // writes only the interaction fields back, so this never becomes the document.\n // The host id is the one thing the child seeds: it is per-placement, and `read`\n // re-projects everything else.\n init: args => ({\n model: {\n document: RichText.Document.make({ version: 1, children: [] }),\n selection: null,\n nextId: 0,\n history: RichText.emptyHistory,\n storedMarks: null,\n menuIndex: 0,\n hostId: args.hostId,\n },\n }),\n update: (model, incoming): Update.ReturnWithOutMessage<EditorView, Message, OutMessage> => {\n const result = transition(model, incoming)\n const out = result.outMessage\n if (out?._tag === 'Edited' || out?._tag === 'Replaced')\n carryKey(model.hostId, model.document, out.state.document)\n return result\n },\n // The host element belongs to the view; everything below it belongs to the\n // interpreter the mount attaches there.\n view: editorView,\n})\n\nconst GotEditor = Link.wrapper('GotEditorMessage', Message)\n\nexport const ParentMessage = defineMessageUnion({ ...GotEditor.cases })\nexport type ParentMessage = typeof ParentMessage.Type\n\nconst editorLink: Link<\n Model,\n Wrapped<'GotEditorMessage', Message>,\n EditorView,\n Message\n> = Link.make({\n // The child sees the parent's document; the parent owns it.\n read: parent =>\n Option.some({\n document: parent.document,\n selection: parent.editor.selection,\n nextId: parent.editor.nextId,\n history: parent.editor.history,\n storedMarks: parent.editor.storedMarks,\n menuIndex: parent.editor.menuIndex,\n hostId: parent.editor.hostId,\n }),\n // Only interaction state is written back: the document is not the child's. `read` builds a\n // new view each time, so the Bundle cannot see that a child returned what it read; a child\n // whose fields are the parent's own leaves the parent as it was. The placement's `init`\n // writes into a parent that has no `editor` yet.\n write: (parent, { document: _document, ...editor }) => {\n const current: EditorState | undefined = parent.editor\n return current !== undefined &&\n (Object.keys(editor) as Array<keyof EditorState>).every(key => editor[key] === current[key])\n ? parent\n : { ...parent, editor }\n },\n wrapper: GotEditor,\n path: ['editor'],\n})\n\n/**\n * What a placement gives its editor. Each is placed by host id rather than passed as an arg\n * (§122): each holds functions or schemas, which a schema-decoded arg cannot describe.\n */\nexport interface EditorPlacement {\n /** How this editor's marks and node kinds render (§121). Defaults to `noRendering`. */\n readonly rendering?: RichText.Rendering | undefined\n /** The vocabulary its edits resolve against (§125). Defaults to none. */\n readonly vocabulary?: Vocabulary | undefined\n /** The rules applied to what is typed (§128). Defaults to none. */\n readonly inputRules?: ReadonlyArray<RichText.InputRule> | undefined\n /**\n * What is drawn over the document (§129), derived from it on every patch: code\n * highlighting, for one. Defaults to nothing.\n */\n readonly decorate?: Decorate | undefined\n /** What the editor shows while its document is blank (`RichText.isBlank`). Defaults to none. */\n readonly placeholder?: string | undefined\n /**\n * Whether this render is the server's (§145), such as `foldkit-ssr`'s `SSR.serving`. While it\n * is, the host carries the document's markup, which the browser's editor adopts instead of\n * drawing again. Defaults to never, so the host is empty until the editor mounts.\n */\n readonly serverRendered?: (() => boolean) | undefined\n}\n\n/**\n * Records everything a placement names for its host id, replacing what the id had: one call,\n * so a placement cannot half-apply. `editorAt` and the form control both place through it.\n */\nexport const placeEditor = (hostId: string, placement: EditorPlacement): void => {\n placeRendering(hostId, placement.rendering ?? RichText.noRendering)\n placeVocabulary(hostId, placement.vocabulary ?? {})\n placeInputRules(hostId, placement.inputRules ?? [])\n placeDecorations(hostId, placement.decorate ?? (() => []))\n // The overlay is set by Commands after placing, so a placement starts without the last one's.\n placeOverlay(hostId, [])\n placePlaceholder(hostId, placement.placeholder)\n placeServerRendered(hostId, placement.serverRendered ?? (() => false))\n}\n\n/**\n * Places one editor, bound to the host element the view renders and the patch Command\n * finds. Each placement picks its own id and names what it places; one call records all\n * of it, so a placement cannot half-apply.\n */\nexport const editorAt = (hostId: string, placement: EditorPlacement = {}) => {\n placeEditor(hostId, placement)\n return Editor.at(editorLink, {\n args: { hostId },\n // Runs with the child already written back, in the same parent transition.\n onOut: (out: OutMessage) => (parent: Model) =>\n out._tag === 'Edited' || out._tag === 'Replaced'\n ? {\n model: {\n ...parent,\n document: out.state.document,\n editor: { ...parent.editor, selection: out.state.selection },\n },\n }\n : { model: parent },\n })\n}\n\nexport const editor = editorAt('richtext-editor')\n\nexport const application = Bundle.assemble<Model, ParentMessage>()([editor])\n\n/** The parent's update: placement Messages route to the editor, others stand still. */\nexport const update = application.update()\n\n/** Wraps one editor Message as the parent Message that carries it. */\nexport const edited = (message: Message): ParentMessage => GotEditor.make(message)\nexport const typed = (text: string): ParentMessage => edited(Message.Typed({ text }))\nexport const pressed = (tag: 'Backspace' | 'DeletedForward' | 'Entered'): ParentMessage =>\n edited(Message[tag]())\nexport const toggled = (mark: string): ParentMessage => edited(Message.ToggledMark({ mark }))\nexport const applied = (mark: RichText.RunMark): ParentMessage =>\n edited(Message.AppliedMark({ mark }))\nexport const cleared = (mark: string): ParentMessage => edited(Message.ClearedMark({ mark }))\nexport const retyped = (block: RichText.TextBlock): ParentMessage =>\n edited(Message.RetypedBlock({ block }))\nexport const wrapped = (containers: ReadonlyArray<RichText.Container>): ParentMessage =>\n edited(Message.WrappedBlock({ containers }))\nexport const converted = (to: RichText.Container): ParentMessage =>\n edited(Message.ConvertedBlock({ to }))\nexport const lifted = (): ParentMessage => edited(Message.LiftedBlock())\nexport const moved = (node: RichText.NodeId, to: RichText.Beside): ParentMessage =>\n edited(Message.MovedBlock({ node, to }))\nexport const selected = (selection: RichText.Selection | null): ParentMessage =>\n edited(Message.Selected({ selection }))\nexport const undone = (): ParentMessage => edited(Message.Undone())\nexport const redone = (): ParentMessage => edited(Message.Redone())\nexport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AQ,SAAS,EAAE,UAAU,CAAC,CAAC;AACxC,MAAa,eAA8B,OAAO,QAAQ,OAAO,CAAC;AAClE,MAAa,eAA8B,OAAO,QAAQ,OAAO,CAAC;AAClE,MAAa,gBAA+B,OAAO,QAAQ,QAAQ,CAAC"}
1
+ {"version":3,"file":"editor-bundle.mjs","names":[],"sources":["../src/editor-bundle.ts"],"sourcesContent":["/**\n * The controlled-editor feasibility harness (§27): the authoritative Document\n * lives in the parent Model, the editor Bundle reads it through its Link, and a\n * single parent transition commits both the document and the interaction state.\n *\n * No DOM, no persistence, no collaboration: this exists to answer whether Bundle\n * ownership can hold a rich-text editor without a second synchronized document\n * copy or a Command that commits half the transition.\n */\nimport { Effect, Equal, Match, Option, Schema } from 'effect'\nimport { define } from 'foldkit/customElement'\nimport { defineMessageUnion } from 'foldkit/message'\nimport { Bundle, Link, type Wrapped } from 'foldkit-bundle'\nimport * as RichText from 'foldkit-richtext'\nimport * as Submodel from 'foldkit/submodel'\nimport type * as Command from 'foldkit/command'\nimport type * as Update from 'foldkit/update'\nimport {\n heldDocument,\n events,\n focusEditor,\n Message,\n patchEditor,\n redecorateEditor,\n slashEntries,\n slashMenu,\n slashQuery,\n type EditorEvent,\n type SlashEntry,\n} from './editor.js'\nimport {\n decorationsFor,\n inputRulesFor,\n placeDecorations,\n placeInputRules,\n placeOverlay,\n placePlaceholders,\n placeRendering,\n placeServerRendered,\n placeKeymap,\n placeSlashEntries,\n placeVocabulary,\n renderingFor,\n serverRenderedFor,\n slashEntriesFor,\n type Vocabulary,\n vocabularyFor,\n} from './host.js'\nimport type { Decorate, KeyBinding } from './events.js'\nimport { renderEditable } from './view.js'\n\n/** Interaction state the parent owns beside the document. */\nexport const EditorState = Schema.Struct({\n selection: Schema.NullOr(RichText.Selection),\n /** Caller-owned identity source: a live edit mints, replay never does. */\n nextId: Schema.Number,\n /** Local undo history: snapshots of document plus selection. */\n history: RichText.History,\n /** Null inherits neighboring marks; an array explicitly sets them, even when empty. */\n storedMarks: Schema.NullOr(Schema.Array(Schema.String)),\n /**\n * The highlighted entry in a live slash menu (§123). The document says whether the\n * caret is in a query and what matches; this is the one thing the menu owns, and\n * `update` resolves Enter against it.\n */\n menuIndex: Schema.Number,\n /** The slash of the query whose menu Escape closed; it stays closed until that query ends. */\n slashDismissed: Schema.OptionFromNullOr(RichText.Position),\n /**\n * The host element the view renders and the patch Command finds (§118). It is\n * per-placement, so it arrives as the Bundle's args and is carried here\n * because `read` re-projects the whole child from the parent.\n */\n hostId: Schema.String,\n})\nexport type EditorState = typeof EditorState.Type\n\nexport const Model = Schema.Struct({\n document: RichText.Document,\n editor: EditorState,\n})\nexport type Model = typeof Model.Type\n\n/** What the child reads: the parent's document passes through, never stored. */\nexport const EditorView = Schema.Struct({\n document: RichText.Document,\n selection: Schema.NullOr(RichText.Selection),\n nextId: Schema.Number,\n history: RichText.History,\n storedMarks: Schema.NullOr(Schema.Array(Schema.String)),\n menuIndex: Schema.Number,\n slashDismissed: Schema.OptionFromNullOr(RichText.Position),\n hostId: Schema.String,\n})\nexport type EditorView = typeof EditorView.Type\n\n/** The committed edit, or the diagnostic that refused it. */\nexport type OutMessage =\n | {\n readonly _tag: 'Edited'\n readonly state: RichText.EditorState\n readonly changeSet: RichText.ChangeSet\n /** What the edit applied, in order, as `RichText.run` returns them. */\n readonly transactions: ReadonlyArray<RichText.Transaction>\n }\n | {\n /** Undo and redo replace the document wholesale; nothing was incremental. */\n readonly _tag: 'Replaced'\n readonly state: RichText.EditorState\n readonly changeSet: RichText.ChangeSet\n }\n | { readonly _tag: 'Rejected'; readonly error: string }\n\n/** Where a node stands: the block holding it (null at the top), and its index there. */\ninterface Placed {\n readonly node: RichText.Block | RichText.Text\n readonly parent: RichText.NodeId | null\n readonly index: number\n}\n\n/** Every block and run of a document by id, nested ones included, with where it stands. */\nconst nodesOf = (content: RichText.Document): ReadonlyMap<RichText.NodeId, Placed> => {\n const nodes = new Map<RichText.NodeId, Placed>()\n const visit = (blocks: ReadonlyArray<RichText.Block>, parent: RichText.NodeId | null): void => {\n for (const [index, block] of blocks.entries()) {\n nodes.set(block.id, { node: block, parent, index })\n for (const [at, run] of block.children.entries()) {\n nodes.set(run.id, { node: run, parent: block.id, index: at })\n }\n if (block.type === 'Node' && block.blocks !== undefined) visit(block.blocks, block.id)\n }\n }\n visit(content.children, null)\n return nodes\n}\n\nconst sameMarks = (left: RichText.Text, right: RichText.Text): boolean =>\n left.marks.length === right.marks.length &&\n left.marks.every((mark, index) => RichText.sameMark(mark, right.marks[index]!))\n\n/** A block's own fields, apart from what it holds: its type, level, kind and props. */\nconst ownFields = ({ children: _runs, ...block }: RichText.Block): unknown => ({\n ...block,\n blocks: undefined,\n})\n\n/**\n * What differs between two whole documents, for a patch from one to the other, in a\n * transaction's terms: the runs whose text or marks changed and the blocks holding them,\n * blocks whose own fields changed, what came and went, and whether any block moved.\n */\nexport const replaceChangeSet = (\n previous: RichText.Document,\n next: RichText.Document,\n): RichText.ChangeSet => {\n const before = nodesOf(previous)\n const after = nodesOf(next)\n const dirtyNodes = new Set<RichText.NodeId>()\n const textChanged = new Set<RichText.NodeId>()\n let structureChanged = false\n for (const [id, placed] of after) {\n const was = before.get(id)\n if (placed.node.type === 'Text') {\n const run = placed.node\n const old = was?.node.type === 'Text' ? was.node : undefined\n if (old === undefined || old.text !== run.text) textChanged.add(id)\n if (old === undefined || old.text !== run.text || !sameMarks(old, run)) {\n dirtyNodes.add(id)\n if (placed.parent !== null) dirtyNodes.add(placed.parent)\n }\n // A run moved to another block, or to another place in its own, changes both blocks'\n // runs though the run itself did not change.\n if (was !== undefined && (was.parent !== placed.parent || was.index !== placed.index)) {\n if (placed.parent !== null) dirtyNodes.add(placed.parent)\n if (was.parent !== null && after.has(was.parent)) dirtyNodes.add(was.parent)\n }\n continue\n }\n if (was === undefined || was.parent !== placed.parent || was.index !== placed.index) {\n structureChanged = true\n }\n if (\n was === undefined ||\n !Equal.equals(ownFields(was.node as RichText.Block), ownFields(placed.node))\n ) {\n dirtyNodes.add(id)\n }\n }\n const removedNodes = new Set([...before.keys()].filter(id => !after.has(id)))\n for (const id of removedNodes) {\n const was = before.get(id)!\n if (was.node.type !== 'Text') structureChanged = true\n else if (was.parent !== null && after.has(was.parent)) dirtyNodes.add(was.parent)\n }\n return {\n dirtyNodes,\n insertedNodes: new Set([...after.keys()].filter(id => !before.has(id))),\n removedNodes,\n textChanged,\n structureChanged,\n selectionChanged: false,\n }\n}\n\ntype CommandMessage = Exclude<\n Message,\n { readonly _tag: 'Undone' | 'Redone' | 'Patched' | 'ActivatedAdornment' | 'DismissedSlash' }\n>\n\nconst toCommand = (message: CommandMessage): RichText.Command => {\n switch (message._tag) {\n case 'Typed':\n return { type: 'InsertText', text: message.text }\n case 'Backspace':\n return { type: 'DeleteBackward' }\n case 'DeletedForward':\n return { type: 'DeleteForward' }\n case 'Entered':\n return { type: 'SplitBlock' }\n case 'ToggledMark':\n return { type: 'ToggleMark', mark: message.mark }\n case 'AppliedMark':\n return { type: 'SetMark', mark: message.mark }\n case 'ClearedMark':\n return { type: 'ClearMark', mark: message.mark }\n case 'RetypedBlock':\n return { type: 'RetypeBlock', to: message.block }\n case 'WrappedBlock':\n return { type: 'WrapBlock', containers: message.containers }\n case 'ConvertedBlock':\n return { type: 'ConvertBlock', to: message.to }\n case 'LiftedBlock':\n return { type: 'LiftBlock' }\n case 'MovedBlock':\n return { type: 'MoveBlock', node: message.node, to: message.to }\n case 'InsertedBlock':\n return { type: 'InsertBlock', block: message.block, to: message.to }\n case 'DeletedBlock':\n return { type: 'DeleteBlock', node: message.node }\n case 'ChangedProps':\n return { type: 'SetProps', node: message.node, props: message.props }\n case 'InsertedRow':\n return { type: 'InsertRow', where: message.where }\n case 'InsertedColumn':\n return { type: 'InsertColumn', where: message.where }\n case 'DeletedRow':\n return { type: 'DeleteRow' }\n case 'DeletedColumn':\n return { type: 'DeleteColumn' }\n case 'Indented':\n return { type: 'Indent' }\n case 'ReplacedText':\n return {\n type: 'Replace',\n query: message.query,\n replacement: message.replacement,\n caseSensitive: message.caseSensitive,\n at: message.at,\n }\n case 'InsertedFootnote':\n return { type: 'InsertFootnote', text: message.text }\n case 'RenamedFootnote':\n return { type: 'RenameFootnote', from: message.from, to: message.to }\n case 'Outdented':\n return { type: 'Outdent' }\n case 'Selected':\n return { type: 'SetSelection', selection: message.selection }\n case 'Pasted':\n return { type: 'Paste', slice: message.slice }\n }\n}\n\n/**\n * The rendering effect (§118): patch the host the view rendered, once the\n * parent's transition has committed. It commits nothing, so the one-transition\n * property the proof established is untouched.\n */\nconst patch = (hostId: string, state: RichText.EditorState, changeSet: RichText.ChangeSet) => ({\n name: 'RichText.patch',\n effect: Effect.as(\n Effect.sync(() => {\n patchEditor(hostId, state, changeSet)\n }),\n Message.Patched(),\n ),\n})\n\n/**\n * The text between the start of the caret's block and the caret, or `''` when the\n * selection names no caret. A menu and the input rules read this; nothing about the query\n * is stored. A range is read from its start, which is where what is typed over it lands,\n * whichever way it was dragged.\n */\nconst textBeforeOf = (model: EditorView): string => {\n if (model.selection?.type !== 'Range') return ''\n const start = RichText.rangeStart(model.document, model.selection)\n return start === undefined ? '' : RichText.textBefore(model.document, start)\n}\n\n/** Where the slash of the caret's live query is: none outside a query. */\nconst slashOf = (model: EditorView): Option.Option<RichText.Position> => {\n const query = slashQuery(textBeforeOf(model))\n if (query === undefined || model.selection?.type !== 'Range') return Option.none()\n const start = RichText.rangeStart(model.document, model.selection)\n const range =\n start === undefined\n ? undefined\n : RichText.textRangeBefore(model.document, start, query.length + 1)\n return range?.type === 'Range' ? Option.some(range.anchor) : Option.none()\n}\n\nconst dismissed = (model: EditorView): boolean =>\n Option.exists(model.slashDismissed, slash =>\n Option.exists(slashOf(model), live => live.node === slash.node && live.offset === slash.offset),\n )\n\n/**\n * The text a slash menu reads: the text before the caret, or nothing once Escape has closed\n * the menu of the query the caret is in. Enter resolves against it, and an application's menu\n * view reads it too, so the two agree on whether a menu is open.\n */\nexport const menuTextOf = (model: EditorView): string =>\n dismissed(model) ? '' : textBeforeOf(model)\n\n/**\n * The kinds of the node blocks around the caret's block, innermost first; a range is read\n * from its start, as `textBeforeOf` reads it.\n */\nconst withinOf = (model: EditorView): ReadonlyArray<string> => {\n if (model.selection?.type !== 'Range') return []\n const start = RichText.rangeStart(model.document, model.selection)\n const run = start === undefined ? undefined : RichText.locateRun(model.document, start.node)\n if (run === undefined) return []\n const kinds: Array<string> = []\n for (let depth = run.path.length - 1; depth > 0; depth--) {\n const block = RichText.blockAtPath(model.document, run.path.slice(0, depth))\n if (block?.type === 'Node') kinds.push(block.kind)\n }\n return kinds\n}\n\nconst Host = define({ tag: 'foldkit-richtext', properties: {}, events: {} })\n\n/**\n * Each host id's keys, by the document shown. The host's Mount reads its document once, so a\n * document that did not come from an edit here (a form's fill or reset, an entry opened, a\n * revision restored) needs a fresh host. A committed edit moves its document's key to the next\n * document (`carryKey`), and the document it leaves keeps none, so returning to it is a new host\n * too. The first document a host id shows has no key, as the server's render has none.\n */\nconst lineages = new Map<\n string,\n { next: number; readonly keys: WeakMap<RichText.Document, number> }\n>()\n\nconst lineageOf = (hostId: string) => {\n const found = lineages.get(hostId)\n if (found !== undefined) return found\n const created = { next: 0, keys: new WeakMap<RichText.Document, number>() }\n lineages.set(hostId, created)\n return created\n}\n\nconst hostKey = (hostId: string, document: RichText.Document): string | undefined => {\n const lineage = lineageOf(hostId)\n const key = lineage.keys.get(document) ?? lineage.next++\n lineage.keys.set(document, key)\n return key === 0 ? undefined : `${hostId}-${key}`\n}\n\nconst carryKey = (hostId: string, from: RichText.Document, to: RichText.Document): void => {\n const keys = lineageOf(hostId).keys\n const key = keys.get(from)\n if (key === undefined || from === to) return\n keys.delete(from)\n keys.set(to, key)\n}\n\n/**\n * Patches the editor at `hostId` to `next`, a document the parent put in place of\n * `previous`, keeping the host element instead of mounting a new one. A parent that\n * replaces its document outside an edit here (another replica's change arriving) returns\n * this, in the same transition as the replacement.\n *\n * The host is found by the document the view renders, so `previous` is the object it\n * rendered and `next.document` the object it will render; building the Command hands the\n * host on from one to the other, so build it only to return it. The patch itself starts\n * from the latest state the editor holds (what it has drawn, or a state waiting on a\n * composition), and `next.selection` becomes the browser selection;\n * a replacement that changes nothing drawn leaves the DOM alone, selection included, as an\n * exchange that only confirms edits already shown does.\n */\nexport const patchTo = (\n hostId: string,\n previous: RichText.Document,\n next: RichText.EditorState,\n): Command.Command<Message> => {\n carryKey(hostId, previous, next.document)\n return {\n name: 'RichText.patch',\n effect: Effect.as(\n Effect.sync(() => {\n const held = heldDocument(hostId)\n // No editor is attached there: it went away while the transition was in flight.\n if (held === undefined) return\n const changeSet = replaceChangeSet(held, next.document)\n const unchanged =\n !changeSet.structureChanged &&\n changeSet.dirtyNodes.size === 0 &&\n changeSet.removedNodes.size === 0\n if (!unchanged) patchEditor(hostId, next, changeSet)\n }),\n Message.Patched(),\n ),\n }\n}\n\n/**\n * Draws `decorations` over the editor at `hostId`, beside what its placement draws, until the\n * next overlay replaces them: decorations an application derives from its own state, such as\n * other people's carets, which a placement's `decorate` cannot see. Their positions name the\n * document shown, so an application sets them again when that changes. The caret stays put.\n */\nexport const overlay = (\n hostId: string,\n decorations: RichText.DecorationSet,\n): Command.Command<Message> => ({\n name: 'RichText.overlay',\n effect: Effect.as(\n Effect.sync(() => {\n placeOverlay(hostId, decorations)\n redecorateEditor(hostId)\n }),\n Message.Patched(),\n ),\n})\n\n/**\n * Focuses the editor at `hostId` with `selection` in the browser, brought into view: for a\n * control outside the editor that sends the reader into the text, such as a table of contents.\n * The browser reports the selection back as `Selected`, so the Model follows it either way.\n */\nexport const focus = (hostId: string, selection: RichText.Selection): Command.Command<Message> => ({\n name: 'RichText.focus',\n effect: Effect.as(\n Effect.sync(() => focusEditor(hostId, selection)),\n Message.Patched(),\n ),\n})\n\n/**\n * The host element the editor mounts into, and whose id the patch Command finds (§118). It is a\n * custom element so hydration leaves what is inside it alone (§145): on the server it holds the\n * document's markup, which the editor adopts; in the browser the view declares it empty, and the\n * editor owns everything below.\n */\nexport const editorView = Submodel.defineView<EditorView, Message>((model, h) => {\n const serverRendered = serverRenderedFor(model.hostId)()\n const key = serverRendered ? undefined : hostKey(model.hostId, model.document)\n return Host.withMessage(h)(\n [\n h.Id(model.hostId),\n ...(key === undefined ? [] : [h.Key(key)]),\n // A custom element is inline until styled, and the editor inside it is a block.\n h.Style({ display: 'block' }),\n h.OnMount(events({ content: model.document })),\n ],\n serverRendered\n ? [\n renderEditable(\n model.document,\n renderingFor(model.hostId),\n decorationsFor(model.hostId)(model.document),\n ),\n ]\n : [],\n )\n})\n\n/** What a Message does to the editor; `Editor.update` carries the host's key on a commit. */\nconst transition = (\n model: EditorView,\n incoming: Message,\n): Update.ReturnWithOutMessage<EditorView, Message, OutMessage> => {\n const state: RichText.EditorState = { document: model.document, selection: model.selection }\n // The vocabulary this placement resolves edits against; both fields may be absent.\n const vocabulary = vocabularyFor(model.hostId)\n // A live query decides what Enter means before anything else reads the message\n // (§123): the highlighted entry applies as the Message a click would send, instead\n // of splitting, and a query that chooses nothing falls through to `incoming` and\n // still splits. Substituting the Message here rather than recursing is what makes a\n // mark entry update the caret's stored marks through the path a toggle already uses.\n const menu =\n incoming._tag === 'Entered'\n ? slashMenu(slashEntriesFor(model.hostId) ?? slashEntries, menuTextOf(model), model.menuIndex)\n : undefined\n const message = menu?.highlighted?.message ?? incoming\n return Match.value(message).pipe(\n Match.withReturnType<Update.ReturnWithOutMessage<EditorView, Message, OutMessage>>(),\n Match.tags({\n // The patch Command's own completion: the render already happened.\n Patched: () => ({ model }),\n // A click asking the application for something, not an edit: nothing changes here.\n ActivatedAdornment: () => ({ model }),\n DismissedSlash: () => {\n const slash = slashOf(model)\n return Option.isNone(slash) || dismissed(model)\n ? { model }\n : { model: { ...model, slashDismissed: slash } }\n },\n Undone: undone => travel(model, state, undone),\n Redone: redone => travel(model, state, redone),\n }),\n Match.orElse(message => {\n let nextId = model.nextId\n // With nothing selected, a mark toggle is the caret's own state: the next\n // typed text lands with it. A caret move ends the format it was carrying.\n const collapsed =\n model.selection?.type === 'Range' &&\n model.selection.anchor.node === model.selection.focus.node &&\n model.selection.anchor.offset === model.selection.focus.offset\n // The caret never carries a mark the vocabulary cannot type — an unknown one, or one\n // like Link whose props a bare name lacks — so it is refused here rather than at the\n // first keystroke after it.\n if (\n message._tag === 'ToggledMark' &&\n collapsed &&\n !(vocabulary.marks ?? RichText.shippedRegistry).accepts(message.mark)\n ) {\n return { model, outMessage: { _tag: 'Rejected', error: 'InvalidInput' } }\n }\n const storedMarks =\n message._tag === 'ToggledMark' && collapsed\n ? model.storedMarks?.includes(message.mark)\n ? model.storedMarks.filter(mark => mark !== message.mark)\n : [...(model.storedMarks ?? []), message.mark]\n : model.storedMarks\n const command =\n message._tag === 'Typed' && storedMarks !== null\n ? ({ type: 'InsertText', text: message.text, marks: storedMarks } as const)\n : toCommand(message)\n // Choosing an entry removes the query it was typed into and applies the choice as\n // one action (§124 §5), so one transition and one undo step cover both. The range is\n // a read, not state: `menu.query` is the text the document already holds, and the\n // `+ 1` is the slash that opened it.\n const queryRange =\n menu === undefined || menu.highlighted === undefined || model.selection?.type !== 'Range'\n ? undefined\n : RichText.textRangeBefore(model.document, model.selection.anchor, menu.query.length + 1)\n const runAction = (action: RichText.Action) =>\n RichText.runAction(\n state,\n action,\n { mint: () => `e${nextId++}` },\n { marks: vocabulary.marks, nodes: vocabulary.nodes },\n )\n // What is typed can be a block marker (§124 §4): the rules are the placement's own, so\n // the editor carries none of any syntax's vocabulary itself.\n const ruled =\n queryRange === undefined && message._tag === 'Typed'\n ? RichText.resolveInputRules(inputRulesFor(model.hostId), {\n textBefore: textBeforeOf(model),\n text: message.text,\n insertion: command,\n within: withinOf(model),\n })\n : undefined\n const attempt = runAction(\n queryRange !== undefined\n ? [{ type: 'SetSelection', selection: queryRange }, { type: 'DeleteBackward' }, command]\n : (ruled?.action ?? [command]),\n )\n // A rule the vocabulary refuses — a fence typed into bold text, say — leaves the marker\n // as the text it is, rather than refusing the keystroke along with it. The refused\n // attempt's identities are given back first.\n const fallback = !attempt.ok && ruled !== undefined\n if (fallback) nextId = model.nextId\n const result = fallback ? runAction([command]) : attempt\n if (!result.ok) {\n // A refused command changes nothing, so it does not burn identities.\n return { model, outMessage: { _tag: 'Rejected', error: result.error } }\n }\n // `runAction` returns the state it was given when nothing changed: a caret the browser\n // echoes back, or a command with nothing to act on. Keeping the Model keeps the page from\n // rendering, and a caret that did not move keeps the format it carries.\n if (result.state === state && storedMarks === model.storedMarks) return { model }\n // History holds content, not cursor movement: a selection change keeps the\n // redo stack, and a no-op edit adds no step to undo.\n const contentChanged = result.state.document !== model.document\n return {\n model: {\n ...model,\n selection: result.state.selection,\n nextId,\n // A caret move ends the format it was carrying; a rule that applied may set the next.\n storedMarks:\n message._tag === 'Selected'\n ? null\n : ((fallback ? undefined : ruled?.storedMarks) ?? storedMarks),\n history: contentChanged\n ? RichText.commit(model.history, state, { group: RichText.groupFor(command) })\n : model.history,\n },\n outMessage: {\n _tag: 'Edited',\n state: result.state,\n changeSet: result.changeSet,\n transactions: result.transactions,\n },\n commands: [patch(model.hostId, result.state, result.changeSet)],\n }\n }),\n )\n}\n\n/** Undo or redo: history restores content and selection, and the host is told as a replace. */\nconst travel = (\n model: EditorView,\n state: RichText.EditorState,\n message: Extract<Message, { readonly _tag: 'Undone' | 'Redone' }>,\n): Update.ReturnWithOutMessage<EditorView, Message, OutMessage> => {\n const restored =\n message._tag === 'Undone'\n ? RichText.undo(model.history, state)\n : RichText.redo(model.history, state)\n if (restored === undefined) {\n return {\n model,\n outMessage: {\n _tag: 'Rejected',\n error: message._tag === 'Undone' ? 'NothingToUndo' : 'NothingToRedo',\n },\n }\n }\n const changeSet = replaceChangeSet(model.document, restored.state.document)\n return {\n model: {\n ...model,\n selection: restored.state.selection,\n history: restored.history,\n },\n outMessage: { _tag: 'Replaced', state: restored.state, changeSet },\n commands: [patch(model.hostId, restored.state, changeSet)],\n }\n}\n\nexport const Editor = Bundle.make({\n name: 'RichTextEditor',\n Model: EditorView,\n Message,\n args: Schema.Struct({ hostId: Schema.String }),\n // A read-only projection has no initial content of its own; the placement\n // writes only the interaction fields back, so this never becomes the document.\n // The host id is the one thing the child seeds: it is per-placement, and `read`\n // re-projects everything else.\n init: args => ({\n model: {\n document: RichText.Document.make({ version: 1, children: [] }),\n selection: null,\n nextId: 0,\n history: RichText.emptyHistory,\n storedMarks: null,\n menuIndex: 0,\n slashDismissed: Option.none(),\n hostId: args.hostId,\n },\n }),\n update: (model, incoming): Update.ReturnWithOutMessage<EditorView, Message, OutMessage> => {\n const result = transition(model, incoming)\n const out = result.outMessage\n // An edit or a replacement carries the state it committed; a rejection, none.\n const committed = out !== undefined && 'state' in out ? out.state : undefined\n if (committed !== undefined) carryKey(model.hostId, model.document, committed.document)\n // A dismissal ends with the query it closed, so a slash typed later opens a menu again.\n // The child's document is the parent's, so the edit is read from what it committed.\n const after = { ...result.model, document: committed?.document ?? result.model.document }\n return Option.isSome(result.model.slashDismissed) && !dismissed(after)\n ? { ...result, model: { ...result.model, slashDismissed: Option.none() } }\n : result\n },\n // The host element belongs to the view; everything below it belongs to the\n // interpreter the mount attaches there.\n view: editorView,\n})\n\nconst GotEditor = Link.wrapper('GotEditorMessage', Message)\n\nexport const ParentMessage = defineMessageUnion({ ...GotEditor.cases })\nexport type ParentMessage = typeof ParentMessage.Type\n\nconst editorLink: Link<\n Model,\n Wrapped<'GotEditorMessage', Message>,\n EditorView,\n Message\n> = Link.make({\n // The child sees the parent's document; the parent owns it.\n read: parent =>\n Option.some({\n document: parent.document,\n selection: parent.editor.selection,\n nextId: parent.editor.nextId,\n history: parent.editor.history,\n storedMarks: parent.editor.storedMarks,\n menuIndex: parent.editor.menuIndex,\n slashDismissed: parent.editor.slashDismissed,\n hostId: parent.editor.hostId,\n }),\n // Only interaction state is written back: the document is not the child's. `read` builds a\n // new view each time, so the Bundle cannot see that a child returned what it read; a child\n // whose fields are the parent's own leaves the parent as it was. The placement's `init`\n // writes into a parent that has no `editor` yet.\n write: (parent, { document: _document, ...editor }) => {\n const current: EditorState | undefined = parent.editor\n return current !== undefined &&\n (Object.keys(editor) as Array<keyof EditorState>).every(key => editor[key] === current[key])\n ? parent\n : { ...parent, editor }\n },\n wrapper: GotEditor,\n path: ['editor'],\n})\n\n/**\n * What a placement gives its editor. Each is placed by host id rather than passed as an arg\n * (§122): each holds functions or schemas, which a schema-decoded arg cannot describe.\n */\nexport interface EditorPlacement {\n /** How this editor's marks and node kinds render (§121). Defaults to `noRendering`. */\n readonly rendering?: RichText.Rendering | undefined\n /** The vocabulary its edits resolve against (§125). Defaults to none. */\n readonly vocabulary?: Vocabulary | undefined\n /** The rules applied to what is typed (§128). Defaults to none. */\n readonly inputRules?: ReadonlyArray<RichText.InputRule> | undefined\n /**\n * What is drawn over the document (§129), derived from it on every patch: code\n * highlighting, for one. Defaults to nothing.\n */\n readonly decorate?: Decorate | undefined\n /** What the editor shows while its document is blank (`RichText.isBlank`). Defaults to none. */\n readonly placeholder?: string | undefined\n /**\n * What the empty paragraph the caret is in shows, such as \"Type / for blocks\", as\n * `data-hint` on it. Defaults to none.\n */\n readonly lineHint?: string | undefined\n /**\n * Chords beside the built-in ones (Bold, Italic, Code, Strikethrough, undo and redo), checked\n * first: `{ chord: 'Mod-u', command: { type: 'ToggleMark', mark: 'Underline' } }` for a mark\n * of the application's own. Defaults to none.\n */\n readonly keymap?: ReadonlyArray<KeyBinding> | undefined\n /**\n * What its slash menu offers, which Enter resolves against: an application's own entries\n * (an image, a table, a callout) beside or instead of `slashEntries`. The application's menu\n * view draws the same list. Defaults to `slashEntries`.\n */\n readonly slashEntries?: ReadonlyArray<SlashEntry<EditorEvent>> | undefined\n /**\n * Whether this render is the server's (§145), such as `foldkit-ssr`'s `SSR.serving`. While it\n * is, the host carries the document's markup, which the browser's editor adopts instead of\n * drawing again. Defaults to never, so the host is empty until the editor mounts.\n */\n readonly serverRendered?: (() => boolean) | undefined\n}\n\n/**\n * Records everything a placement names for its host id, replacing what the id had: one call,\n * so a placement cannot half-apply. `editorAt` and the form control both place through it.\n */\nexport const placeEditor = (hostId: string, placement: EditorPlacement): void => {\n placeRendering(hostId, placement.rendering ?? RichText.noRendering)\n placeVocabulary(hostId, placement.vocabulary ?? {})\n placeInputRules(hostId, placement.inputRules ?? [])\n placeDecorations(hostId, placement.decorate ?? (() => []))\n // The overlay is set by Commands after placing, so a placement starts without the last one's.\n placeOverlay(hostId, [])\n placePlaceholders(hostId, {\n placeholder: placement.placeholder,\n lineHint: placement.lineHint,\n })\n placeSlashEntries(hostId, placement.slashEntries)\n placeKeymap(hostId, placement.keymap ?? [])\n placeServerRendered(hostId, placement.serverRendered ?? (() => false))\n}\n\n/**\n * Places one editor, bound to the host element the view renders and the patch Command\n * finds. Each placement picks its own id and names what it places; one call records all\n * of it, so a placement cannot half-apply.\n */\nexport const editorAt = (hostId: string, placement: EditorPlacement = {}) => {\n placeEditor(hostId, placement)\n return Editor.at(editorLink, {\n args: { hostId },\n // Runs with the child already written back, in the same parent transition.\n onOut: (out: OutMessage) => (parent: Model) =>\n out._tag === 'Edited' || out._tag === 'Replaced'\n ? {\n model: {\n ...parent,\n document: out.state.document,\n editor: { ...parent.editor, selection: out.state.selection },\n },\n }\n : { model: parent },\n })\n}\n\nexport const editor = editorAt('richtext-editor')\n\nexport const application = Bundle.assemble<Model, ParentMessage>()([editor])\n\n/** The parent's update: placement Messages route to the editor, others stand still. */\nexport const update = application.update()\n\n/** Wraps one editor Message as the parent Message that carries it. */\nexport const edited = (message: Message): ParentMessage => GotEditor.make(message)\nexport const typed = (text: string): ParentMessage => edited(Message.Typed({ text }))\nexport const pressed = (tag: 'Backspace' | 'DeletedForward' | 'Entered'): ParentMessage =>\n edited(Message[tag]())\nexport const toggled = (mark: string): ParentMessage => edited(Message.ToggledMark({ mark }))\nexport const applied = (mark: RichText.RunMark): ParentMessage =>\n edited(Message.AppliedMark({ mark }))\nexport const cleared = (mark: string): ParentMessage => edited(Message.ClearedMark({ mark }))\nexport const retyped = (block: RichText.TextBlock): ParentMessage =>\n edited(Message.RetypedBlock({ block }))\nexport const wrapped = (containers: ReadonlyArray<RichText.Container>): ParentMessage =>\n edited(Message.WrappedBlock({ containers }))\nexport const converted = (to: RichText.Container): ParentMessage =>\n edited(Message.ConvertedBlock({ to }))\nexport const lifted = (): ParentMessage => edited(Message.LiftedBlock())\nexport const moved = (node: RichText.NodeId, to: RichText.Beside): ParentMessage =>\n edited(Message.MovedBlock({ node, to }))\nexport const inserted = (block: RichText.Block, to?: RichText.Beside): ParentMessage =>\n edited(Message.InsertedBlock(to === undefined ? { block } : { block, to }))\nexport const deleted = (node: RichText.NodeId): ParentMessage =>\n edited(Message.DeletedBlock({ node }))\nexport const changedProps = (node: RichText.NodeId, props: Schema.JsonObject): ParentMessage =>\n edited(Message.ChangedProps({ node, props }))\nexport const selected = (selection: RichText.Selection | null): ParentMessage =>\n edited(Message.Selected({ selection }))\nexport const undone = (): ParentMessage => edited(Message.Undone())\nexport const redone = (): ParentMessage => edited(Message.Redone())\nexport const patched = (): ParentMessage => edited(Message.Patched())\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoDA,MAAa,cAAc,OAAO,OAAO;CACvC,WAAW,OAAO,OAAO,SAAS,SAAS;;CAE3C,QAAQ,OAAO;;CAEf,SAAS,SAAS;;CAElB,aAAa,OAAO,OAAO,OAAO,MAAM,OAAO,MAAM,CAAC;;;;;;CAMtD,WAAW,OAAO;;CAElB,gBAAgB,OAAO,iBAAiB,SAAS,QAAQ;;;;;;CAMzD,QAAQ,OAAO;AACjB,CAAC;AAGD,MAAa,QAAQ,OAAO,OAAO;CACjC,UAAU,SAAS;CACnB,QAAQ;AACV,CAAC;;AAID,MAAa,aAAa,OAAO,OAAO;CACtC,UAAU,SAAS;CACnB,WAAW,OAAO,OAAO,SAAS,SAAS;CAC3C,QAAQ,OAAO;CACf,SAAS,SAAS;CAClB,aAAa,OAAO,OAAO,OAAO,MAAM,OAAO,MAAM,CAAC;CACtD,WAAW,OAA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