7f432138df
Inventory of the 29 core plugins (22 done, 2 partial, 5 missing), 80 community plugins with a verdict each, a ranked roadmap with 8 ready briefs, the Bases spec (D1-D13) and 20 tasks, ASCII wireframes of the Bases screens (PaperCraft was not running). crates/bases is registered at layer L2. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
TASK paste-url-selection: pasting a URL over selected text makes a Markdown link
Runs through OpenCode (specs/agents/opencode-runbook.md is attached automatically).
OWNS
crates/editor/src/keys.rs(ONE new public function appended beforemod tests, plus its unit tests in that module; no other edit)crates/editor/tests/paste_url.rs
FILES TO OPEN
crates/editor/src/keys.rs(Edit,wrap_selection, the pure-function style)crates/ui-egui/src/shell/app/editor/vim_edit.rs:215andcrates/ui-egui/src/shell/attachment_drop/mod.rs:177(whereEvent::Paste(text)is seen) for context only
GOAL / API
pub fn on_paste_url(text: &str, sel: Range<usize>, pasted: &str) -> Option<Edit>:
Noneunless the selection is non-empty, single-line, at most 500 bytes, not inside a code fence/inline code/link/URL, andpasted.trim()is one URL: schemehttporhttps(case-insensitive), no whitespace, at most 2 048 bytes, a host with a dot orlocalhost.- Result: selection replaced by
[selected](url); the cursor ends after). Selected text containing]or[is escaped with\. An angle-bracketed pasted URL<https://x>is unwrapped. When the selection is itself a bare URL,None(a normal paste). - If the selection is already wrapped in
[], replace only the(...)part when present. - No network access of any kind (no title fetching).
TESTS
crates/editor/tests/paste_url.rs: plain word, phrase, bracket characters, javascript: and file: refused, URL with spaces refused, empty selection None, selection inside a fenced block None, multi-line selection None, 501-byte selection None, unicode selection offsets (use split_at_checked, no [a..b] on input), idempotence of a second paste.
VERIFY
export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-editor paste_url
cargo clippy -p notescraft-editor --all-targets -- -D warnings
rustfmt --edition 2024 crates/editor/src/keys.rs crates/editor/tests/paste_url.rs
DO NOT
Wire the paste event (follow-up in ui-egui); fetch page titles (Auto Link Title is SKIP); add a setting.