select the editing node when jump from edit subtree
This commit is contained in:
1 parent
734879a736
commit
c933541f3e
5 files changed
+27
-15
No files matched your search
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "behavior3editor",
|
"name": "behavior3editor",
|
||||||
"version": "1.6.0",
|
"version": "1.7.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "behavior3editor",
|
"name": "behavior3editor",
|
||||||
"version": "1.6.0",
|
"version": "1.7.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "behavior3editor",
|
"name": "behavior3editor",
|
||||||
"version": "1.6.0",
|
"version": "1.7.0",
|
||||||
"main": "dist-electron/main/index.js",
|
"main": "dist-electron/main/index.js",
|
||||||
"description": "行为树编辑器",
|
"description": "行为树编辑器",
|
||||||
"author": "zhandouxiaojiji & codetypes",
|
"author": "zhandouxiaojiji & codetypes",
|
||||||
|
|||||||
+1
-1
Submodule src/behavior3 updated: a7868c4721...06a5db5989.
@@ -660,7 +660,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
|||||||
const data = findSubtree(findDataById(editor.selectedId));
|
const data = findSubtree(findDataById(editor.selectedId));
|
||||||
if (data?.path) {
|
if (data?.path) {
|
||||||
const path = `${workspace.workdir}/${data.path}`;
|
const path = `${workspace.workdir}/${data.path}`;
|
||||||
workspace.open(path);
|
workspace.open(path, Number(editor.selectedId) - Number(data.id) + 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1075,6 +1075,15 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
|||||||
editor.size.width = editorSize.width;
|
editor.size.width = editorSize.width;
|
||||||
editor.size.height = editorSize.height;
|
editor.size.height = editorSize.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof editor.editNode === "number") {
|
||||||
|
const id = editor.editNode.toString();
|
||||||
|
selectNode(null);
|
||||||
|
setTimeout(() => {
|
||||||
|
editor.graph.focusItem(id);
|
||||||
|
selectNode(id);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// check should subtree
|
// check should subtree
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export class EditorStore {
|
|||||||
graphMatrix?: Matrix;
|
graphMatrix?: Matrix;
|
||||||
graph!: TreeGraph;
|
graph!: TreeGraph;
|
||||||
|
|
||||||
editNode: EditNode | null = null;
|
editNode: EditNode | number | null = null;
|
||||||
|
|
||||||
dispatch!: (event: EditEvent, data?: unknown) => void;
|
dispatch!: (event: EditEvent, data?: unknown) => void;
|
||||||
|
|
||||||
@@ -139,8 +139,8 @@ export type WorkspaceStore = {
|
|||||||
isShowingSearch: boolean;
|
isShowingSearch: boolean;
|
||||||
onShowingSearch: (isShowingSearch: boolean) => void;
|
onShowingSearch: (isShowingSearch: boolean) => void;
|
||||||
|
|
||||||
open: (path: string) => void;
|
open: (path: string, selectedNode?: number) => void;
|
||||||
edit: (path: string) => void;
|
edit: (path: string, selectedNode?: number) => void;
|
||||||
close: (path: string) => void;
|
close: (path: string) => void;
|
||||||
find: (path: string) => EditorStore | undefined;
|
find: (path: string) => EditorStore | undefined;
|
||||||
relative: (path: string) => string;
|
relative: (path: string) => string;
|
||||||
@@ -402,7 +402,7 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({
|
|||||||
set({ isShowingSearch });
|
set({ isShowingSearch });
|
||||||
},
|
},
|
||||||
|
|
||||||
open: (path) => {
|
open: (path, selectedNode) => {
|
||||||
path = fs.realpathSync(path);
|
path = fs.realpathSync(path);
|
||||||
const workspace = get();
|
const workspace = get();
|
||||||
let editor = workspace.editors.find((v) => v.path === path);
|
let editor = workspace.editors.find((v) => v.path === path);
|
||||||
@@ -412,25 +412,28 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({
|
|||||||
workspace.editors.push(editor);
|
workspace.editors.push(editor);
|
||||||
set({ editors: workspace.editors });
|
set({ editors: workspace.editors });
|
||||||
workspace.updateFileMeta(editor);
|
workspace.updateFileMeta(editor);
|
||||||
workspace.edit(editor.path);
|
workspace.edit(editor.path, selectedNode);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
message.error(`invalid file: ${path}`);
|
message.error(`invalid file: ${path}`);
|
||||||
}
|
}
|
||||||
} else if (workspace.editing !== editor) {
|
} else if (workspace.editing !== editor) {
|
||||||
workspace.edit(editor.path);
|
workspace.edit(editor.path, selectedNode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
edit: (path) => {
|
edit: (path, selectedNode) => {
|
||||||
const workspace = get();
|
const workspace = get();
|
||||||
const editor = workspace.editors.find((v) => v.path === path);
|
const editor = workspace.editors.find((v) => v.path === path);
|
||||||
|
if (editor && selectedNode) {
|
||||||
|
editor.editNode = selectedNode;
|
||||||
|
}
|
||||||
set({ editing: editor, editingNode: null, editingTree: null });
|
set({ editing: editor, editingNode: null, editingTree: null });
|
||||||
if (editor) {
|
if (editor) {
|
||||||
if (editor.editNode) {
|
if (!editor.editNode) {
|
||||||
workspace.onEditingNode(editor.editNode);
|
|
||||||
} else {
|
|
||||||
workspace.onEditingTree(editor);
|
workspace.onEditingTree(editor);
|
||||||
|
} else if (typeof editor.editNode === "object") {
|
||||||
|
workspace.onEditingNode(editor.editNode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set({ editingNode: null, editingTree: null });
|
set({ editingNode: null, editingTree: null });
|
||||||
|
|||||||
Reference in new issue
Block a user