docs/solutions/ui-bugs/2026-03-30-docs-demos-must-clone-reusable-values-per-editor.md
The docs app was mounting multiple editors from the same reusable Slate value object. On /docs/table, the generic table-demo and the disable-merge table demo both started from the same tableValue tree, so Slate's DOM-to-node bookkeeping could end up pointing at the wrong mounted editor.
Unable to find the path for Slate node: {"text":"Heading","bold":true}.findPathtoSlatePointtoSlateRangeEditable.useMemo[onDOMSelectionChange]node_modules/.bun mirror could also break docs compilation with the unrelated is-hotkey parse error.3002 kept serving old code, so the first browser retest did not prove anything.Clone reusable demo values before passing them into usePlateEditor, so every mounted docs editor owns its own Slate tree.
import cloneDeep from 'lodash/cloneDeep.js';
export const createDemoValueSnapshot = <T,>(value: T): T => cloneDeep(value);
Use that helper for the generic demo renderer and the custom table no-merge demo:
const editor = usePlateEditor({
plugins: EditorKit,
value: createDemoValueSnapshot(DEMO_VALUES[id]),
});
const editor = usePlateEditor({
plugins: [
...EditorKit,
TablePlugin.configure({
options: {
disableMerge: true,
},
}),
],
value: createDemoValueSnapshot(tableValue),
});
Add a regression test that proves the same reusable demo value produces isolated snapshots:
const snapshotA = createDemoValueSnapshot(DEMO_VALUES.table);
const snapshotB = createDemoValueSnapshot(DEMO_VALUES.table);
expect(snapshotA[2]).not.toBe(DEMO_VALUES.table[2]);
expect(snapshotA[2]).not.toBe(snapshotB[2]);
Slate expects each mounted editor to own its own node graph. Reusing one static value object across multiple editors breaks that assumption, so DOM selection can resolve a node from one mounted editor against another editor's tree and fail path lookup. Deep-cloning the initial value restores one-editor-one-tree ownership and keeps Slate's internal DOM mappings stable.
DEMO_VALUES[id], snapshot the value at the editor boundary..bun parse failures while CI is green, clean non-versioned local env first:
node_modulesapps/www/.next and apps/www/.contentlayer.turbopnpm install.claude/docs/solutions/ui-bugs/2026-03-27-version-history-demo-must-clone-snapshots-per-editor.md