mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-09-19 17:37:29 +02:00
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
16 lines
442 B
TypeScript
16 lines
442 B
TypeScript
// 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;
|
|
}
|