update node layout
This commit is contained in:
1 parent
3b1091cf87
commit
6894aacfd1
5 files changed
+25
-26
No files matched your search
@@ -19,7 +19,7 @@ import {
|
||||
useWorkspace,
|
||||
} from "../contexts/workspace-context";
|
||||
import i18n from "../misc/i18n";
|
||||
import { Hotkey, isMacos, useKeyDown } from "../misc/keys";
|
||||
import { Hotkey, isMacos, useKeyPress } from "../misc/keys";
|
||||
import { mergeClassNames } from "../misc/util";
|
||||
import { FilterOption, Graph } from "./graph";
|
||||
import "./register-node";
|
||||
@@ -129,7 +129,7 @@ export const Editor: FC<EditorProps> = ({ onChange, data: editor, ...props }) =>
|
||||
);
|
||||
|
||||
const keysRef = useRef<HTMLDivElement>(null);
|
||||
useKeyDown(
|
||||
useKeyPress(
|
||||
[
|
||||
Hotkey.Copy,
|
||||
Hotkey.Replace,
|
||||
@@ -148,7 +148,7 @@ export const Editor: FC<EditorProps> = ({ onChange, data: editor, ...props }) =>
|
||||
}
|
||||
);
|
||||
|
||||
useKeyDown([Hotkey.Undo, Hotkey.Redo], null, (e, key) => {
|
||||
useKeyPress([Hotkey.Undo, Hotkey.Redo], null, (e, key) => {
|
||||
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import { getNodeType } from "../misc/b3type";
|
||||
import * as b3util from "../misc/b3util";
|
||||
import { modal } from "../misc/hooks";
|
||||
import i18n from "../misc/i18n";
|
||||
import { Hotkey, isMacos, useKeyDown } from "../misc/keys";
|
||||
import { Hotkey, isMacos, useKeyPress } from "../misc/keys";
|
||||
import Path from "../misc/path";
|
||||
|
||||
const { DirectoryTree } = Tree;
|
||||
@@ -631,7 +631,7 @@ export const Explorer: FC = () => {
|
||||
|
||||
const keysRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useKeyDown([Hotkey.F2, isMacos ? Hotkey.Enter : ""], keysRef, (event) => {
|
||||
useKeyPress([Hotkey.F2, isMacos ? Hotkey.Enter : ""], keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
const node = findFile(selectedKeys[0], workspace.fileTree!);
|
||||
if (node && node !== workspace.fileTree && !node.editing) {
|
||||
@@ -639,7 +639,7 @@ export const Explorer: FC = () => {
|
||||
}
|
||||
});
|
||||
|
||||
useKeyDown([Hotkey.Delete, isMacos ? Hotkey.MacDelete : ""], keysRef, (event) => {
|
||||
useKeyPress([Hotkey.Delete, isMacos ? Hotkey.MacDelete : ""], keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
const node = findFile(selectedKeys[0], workspace.fileTree!);
|
||||
if (node && node !== workspace.fileTree) {
|
||||
@@ -647,7 +647,7 @@ export const Explorer: FC = () => {
|
||||
}
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.Escape, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.Escape, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
const node = findFile(selectedKeys[0], workspace.fileTree!);
|
||||
if (node) {
|
||||
@@ -656,7 +656,7 @@ export const Explorer: FC = () => {
|
||||
}
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.Duplicate, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.Duplicate, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
const node = findFile(selectedKeys[0], workspace.fileTree!);
|
||||
if (node && node.isLeaf) {
|
||||
@@ -664,7 +664,7 @@ export const Explorer: FC = () => {
|
||||
}
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.Copy, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.Copy, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
const node = findFile(selectedKeys[0], workspace.fileTree!);
|
||||
if (node && node.isLeaf) {
|
||||
@@ -672,7 +672,7 @@ export const Explorer: FC = () => {
|
||||
}
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.Paste, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.Paste, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
const node = findFile(selectedKeys[0], workspace.fileTree!);
|
||||
if (node) {
|
||||
|
||||
@@ -254,15 +254,15 @@ export const TreeNodeStyle: { [s in TreeNodeState]?: { [n in ShapeName]?: NodeSt
|
||||
},
|
||||
highlightargs: {
|
||||
"args-bg": { visibility: "visible" },
|
||||
"args-text": { fill: "white", fontWeight: "bolder" },
|
||||
"args-text": { fill: "white" },
|
||||
},
|
||||
highlightinput: {
|
||||
"input-bg": { visibility: "visible" },
|
||||
"input-text": { fill: "white", fontWeight: "bolder" },
|
||||
"input-text": { fill: "white" },
|
||||
},
|
||||
highlightoutput: {
|
||||
"output-bg": { visibility: "visible" },
|
||||
"output-text": { fill: "white", fontWeight: "bolder" },
|
||||
"output-text": { fill: "white" },
|
||||
},
|
||||
highlightgray: {
|
||||
"args-text": { fill: "#666" },
|
||||
@@ -414,7 +414,7 @@ class TreeNode extends Rect {
|
||||
text: this._data.name,
|
||||
textBaseline: "top",
|
||||
x: this._nodeLayout === "compact" ? 26 : 46,
|
||||
y: 5,
|
||||
y: isMacos ? 3 : 2,
|
||||
},
|
||||
container
|
||||
);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { app } from "@electron/remote";
|
||||
import { useKeyPress } from "ahooks";
|
||||
import { Button, Flex, Layout, Space, Tabs, Tag, Tooltip } from "antd";
|
||||
import { FC, useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -12,7 +11,7 @@ import { useShallow } from "zustand/react/shallow";
|
||||
import { useSetting } from "../contexts/setting-context";
|
||||
import { EditorStore, useWorkspace } from "../contexts/workspace-context";
|
||||
import { modal } from "../misc/hooks";
|
||||
import { Hotkey, isMacos, setInputFocus, useKeyDown } from "../misc/keys";
|
||||
import { Hotkey, isMacos, setInputFocus, useKeyPress } from "../misc/keys";
|
||||
import Path from "../misc/path";
|
||||
import { Editor } from "./editor";
|
||||
import { Explorer } from "./explorer";
|
||||
@@ -47,21 +46,21 @@ export const Workspace: FC = () => {
|
||||
|
||||
const keysRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useKeyDown(Hotkey.Build, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.Build, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
workspace.buildProject();
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.Save, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.Save, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
workspace.save();
|
||||
});
|
||||
|
||||
useKeyPress(Hotkey.CloseEditor, (event) => {
|
||||
useKeyPress(Hotkey.CloseEditor, null, (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.CloseEditor, null, (event) => {
|
||||
useKeyPress(Hotkey.CloseEditor, null, (event) => {
|
||||
if (workspace.editing) {
|
||||
event.preventDefault();
|
||||
if (workspace.editing.changed) {
|
||||
@@ -73,17 +72,17 @@ export const Workspace: FC = () => {
|
||||
keysRef.current?.focus();
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.SearchTree, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.SearchTree, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
workspace.onShowingSearch(true);
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.SearchNode, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.SearchNode, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
workspace.editing?.dispatch?.("searchNode");
|
||||
});
|
||||
|
||||
useKeyDown(Hotkey.JumpNode, keysRef, (event) => {
|
||||
useKeyPress(Hotkey.JumpNode, keysRef, (event) => {
|
||||
event.preventDefault();
|
||||
workspace.editing?.dispatch?.("jumpNode");
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user