Database diagrams editor that allows you to visualize and design your DB with a single query.
TypeScript databasedbdb-migrationeditorerdmariadbmssqlmysqlpostgresqlreactreact-flowschema-migrationssqlsqlitetypescriptvisualizationxyflow
fix: improve title name edit interaction (#367)
Favor84e7591d0586
diff --git a/src/globals.css b/src/globals.cssindex 95a3908f..cd78f914 100644--- a/src/globals.css+++ b/src/globals.css@@ -3,69 +3,73 @@@tailwind utilities;@layer base {- :root {- --background: 0 0% 100%;- --foreground: 222.2 84% 4.9%;- --card: 0 0% 100%;- --card-foreground: 222.2 84% 4.9%;- --popover: 0 0% 100%;- --popover-foreground: 222.2 84% 4.9%;- --primary: 222.2 47.4% 11.2%;- --primary-foreground: 210 40% 98%;- --secondary: 210 40% 96.1%;- --secondary-foreground: 222.2 47.4% 11.2%;- --muted: 210 40% 96.1%;- --muted-foreground: 215.4 16.3% 46.9%;- --accent: 210 40% 96.1%;- --accent-foreground: 222.2 47.4% 11.2%;- --destructive: 0 84.2% 60.2%;- --destructive-foreground: 210 40% 98%;- --border: 214.3 31.8% 91.4%;- --input: 214.3 31.8% 91.4%;- --ring: 222.2 84% 4.9%;- --radius: 0.5rem;- --chart-1: 12 76% 61%;- --chart-2: 173 58% 39%;- --chart-3: 197 37% 24%;- --chart-4: 43 74% 66%;- --chart-5: 27 87% 67%;- --subtitle: 215.3 19.3% 34.5%;- }+ :root {+ --background: 0 0% 100%;+ --foreground: 222.2 84% 4.9%;+ --card: 0 0% 100%;+ --card-foreground: 222.2 84% 4.9%;+ --popover: 0 0% 100%;+ --popover-foreground: 222.2 84% 4.9%;+ --primary: 222.2 47.4% 11.2%;+ --primary-foreground: 210 40% 98%;+ --secondary: 210 40% 96.1%;+ --secondary-foreground: 222.2 47.4% 11.2%;+ --muted: 210 40% 96.1%;+ --muted-foreground: 215.4 16.3% 46.9%;+ --accent: 210 40% 96.1%;+ --accent-foreground: 222.2 47.4% 11.2%;+ --destructive: 0 84.2% 60.2%;+ --destructive-foreground: 210 40% 98%;+ --border: 214.3 31.8% 91.4%;+ --input: 214.3 31.8% 91.4%;+ --ring: 222.2 84% 4.9%;+ --radius: 0.5rem;+ --chart-1: 12 76% 61%;+ --chart-2: 173 58% 39%;+ --chart-3: 197 37% 24%;+ --chart-4: 43 74% 66%;+ --chart-5: 27 87% 67%;+ --subtitle: 215.3 19.3% 34.5%;+ }- .dark {- --background: 222.2 84% 4.9%;- --foreground: 210 40% 98%;- --card: 222.2 84% 4.9%;- --card-foreground: 210 40% 98%;- --popover: 222.2 84% 4.9%;- --popover-foreground: 210 40% 98%;- --primary: 210 40% 98%;- --primary-foreground: 222.2 47.4% 11.2%;- --secondary: 217.2 32.6% 17.5%;- --secondary-foreground: 210 40% 98%;- --muted: 217.2 32.6% 17.5%;- --muted-foreground: 215 20.2% 65.1%;- --accent: 217.2 32.6% 17.5%;- --accent-foreground: 210 40% 98%;- --destructive: 0 62.8% 30.6%;- --destructive-foreground: 210 40% 98%;- --border: 217.2 32.6% 17.5%;- --input: 217.2 32.6% 17.5%;- --ring: 212.7 26.8% 83.9%;- --chart-1: 220 70% 50%;- --chart-2: 160 60% 45%;- --chart-3: 30 80% 55%;- --chart-4: 280 65% 60%;- --chart-5: 340 75% 55%;- --subtitle: 212.7 26.8% 83.9%;- }+ .dark {+ --background: 222.2 84% 4.9%;+ --foreground: 210 40% 98%;+ --card: 222.2 84% 4.9%;+ --card-foreground: 210 40% 98%;+ --popover: 222.2 84% 4.9%;+ --popover-foreground: 210 40% 98%;+ --primary: 210 40% 98%;+ --primary-foreground: 222.2 47.4% 11.2%;+ --secondary: 217.2 32.6% 17.5%;+ --secondary-foreground: 210 40% 98%;+ --muted: 217.2 32.6% 17.5%;+ --muted-foreground: 215 20.2% 65.1%;+ --accent: 217.2 32.6% 17.5%;+ --accent-foreground: 210 40% 98%;+ --destructive: 0 62.8% 30.6%;+ --destructive-foreground: 210 40% 98%;+ --border: 217.2 32.6% 17.5%;+ --input: 217.2 32.6% 17.5%;+ --ring: 212.7 26.8% 83.9%;+ --chart-1: 220 70% 50%;+ --chart-2: 160 60% 45%;+ --chart-3: 30 80% 55%;+ --chart-4: 280 65% 60%;+ --chart-5: 340 75% 55%;+ --subtitle: 212.7 26.8% 83.9%;+ }}@layer base {- * {- @apply border-border;- }- body {- @apply bg-background text-foreground;- }-}\ No newline at end of file+ * {+ @apply border-border;+ }+ body {+ @apply bg-background text-foreground;+ }++ .text-editable {+ @apply dark:group-hover:bg-slate-900 group-hover:bg-slate-100 group-hover:ring-[0.5px] rounded-md cursor-pointer;+ }+}diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.tsindex 5371c0d7..8a75018b 100644--- a/src/i18n/locales/de.ts+++ b/src/i18n/locales/de.ts@@ -346,6 +346,10 @@ export const de: LanguageTranslation = {edit_table: 'Tabelle bearbeiten',delete_table: 'Tabelle löschen',},++ tool_tips: {+ double_click_to_edit: 'Doppelklicken zum Bearbeiten',+ },},};diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.tsindex b21519b0..b2438645 100644--- a/src/i18n/locales/en.ts+++ b/src/i18n/locales/en.ts@@ -345,6 +345,10 @@ export const en = {edit_table: 'Edit Table',delete_table: 'Delete Table',},++ tool_tips: {+ double_click_to_edit: 'Double-click to edit',+ },},};diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.tsindex ad5e707d..0be9eb1f 100644--- a/src/i18n/locales/es.ts+++ b/src/i18n/locales/es.ts@@ -353,6 +353,10 @@ export const es: LanguageTranslation = {edit_table: 'Editar Tabla',delete_table: 'Eliminar Tabla',},++ tool_tips: {+ double_click_to_edit: 'Doble clic para editar',+ },},};diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.tsindex f71a8db9..45755a1a 100644--- a/src/i18n/locales/fr.ts+++ b/src/i18n/locales/fr.ts@@ -349,6 +349,10 @@ export const fr: LanguageTranslation = {edit_table: 'Éditer la Table',delete_table: 'Supprimer la Table',},++ tool_tips: {+ double_click_to_edit: 'Double-cliquez pour modifier',+ },},};diff --git a/src/i18n/locales/hi.ts b/src/i18n/locales/hi.tsindex ca41572b..b75cb0c9 100644--- a/src/i18n/locales/hi.ts+++ b/src/i18n/locales/hi.ts@@ -348,6 +348,10 @@ export const hi: LanguageTranslation = {edit_table: 'तालिका संपादित करें',delete_table: 'तालिका हटाएँ',},++ tool_tips: {+ double_click_to_edit: 'संपादित करने के लिए डबल-क्लिक करें',+ },},};diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.tsindex 388f099d..dff1fc74 100644--- a/src/i18n/locales/ja.ts+++ b/src/i18n/locales/ja.ts@@ -350,6 +350,10 @@ export const ja: LanguageTranslation = {edit_table: 'テーブルを編集',delete_table: 'テーブルを削除',},++ tool_tips: {+ double_click_to_edit: 'ダブルクリックして編集',+ },},};diff --git a/src/i18n/locales/ko_KR.ts b/src/i18n/locales/ko_KR.tsindex 94846b18..ec6f8e07 100644--- a/src/i18n/locales/ko_KR.ts+++ b/src/i18n/locales/ko_KR.ts@@ -344,6 +344,10 @@ export const ko_KR: LanguageTranslation = {edit_table: '테이블 수정',delete_table: '테이블 삭제',},++ tool_tips: {+ double_click_to_edit: '더블클릭하여 편집',+ },},};diff --git a/src/i18n/locales/pt_BR.ts b/src/i18n/locales/pt_BR.tsindex 5482773f..b37cf6ae 100644--- a/src/i18n/locales/pt_BR.ts+++ b/src/i18n/locales/pt_BR.ts@@ -345,6 +345,10 @@ export const pt_BR: LanguageTranslation = {edit_table: 'Editar Tabela',delete_table: 'Excluir Tabela',},++ tool_tips: {+ double_click_to_edit: 'Duplo clique para editar',+ },},};diff --git a/src/i18n/locales/uk.ts b/src/i18n/locales/uk.tsindex 2495c952..1d990bfa 100644--- a/src/i18n/locales/uk.ts+++ b/src/i18n/locales/uk.ts@@ -345,6 +345,10 @@ export const uk: LanguageTranslation = {edit_table: 'Редагувати таблицю',delete_table: 'Видалити таблицю',},++ tool_tips: {+ double_click_to_edit: 'Двойной клик для редактирования',+ },},};diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header.tsxindex 4fa7a33f..9e4fc6bf 100644--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header.tsx+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header.tsx@@ -28,6 +28,11 @@ import { useLayout } from '@/hooks/use-layout';import { useBreakpoint } from '@/hooks/use-breakpoint';import { useTranslation } from 'react-i18next';import { useDialog } from '@/hooks/use-dialog';+import {+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@/components/tooltip/tooltip';export interface TableListItemHeaderProps {table: DBTable;@@ -65,10 +70,8 @@ export const TableListItemHeader: React.FC<TableListItemHeaderProps> = ({useClickAway(inputRef, editTableName);useKeyPressEvent('Enter', editTableName);- const enterEditMode = (- event: React.MouseEvent<HTMLButtonElement, MouseEvent>- ) => {- event.stopPropagation();+ const enterEditMode = (e: React.MouseEvent) => {+ e.stopPropagation();setEditMode(true);};@@ -219,7 +222,7 @@ export const TableListItemHeader: React.FC<TableListItemHeaderProps> = ({return (<div className="group flex h-11 flex-1 items-center justify-between gap-1 overflow-hidden">- <div className="flex min-w-0 flex-1">+ <div className="flex min-w-0 flex-1 px-1">{editMode ? (<Inputref={inputRef}@@ -232,12 +235,24 @@ export const TableListItemHeader: React.FC<TableListItemHeaderProps> = ({className="h-7 w-full focus-visible:ring-0"/>) : (- <div className="truncate">- {table.name}- <span className="text-xs text-muted-foreground">- {schemaToDisplay ? ` (${schemaToDisplay})` : ''}- </span>- </div>+ <Tooltip>+ <TooltipTrigger asChild>+ <div+ onDoubleClick={enterEditMode}+ className="text-editable truncate px-2 py-0.5"+ >+ {table.name}+ <span className="text-xs text-muted-foreground">+ {schemaToDisplay+ ? ` (${schemaToDisplay})`+ : ''}+ </span>+ </div>+ </TooltipTrigger>+ <TooltipContent>+ {t('tool_tips.double_click_to_edit')}+ </TooltipContent>+ </Tooltip>)}</div><div className="flex flex-row-reverse">diff --git a/src/pages/editor-page/top-navbar/diagram-name.tsx b/src/pages/editor-page/top-navbar/diagram-name.tsxindex 2e9dd308..a0ec5521 100644--- a/src/pages/editor-page/top-navbar/diagram-name.tsx+++ b/src/pages/editor-page/top-navbar/diagram-name.tsx@@ -1,7 +1,7 @@import React, { useCallback, useEffect, useState } from 'react';import { Label } from '@/components/label/label';import { Button } from '@/components/button/button';-import { Check, Pencil } from 'lucide-react';+import { Check } from 'lucide-react';import { Input } from '@/components/input/input';import { useChartDB } from '@/hooks/use-chartdb';import { useClickAway, useKeyPressEvent } from 'react-use';@@ -10,6 +10,11 @@ import { DiagramIcon } from '@/components/diagram-icon/diagram-icon';import { useTranslation } from 'react-i18next';import { cn } from '@/lib/utils';import { labelVariants } from '@/components/label/label-variants';+import {+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@/components/tooltip/tooltip';export interface DiagramNameProps {}@@ -39,54 +44,73 @@ export const DiagramName: React.FC<DiagramNameProps> = () => {useKeyPressEvent('Enter', editDiagramName);const enterEditMode = (- event: React.MouseEvent<HTMLButtonElement, MouseEvent>+ event: React.MouseEvent<HTMLHeadingElement, MouseEvent>) => {event.stopPropagation();setEditMode(true);};return (- <>- <DiagramIcon diagram={currentDiagram} />- <div className="flex">- {isDesktop ? <Label>{t('diagrams')}/</Label> : null}- </div>- <div className="flex flex-row items-center gap-1">- {editMode ? (- <>- <Input- ref={inputRef}- autoFocus- type="text"- placeholder={diagramName}- value={editedDiagramName}- onClick={(e) => e.stopPropagation()}- onChange={(e) =>- setEditedDiagramName(e.target.value)- }- className="ml-1 h-7 focus-visible:ring-0"- />- <Button- variant="ghost"- className="hidden size-7 p-2 text-slate-500 hover:bg-primary-foreground hover:text-slate-700 group-hover:flex dark:text-slate-400 dark:hover:text-slate-300"- onClick={editDiagramName}- >- <Check />- </Button>- </>- ) : (- <>- <h1 className={cn(labelVariants())}>{diagramName}</h1>- <Button- variant="ghost"- className="hidden size-7 p-2 text-slate-500 hover:bg-primary-foreground hover:text-slate-700 group-hover:flex dark:text-slate-400 dark:hover:text-slate-300"- onClick={enterEditMode}- >- <Pencil />- </Button>- </>+ <div className="group">+ <div+ className={cn(+ 'flex flex-1 flex-row items-center justify-center px-2 py-1',+ {+ 'text-editable': !editMode,+ })}+ >+ <DiagramIcon diagram={currentDiagram} />+ <div className="flex">+ {isDesktop ? <Label>{t('diagrams')}/</Label> : null}+ </div>+ <div className="flex flex-row items-center gap-1">+ {editMode ? (+ <>+ <Input+ ref={inputRef}+ autoFocus+ type="text"+ placeholder={diagramName}+ value={editedDiagramName}+ onClick={(e) => e.stopPropagation()}+ onChange={(e) =>+ setEditedDiagramName(e.target.value)+ }+ className="ml-1 h-7 focus-visible:ring-0"+ />+ <Button+ variant="ghost"+ className="flex size-7 p-2 text-slate-500 hover:bg-primary-foreground hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-300"+ onClick={editDiagramName}+ >+ <Check />+ </Button>+ </>+ ) : (+ <>+ <Tooltip>+ <TooltipTrigger asChild>+ <h1+ className={cn(+ labelVariants(),+ 'group-hover:underline'+ )}+ onDoubleClick={(e) => {+ enterEditMode(e);+ }}+ >+ {diagramName}+ </h1>+ </TooltipTrigger>+ <TooltipContent>+ {t('tool_tips.double_click_to_edit')}+ </TooltipContent>+ </Tooltip>+ </>+ )}+ </div></div>- </>+ </div>);};diff --git a/src/pages/editor-page/top-navbar/top-navbar.tsx b/src/pages/editor-page/top-navbar/top-navbar.tsxindex 7cbc29f3..e04b1d0a 100644--- a/src/pages/editor-page/top-navbar/top-navbar.tsx+++ b/src/pages/editor-page/top-navbar/top-navbar.tsx@@ -607,9 +607,7 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {</div>{isDesktop ? (<>- <div className="group flex flex-1 flex-row items-center justify-center">- <DiagramName />- </div>+ <DiagramName /><div className="hidden flex-1 items-center justify-end gap-2 sm:flex"><LastSaved />{renderStars()}