Wrap selected text with typed pairs (#119)

Adds modular selection-pair handling for the rich editor and source mode so typing (, {, [, ', " or ` around a selection wraps it instead of replacing it.

Reviewed-on: https://codeberg.org/ArkHost/HelixNotes/pulls/119
This commit is contained in:
MF
2026-06-16 14:59:14 +02:00
committed by ArkHost
parent 7e480ad7e2
commit 8454f2eca8
4 changed files with 83 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
// Shared source of truth for editor behaviors that wrap an active selection.
// Keep this small: only characters users reasonably expect to form pairs.
const selectionPairs: Record<string, string> = {
'(': ')',
'{': '}',
'[': ']',
"'": "'",
'"': '"',
'`': '`',
};
// Returns the closing character for a typed wrapper key, or null to pass through.
export function getSelectionPair(key: string) {
return selectionPairs[key] ?? null;
}