Skip to content

feat: Copy/Move selection to new note via context menu - #81

Draft
adam4813 with Copilot wants to merge 3 commits into
mainfrom
copilot/add-extract-selection-to-new-note
Draft

feat: Copy/Move selection to new note via context menu#81
adam4813 with Copilot wants to merge 3 commits into
mainfrom
copilot/add-extract-selection-to-new-note

Conversation

Copilot AI commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Right-clicking a text selection in the rendered (WYSIWYG) or source editor now offers two actions: Copy to New Note (duplicates selection into a new file) and Move to New Note (removes selection, inserts a [[wikilink]] back to the new note). Cancelling the name prompt or a creation failure leaves the original note untouched.

Changes

  • packages/editor/src/types.ts — Added extractToNewNote(content, mode) to EditorCallbacks; returns the new note's path or null on cancel/failure.

  • apps/web/src/state/use-editor-callbacks.tsx — Implements extractToNewNote via usePromptDialog + api.create; opens the new note in a tab. Return type changed from EditorCallbacks to { callbacks, promptDialog } — callers must render promptDialog.

  • packages/editor/src/rendered-editor.tsx — Accepts onRegisterContextMenu prop; registers a builder that surfaces the two extract actions when TipTap has a non-empty selection and the right-click target is within .editor-column--rendered. Selection from/to are captured at menu-open time so the async replace is positionally stable.

  • packages/editor/src/native-source-editor.tsx — Same pattern for the textarea pane: checks selectionStart !== selectionEnd, scopes to .editor-column--split, uses setRangeText for the move replacement.

  • apps/web/src/components/note-editor.tsx — Adds a dedicated sourceCtxBuilder slot (registerSourceCtxBuilder) passed to NativeSourceEditor, plus a resolveCtxItems helper that probes builders in priority order (customCtxBuilder → sourceCtxBuilder → descriptorCtxBuilder). This keeps split-mode right-clicks in each pane independent without changing the existing CustomContextMenuBuilder API.

Copilot AI and others added 2 commits August 28, 2026 02:36
- Add `extractToNewNote` callback to `EditorCallbacks`
- Update `useEditorCallbacks` to implement `extractToNewNote` via
  `usePromptDialog` and return `{ callbacks, promptDialog }`
- Register selection-aware context menu builder in `RenderedEditor`
  (TipTap) and `NativeSourceEditor` (textarea) with proper column
  scoping for split mode
- Add `sourceCtxBuilder` slot + `resolveCtxItems` to `NoteEditor` so
  both panes are handled in split mode independently

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ability to extract a selection to a new note feat: Copy/Move selection to new note via context menu Aug 28, 2026
Copilot AI requested a review from adam4813 August 28, 2026 02:38
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.

Add ability to extract a selection to a new note (move or just copy)

2 participants