Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/docs/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ wsh editconfig
| app:hideaibutton <VersionBadge version="v0.14" /> | bool | Set to true to hide the AI button in the tab bar (defaults to false) |
| app:disablectrlshiftarrows <VersionBadge version="v0.14" /> | bool | Set to true to disable Ctrl+Shift+Arrow keybindings for block navigation (defaults to false) |
| app:disablectrlshiftdisplay <VersionBadge version="v0.14" /> | bool | Set to true to disable the Ctrl+Shift visual indicator display (defaults to false) |
| app:focusfollowscursor <VersionBadge version="v0.14" /> | string | Controls whether block focus follows cursor movement: `"off"` (default), `"on"` (all blocks), or `"term"` (terminal blocks only) |
| ai:preset | string | the default AI preset to use |
| ai:baseurl | string | Set the AI Base Url (must be OpenAI compatible) |
| ai:apitoken | string | your AI api token |
Expand Down Expand Up @@ -122,6 +123,7 @@ For reference, this is the current default configuration (v0.14.0):
"app:hideaibutton": false,
"app:disablectrlshiftarrows": false,
"app:disablectrlshiftdisplay": false,
"app:focusfollowscursor": "off",
"autoupdate:enabled": true,
"autoupdate:installonquit": true,
"autoupdate:intervalms": 3600000,
Expand Down
39 changes: 38 additions & 1 deletion frontend/app/block/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import { CenteredDiv } from "@/element/quickelems";
import { useDebouncedNodeInnerRect } from "@/layout/index";
import { counterInc } from "@/store/counters";
import {
atoms,
getBlockComponentModel,
getSettingsKeyAtom,
registerBlockComponentModel,
unregisterBlockComponentModel,
} from "@/store/global";
Expand Down Expand Up @@ -147,6 +149,9 @@ const BlockFull = memo(({ nodeModel, viewModel }: FullBlockProps) => {
const [blockData] = useWaveObjectValue<Block>(makeORef("block", nodeModel.blockId));
const isFocused = useAtomValue(nodeModel.isFocused);
const disablePointerEvents = useAtomValue(nodeModel.disablePointerEvents);
const isResizing = useAtomValue(nodeModel.isResizing);
const modalOpen = useAtomValue(atoms.modalOpen);
const focusFollowsCursorMode = useAtomValue(getSettingsKeyAtom("app:focusfollowscursor")) ?? "off";
const innerRect = useDebouncedNodeInnerRect(nodeModel);
const noPadding = useAtomValueSafe(viewModel.noPadding);

Expand Down Expand Up @@ -220,10 +225,42 @@ const BlockFull = memo(({ nodeModel, viewModel }: FullBlockProps) => {
return;
}
focusElemRef.current?.focus({ preventScroll: true });
}, []);
}, [viewModel]);

const focusFromPointerEnter = useCallback(
(event: React.PointerEvent<HTMLDivElement>) => {
const focusFollowsCursorEnabled =
focusFollowsCursorMode === "on" ||
(focusFollowsCursorMode === "term" && blockData?.meta?.view === "term");
if (!focusFollowsCursorEnabled || event.pointerType === "touch" || event.buttons > 0) {
return;
}
if (modalOpen || disablePointerEvents || isResizing) {
return;
}
if (isFocused && focusedBlockId() === nodeModel.blockId) {
return;
}
setFocusTarget();
if (!isFocused) {
nodeModel.focusNode();
}
},
[
focusFollowsCursorMode,
blockData?.meta?.view,
modalOpen,
disablePointerEvents,
isResizing,
isFocused,
nodeModel,
setFocusTarget,
]
);

const blockModel: BlockComponentModel2 = {
onClick: setBlockClickedTrue,
onPointerEnter: focusFromPointerEnter,
onFocusCapture: handleChildFocus,
blockRef: blockRef,
};
Expand Down
1 change: 1 addition & 0 deletions frontend/app/block/blockframe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const BlockFrame_Default_Component = (props: BlockFrameProps) => {
})}
data-blockid={nodeModel.blockId}
onClick={blockModel?.onClick}
onPointerEnter={blockModel?.onPointerEnter}
onFocusCapture={blockModel?.onFocusCapture}
ref={blockModel?.blockRef}
style={
Expand Down
1 change: 1 addition & 0 deletions frontend/app/block/blocktypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface SubBlockProps {

export interface BlockComponentModel2 {
onClick?: () => void;
onPointerEnter?: React.PointerEventHandler<HTMLDivElement>;
onFocusCapture?: React.FocusEventHandler<HTMLDivElement>;
blockRef?: React.RefObject<HTMLDivElement>;
}
Expand Down
1 change: 1 addition & 0 deletions frontend/types/gotypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ declare global {
"app:hideaibutton"?: boolean;
"app:disablectrlshiftarrows"?: boolean;
"app:disablectrlshiftdisplay"?: boolean;
"app:focusfollowscursor"?: string;
"feature:waveappbuilder"?: boolean;
"ai:*"?: boolean;
"ai:preset"?: string;
Expand Down
1 change: 1 addition & 0 deletions pkg/wconfig/defaultconfig/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"app:hideaibutton": false,
"app:disablectrlshiftarrows": false,
"app:disablectrlshiftdisplay": false,
"app:focusfollowscursor": "off",
"autoupdate:enabled": true,
"autoupdate:installonquit": true,
"autoupdate:intervalms": 3600000,
Expand Down
1 change: 1 addition & 0 deletions pkg/wconfig/metaconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
ConfigKey_AppHideAiButton = "app:hideaibutton"
ConfigKey_AppDisableCtrlShiftArrows = "app:disablectrlshiftarrows"
ConfigKey_AppDisableCtrlShiftDisplay = "app:disablectrlshiftdisplay"
ConfigKey_AppFocusFollowsCursor = "app:focusfollowscursor"

ConfigKey_FeatureWaveAppBuilder = "feature:waveappbuilder"

Expand Down
1 change: 1 addition & 0 deletions pkg/wconfig/settingsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type SettingsType struct {
AppHideAiButton bool `json:"app:hideaibutton,omitempty"`
AppDisableCtrlShiftArrows bool `json:"app:disablectrlshiftarrows,omitempty"`
AppDisableCtrlShiftDisplay bool `json:"app:disablectrlshiftdisplay,omitempty"`
AppFocusFollowsCursor string `json:"app:focusfollowscursor,omitempty" jsonschema:"enum=off,enum=on,enum=term"`

FeatureWaveAppBuilder bool `json:"feature:waveappbuilder,omitempty"`

Expand Down
8 changes: 8 additions & 0 deletions schema/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
"app:disablectrlshiftdisplay": {
"type": "boolean"
},
"app:focusfollowscursor": {
"type": "string",
"enum": [
"off",
"on",
"term"
]
},
"feature:waveappbuilder": {
"type": "boolean"
},
Expand Down