Skip to content

Fix duplicate/delete node transforms and selection updates#51

Open
cbassuarez wants to merge 1 commit intomainfrom
seb/fix-duplicate-and-delete-for-node-kinds
Open

Fix duplicate/delete node transforms and selection updates#51
cbassuarez wants to merge 1 commit intomainfrom
seb/fix-duplicate-and-delete-for-node-kinds

Conversation

@cbassuarez
Copy link
Copy Markdown
Owner

Motivation

  • Duplicate/Delete editor actions were no-ops because command handlers did not emit canonical transform requests and keyboard shortcuts weren't wired to transforms.
  • The server-side edit API lacked canonical handlers for deleteNode/duplicateNode, so UI requests couldn't reliably update the document or selection.
  • Selection remained stale after node operations because transform responses didn't include updated selection logic.

Description

  • Wired editor commands to real handlers by adding handleDuplicate/handleDelete into the command context and hooking Duplicate/Delete menu commands and shortcuts to emit transform requests.
  • Split the editor transform entrypoints: introduced runTransform and exposed handleTransform (for TransformRequest) and handleEditorTransform (for internal EditorTransform) to avoid request-shape mismatches.
  • Implemented server-side edit handlers for new ops: applyDeleteNodeTransform and applyDuplicateNodeTransform, plus helpers findNodeWithParent, cloneNodeWithNewIds, and applyReplaceBodyNodesTransform, to update the source, index, and returned selectedId appropriately.
  • Updated the editor UI to call the canonical transform shape ({ op: ..., args: { id } }) for duplicate/delete and to update selection behavior: after delete select next sibling/prev/parent, after duplicate select the new copy.
  • Added integration tests covering duplicate/delete behavior at the edit API level to guard tree+index updates and selection changes.

Testing

  • Ran pnpm vitest packages/viewer/tests/edit-api.spec.ts; all tests passed (9 tests, 1 file), including the new duplicate/delete tests.
  • The changes were exercised by the added tests that assert document source, index presence, and returned selectedId after operations.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant