docs/plans/2026-04-13-slate-v2-delete-text-post-rc-stabilization-plan.md
delete-text.ts Post-RC Stabilization PlanStabilize and simplify delete-text.ts after RC recovery work.
This is a structure plan, not a semantics plan.
The goal is:
The file is functionally green and structurally ugly.
Current evidence already banked:
pnpm --filter slate testSLATE_RUN_LEGACY_TRANSFORM_AUDIT=1 pnpm exec mocha --require ./config/babel/register.cjs ./packages/slate/test/legacy-transforms-fixtures.tspnpm exec turbo build --filter=./packages/slate --filter=./packages/slate-historypnpm exec turbo typecheck --filter=./packages/slate --filter=./packages/slate-historypnpm lint:fixCurrent reality:
slate suite is greenThis plan does not do any of these:
Before any refactor step:
Lock set:
pnpm --filter slate testTurn one large routine into one coordinator plus four private phases.
resolveDeleteTarget(...)Own:
void and elementReadOnly nudgingIt should return one explicit internal object instead of mutating ad hoc locals.
removeDeleteContents(...)Own:
It should also return the minimal facts later phases need:
reconcileDeleteStructure(...)Own:
This is where the policy split must become explicit:
resolveDeleteSelection(...)Own:
set_selectionThis is where forward/reverse inline spacer rules belong. They should not stay smeared across content-removal or structure-reconcile code.
Build one small internal plan object and pass it through the helpers.
Minimum fields:
startendisSingleTextisAcrossBlockspreserveEndBlockpreserveEmptyStartBlockPathremovedInteriorElementSiblingStructurestartNonEditableendNonEditableRule:
These should exist as private helpers, not repeated local policy blobs:
Legacy recovery rules are allowed to survive, but they must be named as such.
Examples:
shouldPreserveEmptyStartBlockForHangingRange(...)shouldKeepSplitTextAfterInteriorElementRemoval(...)Bad shape:
if ladders that encode the same policy three timesresolveDeleteTarget(...)removeDeleteContents(...)reconcileDeleteStructure(...)set_selection into
resolveDeleteSelection(...)Do not optimize blindly.
After the structural refactor, measure only these three delete lanes:
Decision rule:
Required after each meaningful phase:
Required at the end:
pnpm exec turbo build --filter=./packages/slate --filter=./packages/slate-historypnpm exec turbo typecheck --filter=./packages/slate --filter=./packages/slate-historypnpm lint:fixpnpm --filter slate testSLATE_RUN_LEGACY_TRANSFORM_AUDIT=1 pnpm exec mocha --require ./config/babel/register.cjs ./packages/slate/test/legacy-transforms-fixtures.tsStop the refactor immediately if any of these happens:
slate suite reopensThis plan is complete when:
delete-text.ts is split into named local phasesThis should be done after RC, not before.
The current file is ugly but green. That is acceptable for RC.
This plan exists so the team does not confuse “green” with “finished”.