From 4a11bcacd94a6a0f1340b1741e8ce77d1c6d7e84 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Thu, 12 Jan 2023 17:51:38 +0800 Subject: [PATCH 1/2] feat:adjust range by shortcut --- src/editor/core/event/handlers/keydown.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/editor/core/event/handlers/keydown.ts b/src/editor/core/event/handlers/keydown.ts index 82d4718..cdf3a70 100644 --- a/src/editor/core/event/handlers/keydown.ts +++ b/src/editor/core/event/handlers/keydown.ts @@ -88,24 +88,30 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) { } else if (evt.key === KeyMap.Left) { if (isReadonly) return if (index > 0) { - const curIndex = index - 1 - rangeManager.setRange(curIndex, curIndex) + const curIndex = startIndex - 1 + // shift则向左扩大选区 + const anchorIndex = evt.shiftKey ? endIndex : curIndex + rangeManager.setRange(curIndex, anchorIndex) draw.render({ curIndex, isSubmitHistory: false, isComputeRowList: false }) + evt.preventDefault() } } else if (evt.key === KeyMap.Right) { if (isReadonly) return if (index < positionList.length - 1) { - const curIndex = index + 1 - rangeManager.setRange(curIndex, curIndex) + const curIndex = endIndex + 1 + // shift则向右扩大选区 + const anchorIndex = evt.shiftKey ? startIndex : curIndex + rangeManager.setRange(anchorIndex, curIndex) draw.render({ curIndex, isSubmitHistory: false, isComputeRowList: false }) + evt.preventDefault() } } else if (evt.key === KeyMap.Up || evt.key === KeyMap.Down) { if (isReadonly) return From 81ac4d8dc0177090ef11098c9916d156415b5db9 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Thu, 12 Jan 2023 17:58:22 +0800 Subject: [PATCH 2/2] docs:adjust selection by shortcut --- docs/guide/shortcut-internal.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/guide/shortcut-internal.md b/docs/guide/shortcut-internal.md index 4f13eab..7877567 100644 --- a/docs/guide/shortcut-internal.md +++ b/docs/guide/shortcut-internal.md @@ -12,9 +12,15 @@ ## ← 功能:向左移动 +## Shift + ← +功能:向左扩大选区 + ## → 功能:向右移动 +## Shift + → +功能:向右扩大选区 + ## ↑ 功能:向上移动