@hexdspace/react 0.1.50 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +16 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -926,13 +926,13 @@ declare class VimController {
|
|
|
926
926
|
private readonly regions;
|
|
927
927
|
private readonly handleKey;
|
|
928
928
|
private readonly selection;
|
|
929
|
-
private readonly
|
|
929
|
+
private readonly modifierMovementActionsByRegion;
|
|
930
930
|
constructor(selection: SelectionController, regions?: VimRegionRegistry, handleKey?: VimHandleKeyUseCase);
|
|
931
931
|
handleRegisterRegionMeta(meta: VimRegionMeta): void;
|
|
932
932
|
handleUnregisterRegionMeta(key: RegionKey): void;
|
|
933
933
|
handleCharKey(char: string, e: KeyboardEvent): void;
|
|
934
934
|
handleEscape(e: KeyboardEvent): void;
|
|
935
|
-
setModifierMovementActions(
|
|
935
|
+
setModifierMovementActions(key: RegionKey, actions: VimModifierMovementActions | null): void;
|
|
936
936
|
handleModifiedMovement(dir: VimDirection, modifier: VimMovementModifier, e: KeyboardEvent): void;
|
|
937
937
|
resetActiveScope(): void;
|
|
938
938
|
getSelection(): SelectionController;
|
|
@@ -956,7 +956,7 @@ type VimBindingOptions = {
|
|
|
956
956
|
allowArrowKeys?: boolean;
|
|
957
957
|
modifierMovementActions?: VimModifierMovementActions;
|
|
958
958
|
};
|
|
959
|
-
declare function useVimBindings(keyboardScopeId: string, options?: VimBindingOptions): void;
|
|
959
|
+
declare function useVimBindings(regionKey: RegionKey, keyboardScopeId: string, options?: VimBindingOptions): void;
|
|
960
960
|
|
|
961
961
|
type UseVimRegionArgs = {
|
|
962
962
|
key: RegionKey;
|
package/dist/index.js
CHANGED
|
@@ -3576,7 +3576,7 @@ var VimController = class {
|
|
|
3576
3576
|
regions;
|
|
3577
3577
|
handleKey;
|
|
3578
3578
|
selection;
|
|
3579
|
-
|
|
3579
|
+
modifierMovementActionsByRegion = /* @__PURE__ */ new Map();
|
|
3580
3580
|
constructor(selection, regions = new VimRegionRegistry(), handleKey = new VimHandleKeyUseCase(
|
|
3581
3581
|
selection.getHandle(),
|
|
3582
3582
|
selection.getQuery(),
|
|
@@ -3599,19 +3599,20 @@ var VimController = class {
|
|
|
3599
3599
|
handleEscape(e) {
|
|
3600
3600
|
this.handleKey.handleEscape(e);
|
|
3601
3601
|
}
|
|
3602
|
-
setModifierMovementActions(
|
|
3602
|
+
setModifierMovementActions(key, actions) {
|
|
3603
|
+
const regionKey = toRegionKeyString(key);
|
|
3603
3604
|
if (!actions) {
|
|
3604
|
-
this.
|
|
3605
|
+
this.modifierMovementActionsByRegion.delete(regionKey);
|
|
3605
3606
|
return;
|
|
3606
3607
|
}
|
|
3607
|
-
this.
|
|
3608
|
+
this.modifierMovementActionsByRegion.set(regionKey, actions);
|
|
3608
3609
|
}
|
|
3609
3610
|
handleModifiedMovement(dir, modifier, e) {
|
|
3610
3611
|
const scopeId = this.selection.getActiveScope();
|
|
3611
3612
|
if (!scopeId) return;
|
|
3612
3613
|
const activeKey = this.selection.getActiveRegion(scopeId);
|
|
3613
3614
|
if (!activeKey) return;
|
|
3614
|
-
const actions = this.
|
|
3615
|
+
const actions = this.modifierMovementActionsByRegion.get(toRegionKeyString(activeKey));
|
|
3615
3616
|
const action = actions?.[modifier]?.[dir];
|
|
3616
3617
|
if (!action) return;
|
|
3617
3618
|
const itemId = this.selection.getActiveItem(activeKey);
|
|
@@ -3648,6 +3649,9 @@ var createVimController = controllerFactory(
|
|
|
3648
3649
|
};
|
|
3649
3650
|
}
|
|
3650
3651
|
);
|
|
3652
|
+
function toRegionKeyString(key) {
|
|
3653
|
+
return `${key.scopeId}.${key.regionId}`;
|
|
3654
|
+
}
|
|
3651
3655
|
|
|
3652
3656
|
// src/feature/vim-navigation/infra/web/react/VimControllerProvider.tsx
|
|
3653
3657
|
import { createContext as createContext5, useContext as useContext6 } from "react";
|
|
@@ -3670,7 +3674,7 @@ function notify(entry) {
|
|
|
3670
3674
|
notifySub(entry.ownerId);
|
|
3671
3675
|
}
|
|
3672
3676
|
}
|
|
3673
|
-
function useVimBindings(keyboardScopeId, options = {}) {
|
|
3677
|
+
function useVimBindings(regionKey, keyboardScopeId, options = {}) {
|
|
3674
3678
|
const vim = useVimController();
|
|
3675
3679
|
const enabled = options.enabled ?? true;
|
|
3676
3680
|
const allowArrowKeys = options.allowArrowKeys ?? true;
|
|
@@ -3713,12 +3717,13 @@ function useVimBindings(keyboardScopeId, options = {}) {
|
|
|
3713
3717
|
};
|
|
3714
3718
|
}, [enabled, handleOwnerChange, keyboardScopeId]);
|
|
3715
3719
|
useEffect7(() => {
|
|
3716
|
-
if (!enabled
|
|
3720
|
+
if (!enabled) {
|
|
3721
|
+
vim.setModifierMovementActions(regionKey, null);
|
|
3717
3722
|
return;
|
|
3718
3723
|
}
|
|
3719
|
-
vim.setModifierMovementActions(
|
|
3720
|
-
return () => vim.setModifierMovementActions(
|
|
3721
|
-
}, [enabled,
|
|
3724
|
+
vim.setModifierMovementActions(regionKey, modifierMovementActions ?? null);
|
|
3725
|
+
return () => vim.setModifierMovementActions(regionKey, null);
|
|
3726
|
+
}, [enabled, modifierMovementActions, regionKey, vim]);
|
|
3722
3727
|
const bindings = useMemo6(() => {
|
|
3723
3728
|
if (!enabled || !isOwner) {
|
|
3724
3729
|
return [];
|
|
@@ -3899,7 +3904,7 @@ function useVimRegion(containerRef, args) {
|
|
|
3899
3904
|
keyboard.handleEnableScope(keyboardScopeId);
|
|
3900
3905
|
return () => keyboard.handleDisableScope(keyboardScopeId);
|
|
3901
3906
|
}, [bindKeys, keyboard, keyboardScopeId]);
|
|
3902
|
-
useVimBindings(keyboardScopeId, {
|
|
3907
|
+
useVimBindings(args.key, keyboardScopeId, {
|
|
3903
3908
|
enabled: bindKeys,
|
|
3904
3909
|
allowArrowKeys: args.allowArrowKeys,
|
|
3905
3910
|
modifierMovementActions: args.modifierMovementActions
|