Files
museion/docs/adr/0010-native-textkit2-prose-editor.md
T
AlexKucera 50eecc6dcb docs(spec): projects/archive layout + outline type — v1.1 spec (#106)
CONTEXT.md: Project, Outline, Archive adopted; Content Type rewritten
as frontmatter attribute; Post ID global across projects.
ADR-0012 (amends 0004), ADR-0013 (specializes 0010).

Wayfinder map #97 — spec assembly ticket #106.
2026-10-13 16:15:19 +02:00

2.4 KiB

0010 — Native TextKit2 prose editor (mode B)

Reading half superseded by ADR-0011 — apex HTML pipeline; the editing stance (TextKit2 mode B) stands. Outline editing splits off onto a dedicated block surface per ADR-0013.

The editor is a native NSTextView/TextKit2 surface presenting markdown source as calm writing (mode B: styled source, dimmed syntax, reading toggle), with presentation as a flat line-kind→attribute map — no third-party editor dependency. Decided from three throwaway spikes on the pinned calibration corpus (spike/codeedit/, spike/textkit2/, spike/blocks/ on spike/editor-presentation): TextKit2 delivers full typographic calm at the lowest cost, editing (undo, IME, selection) is native and free, and the Fix-Card anchor proof — exact-range quote highlight + stale-anchor alert with the web-proto wording — passes live on this substrate (2.4 ms anchor search on PERF-3k, ≤1.1 ms full-doc attribute load).

Considered Options

  • CodeEditSourceEditor fork 0.15.8-helm (the presumptive leader, proven in Classis): anchor mechanics clean, but the substrate cannot reach typographic calm — one font size for everything, no paragraph spacing (EditorTheme/attributesFor builds every run from a single base font), mid-word wraps at typographic apostrophes, and emphasis ghost-doubles colored spans (CATextLayer re-draw, unfixable from the API side). Museion takes no CodeEdit dependency; Classis keeps its fork pin, untouched.
  • SwiftUI block editor (mode C, live preview): best-in-class typography, but structural interaction ceilings — no cross-block selection, per-block undo only, split/merge outside any undo stack, and lists shatter into per-bullet blocks. Each solvable, none for free; it pays in interaction-model decisions where TextKit2 pays in already-written presentation code.

Consequences

  • Typography stance: variable heading sizes and real paragraph spacing are required, and natively expressible — not a compromise to accept.
  • Reading toggle renders block-aware: blank-line split, per-paragraph inline parse, headings fonted by level. A monolithic single-Text .full markdown dump flattens block structure — the anti-pattern.
  • Paper-grade polish is not a deferred phase; it is iterative practice, applied whenever the writing surface feels short of calm.