Free, simple, and intuitive online database diagram editor and SQL generator.
JavaScript databasedatabase-designdatabase-diagramdatabase-schemadbmldiagram-editoreditorer-diagramerderdiagramindexeddbmariadbmcporacle-databaseoracle-dbpostgresqlschema-designsqlsql-serversqlite
Open note in tab after clicking edit button
haecheonleec0437b543345
diff --git a/src/components/EditorCanvas/Note.jsx b/src/components/EditorCanvas/Note.jsxindex 7a7976ba..f3abc282 100644--- a/src/components/EditorCanvas/Note.jsx+++ b/src/components/EditorCanvas/Note.jsx@@ -61,22 +61,18 @@ export default function Note({ data, onMouseDown }) {};const edit = () => {- if (layout.sidebar) {- setSelectedElement((prev) => ({- ...prev,- currentTab: Tab.NOTES,- }));- if (selectedElement.currentTab !== Tab.NOTES) return;+ setSelectedElement((prev) => ({+ ...prev,+ ...(layout.sidebar && { currentTab: Tab.NOTES }),+ ...(!layout.sidebar && { element: ObjectType.NOTE }),+ id: data.id,+ open: true,+ }));++ if (layout.sidebar && selectedElement.currentTab === Tab.NOTES) {document.getElementById(`scroll_note_${data.id}`).scrollIntoView({ behavior: "smooth" });- } else {- setSelectedElement((prev) => ({- ...prev,- element: ObjectType.NOTE,- id: data.id,- open: true,- }));}};diff --git a/src/components/EditorSidePanel/NotesTab/NotesTab.jsx b/src/components/EditorSidePanel/NotesTab/NotesTab.jsxindex 951fcad7..400fdab7 100644--- a/src/components/EditorSidePanel/NotesTab/NotesTab.jsx+++ b/src/components/EditorSidePanel/NotesTab/NotesTab.jsx@@ -1,20 +1,27 @@import { useState } from "react";import { Row, Col, Button, Collapse } from "@douyinfe/semi-ui";import { IconPlus } from "@douyinfe/semi-icons";-import { useNotes } from "../../../hooks";+import { useNotes, useSelect } from "../../../hooks";import Empty from "../Empty";import SearchBar from "./SearchBar";import NoteInfo from "./NoteInfo";export default function NotesTab() {const { notes, addNote } = useNotes();- const [activeKey, setActiveKey] = useState("");+ const { selectedElement, setSelectedElement } = useSelect();return (<><Row gutter={6}><Col span={16}>- <SearchBar setActiveKey={setActiveKey} />+ <SearchBar+ setActiveKey={(activeKey) =>+ setSelectedElement((prev) => ({+ ...prev,+ id: parseInt(activeKey),+ }))+ }+ /></Col><Col span={8}><Button icon={<IconPlus />} block onClick={() => addNote()}>@@ -26,8 +33,14 @@ export default function NotesTab() {<Empty title="No text notes" text="Add notes cuz why not!" />) : (<Collapse- activeKey={activeKey}- onChange={(k) => setActiveKey(k)}+ activeKey={selectedElement.open ? `${selectedElement.id}` : ""}+ onChange={(activeKey) => {+ setSelectedElement((prev) => ({+ ...prev,+ id: parseInt(activeKey),+ open: true,+ }));+ }}accordion>{notes.map((n, i) => (