Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Make individual tables resizable (#1150)

1ilit9f405eac0c38
diff --git a/src/components/EditorCanvas/Canvas.jsx b/src/components/EditorCanvas/Canvas.jsx
index ca575132..b1fad484 100644
--- a/src/components/EditorCanvas/Canvas.jsx
+++ b/src/components/EditorCanvas/Canvas.jsx
@@ -33,8 +33,16 @@ import {
} from "../../hooks";
import { useTranslation } from "react-i18next";
import { useEventListener } from "usehooks-ts";
-import { areFieldsCompatible, getTableHeight } from "../../utils/utils";
-import { getViewHeight, resolveViewColumns } from "../../utils/views";
+import {
+ areFieldsCompatible,
+ getTableHeight,
+ getTableWidth,
+} from "../../utils/utils";
+import {
+ getViewHeight,
+ getViewWidth,
+ resolveViewColumns,
+} from "../../utils/views";
import { getRectFromEndpoints, isInsideRect } from "../../utils/rect";
import { State, noteWidth } from "../../data/constants";
import { nanoid } from "nanoid";
@@ -168,13 +176,8 @@ export default function Canvas() {
const tableRect = {
x: table.x,
y: table.y,
- width: settings.tableWidth,
- height: getTableHeight(
- table,
- settings.tableWidth,
- settings.showComments,
- relationships,
- ),
+ width: getTableWidth(table),
+ height: getTableHeight(table, settings.showComments, relationships),
};
if (shouldAddElement(tableRect, element)) {
elements.push(element);
@@ -193,11 +196,10 @@ export default function Canvas() {
const viewRect = {
x: view.x,
y: view.y,
- width: settings.tableWidth,
+ width: getViewWidth(view),
height: getViewHeight(
view,
resolveViewColumns(view, tables),
- settings.tableWidth,
settings.showComments,
),
};
diff --git a/src/components/EditorCanvas/Relationship.jsx b/src/components/EditorCanvas/Relationship.jsx
index a5531699..0ba53028 100644
--- a/src/components/EditorCanvas/Relationship.jsx
+++ b/src/components/EditorCanvas/Relationship.jsx
@@ -9,6 +9,7 @@ import {
getVisibleFieldIndex,
getVisibleFields,
getRelationshipFields,
+ getTableWidth,
} from "../../utils/utils";
const labelFontSize = 16;
@@ -52,12 +53,14 @@ export default function Relationship({ data }) {
startTable: {
x: startTable.x,
y: startTable.y,
+ width: getTableWidth(startTable),
comment: startTable.comment,
fields: startFields,
},
endTable: {
x: endTable.x,
y: endTable.y,
+ width: getTableWidth(endTable),
comment: endTable.comment,
fields: endFields,
},
@@ -75,11 +78,10 @@ export default function Relationship({ data }) {
startFieldIndices: pathValues.startFieldIndices,
endFieldIndices: pathValues.endFieldIndices,
},
- settings.tableWidth,
1,
settings.showComments,
);
- }, [pathValues, isComposite, settings.tableWidth, settings.showComments]);
+ }, [pathValues, isComposite, settings.showComments]);
const pathRef = useRef();
const labelRef = useRef();
@@ -183,12 +185,7 @@ export default function Relationship({ data }) {
d={
composite
? composite.path
- : calcPath(
- pathValues,
- settings.tableWidth,
- 1,
- settings.showComments,
- )
+ : calcPath(pathValues, 1, settings.showComments)
}
fill="none"
stroke="transparent"
@@ -200,12 +197,7 @@ export default function Relationship({ data }) {
d={
composite
? composite.path
- : calcPath(
- pathValues,
- settings.tableWidth,
- 1,
- settings.showComments,
- )
+ : calcPath(pathValues, 1, settings.showComments)
}
className="relationship-path"
style={{ stroke: hovered ? undefined : data.color }}
diff --git a/src/components/EditorCanvas/ResizeHandles.jsx b/src/components/EditorCanvas/ResizeHandles.jsx
new file mode 100644
index 00000000..e7bcaf06
--- /dev/null
+++ b/src/components/EditorCanvas/ResizeHandles.jsx
@@ -0,0 +1,127 @@
+import { useEffect, useRef, useState } from "react";
+import { clampTableWidth } from "../../utils/utils";
+import { useSettings } from "../../hooks";
+
+const handleRadius = 6;
+const handleHitWidth = handleRadius * 2 + 2;
+const handleInset = 6;
+
+export default function ResizeHandles({
+ x,
+ y,
+ width,
+ height,
+ zoom,
+ visible,
+ onResize,
+ onResizeEnd,
+ onEngagedChange,
+}) {
+ const { settings } = useSettings();
+ const [active, setActive] = useState(null);
+ const [hovered, setHovered] = useState(null);
+ const latestRef = useRef(null);
+ const detachRef = useRef(null);
+ latestRef.current = { x, width, onResize, onResizeEnd, onEngagedChange };
+
+ const engaged = hovered !== null || active !== null;
+
+ useEffect(() => {
+ latestRef.current.onEngagedChange?.(engaged);
+ }, [engaged]);
+
+ useEffect(() => () => detachRef.current?.(), []);
+
+ const beginResize = (side) => (e) => {
+ if (!e.isPrimary) return;
+ e.stopPropagation();
+
+ const from = {
+ x,
+ width,
+ clientX: e.clientX,
+ pointerId: e.pointerId,
+ zoom: zoom || 1,
+ };
+ setActive(side);
+
+ const move = (event) => {
+ if (event.pointerId !== from.pointerId) return;
+
+ const latest = latestRef.current;
+ const delta = (event.clientX - from.clientX) / from.zoom;
+ const next = clampTableWidth(
+ side === "left" ? from.width - delta : from.width + delta,
+ );
+ if (next === latest.width) return;
+
+ latest.onResize(
+ side === "left"
+ ? { width: next, x: from.x + from.width - next }
+ : { width: next },
+ );
+ };
+
+ const stop = (event) => {
+ if (event && event.pointerId !== from.pointerId) return;
+
+ detachRef.current?.();
+ detachRef.current = null;
+ setActive(null);
+
+ const latest = latestRef.current;
+ if (from.width === latest.width && from.x === latest.x) return;
+ latest.onResizeEnd(
+ { x: from.x, width: from.width },
+ { x: latest.x, width: latest.width },
+ );
+ };
+
+ window.addEventListener("pointermove", move);
+ window.addEventListener("pointerup", stop);
+ window.addEventListener("pointercancel", stop);
+ detachRef.current = () => {
+ window.removeEventListener("pointermove", move);
+ window.removeEventListener("pointerup", stop);
+ window.removeEventListener("pointercancel", stop);
+ };
+ };
+
+ const handle = (side) => {
+ const edgeX = side === "left" ? x : x + width;
+ const barHeight = Math.max(0, height - handleInset * 2);
+ return (
+ <g key={side}>
+ {(visible || engaged) && (
+ <circle
+ cx={edgeX}
+ cy={y + height / 2}
+ r={handleRadius}
+ fill={settings.mode === "light" ? "white" : "rgb(28, 31, 35)"}
+ stroke="#5891db"
+ strokeWidth={2}
+ className="pointer-events-none"
+ />
+ )}
+ <rect
+ x={edgeX - handleHitWidth / 2}
+ y={y + handleInset}
+ width={handleHitWidth}
+ height={barHeight}
+ fill="transparent"
+ style={{ cursor: "ew-resize", touchAction: "none" }}
+ onPointerEnter={(e) => e.isPrimary && setHovered(side)}
+ onPointerLeave={(e) => e.isPrimary && setHovered(null)}
+ onPointerDown={beginResize(side)}
+ />
+ </g>
+ );
+ };
+
+ return (
+ <>
+ {handle("left")}
+ {handle("right")}
+ </>
+ );
+}
diff --git a/src/components/EditorCanvas/Table.jsx b/src/components/EditorCanvas/Table.jsx
index cd1ecf6f..b2230373 100644
--- a/src/components/EditorCanvas/Table.jsx
+++ b/src/components/EditorCanvas/Table.jsx
@@ -33,6 +33,7 @@ import {
useDiagram,
useSelect,
useUndoRedo,
+ useTransform,
} from "../../hooks";
import TableInfo from "../EditorSidePanel/TablesTab/TableInfo";
import { useTranslation } from "react-i18next";
@@ -43,10 +44,12 @@ import {
getCommentHeight,
getFieldOffsetY,
getTableHeight,
+ getTableWidth,
getVisibleFieldEntries,
getVisibleFields,
getRelationshipFields,
} from "../../utils/utils";
+import ResizeHandles from "./ResizeHandles";
export default function Table({
tableData,
@@ -56,6 +59,8 @@ export default function Table({
setLinkingLine,
}) {
const [hoveredField, setHoveredField] = useState(null);
+ const [hovered, setHovered] = useState(false);
+ const [resizeEngaged, setResizeEngaged] = useState(false);
const { layout } = useLayout();
const {
database,
@@ -68,6 +73,7 @@ export default function Table({
} = useDiagram();
const { setUndoStack, setRedoStack } = useUndoRedo();
const { settings } = useSettings();
+ const { transform } = useTransform();
const { t } = useTranslation();
const {
selectedElement,
@@ -81,9 +87,10 @@ export default function Table({
[settings.mode],
);
+ const width = getTableWidth(tableData);
+
const height = getTableHeight(
tableData,
- settings.tableWidth,
settings.showComments,
relationships,
);
@@ -234,6 +241,46 @@ export default function Table({
return { tableName: refTable.name, fieldName: refField.name };
};
+ const resizeTable = ({ width: nextWidth, x: nextX }) => {
+ updateTable(
+ tableData.id,
+ nextX === undefined
+ ? { width: nextWidth }
+ : { width: nextWidth, x: nextX },
+ );
+ if (nextX === undefined) return;
+ setBulkSelectedElements((prev) =>
+ prev.map((el) =>
+ el.type === ObjectType.TABLE && el.id === tableData.id
+ ? {
+ ...el,
+ initialCoords: { ...el.initialCoords, x: nextX },
+ currentCoords: { ...el.currentCoords, x: nextX },
+ }
+ : el,
+ ),
+ );
+ };
+
+ const commitResize = (initial, final) => {
+ setUndoStack((prev) => [
+ ...prev,
+ {
+ action: Action.EDIT,
+ element: ObjectType.TABLE,
+ component: "self",
+ tid: tableData.id,
+ undo: initial,
+ redo: final,
+ message: t("edit_table", {
+ tableName: tableData.name,
+ extra: "[width]",
+ }),
+ },
+ ]);
+ setRedoStack([]);
+ };
+
if (tableData.hidden) return null;
return (
@@ -242,10 +289,12 @@ export default function Table({
key={tableData.id}
x={tableData.x}
y={tableData.y}
- width={settings.tableWidth}
+ width={width}
height={height}
className="group drop-shadow-lg rounded-md cursor-move"
onPointerDown={onPointerDown}
+ onPointerEnter={(e) => e.isPrimary && setHovered(true)}
+ onPointerLeave={(e) => e.isPrimary && setHovered(false)}
>
<div
onDoubleClick={openEditor}
@@ -254,7 +303,13 @@ export default function Table({
settings.mode === "light"
? "bg-zinc-100 text-zinc-800"
: "bg-zinc-800 text-zinc-200"
- } ${isSelected ? "border-solid border-blue-500" : borderColor}`}
+ } ${
+ resizeEngaged
+ ? "border-dashed border-blue-500"
+ : isSelected
+ ? "border-solid border-blue-500"
+ : borderColor
+ }`}
style={{ direction: "ltr" }}
>
<div
@@ -469,6 +524,19 @@ export default function Table({
})}
</div>
</foreignObject>
+ {!layout.readOnly && !tableData.locked && (
+ <ResizeHandles
+ x={tableData.x}
+ y={tableData.y}
+ width={width}
+ height={height}
+ zoom={transform.zoom}
+ visible={hovered}
+ onResize={resizeTable}
+ onResizeEnd={commitResize}
+ onEngagedChange={setResizeEngaged}
+ />
+ )}
<SideSheet
title={t("edit")}
size="small"
@@ -542,14 +610,14 @@ export default function Table({
getFieldOffsetY(
visibleFields,
index,
- settings.tableWidth,
+ width,
settings.showComments,
) +
tableHeaderHeight +
tableColorStripHeight +
getCommentHeight(
tableData.comment,
- settings.tableWidth,
+ width,
settings.showComments,
) +
14;
diff --git a/src/components/EditorCanvas/View.jsx b/src/components/EditorCanvas/View.jsx
index 961a6a0c..5c505e01 100644
--- a/src/components/EditorCanvas/View.jsx
+++ b/src/components/EditorCanvas/View.jsx
@@ -1,5 +1,5 @@
-import { useMemo } from "react";
-import { Tab, ObjectType } from "../../data/constants";
+import { useMemo, useState } from "react";
+import { Action, Tab, ObjectType } from "../../data/constants";
import {
IconMore,
IconDeleteStroked,
@@ -22,17 +22,28 @@ import {
useDiagram,
useSelect,
useViews,
+ useUndoRedo,
+ useTransform,
} from "../../hooks";
import ViewInfo from "../EditorSidePanel/ViewsTab/ViewInfo";
import { useTranslation } from "react-i18next";
import { resolveType } from "../../utils/customTypes";
-import { getViewHeight, resolveViewColumns } from "../../utils/views";
+import {
+ getViewHeight,
+ getViewWidth,
+ resolveViewColumns,
+} from "../../utils/views";
+import ResizeHandles from "./ResizeHandles";
export default function View({ viewData, onPointerDown }) {
+ const [hovered, setHovered] = useState(false);
+ const [resizeEngaged, setResizeEngaged] = useState(false);
const { layout } = useLayout();
const { database, tables } = useDiagram();
const { views, addView, deleteView, updateView } = useViews();
const { settings } = useSettings();
+ const { setUndoStack, setRedoStack } = useUndoRedo();
+ const { transform } = useTransform();
const { t } = useTranslation();
const {
selectedElement,
@@ -51,12 +62,9 @@ export default function View({ viewData, onPointerDown }) {
[viewData, tables],
);
- const height = getViewHeight(
- viewData,
- columns,
- settings.tableWidth,
- settings.showComments,
- );
+ const width = getViewWidth(viewData);
+
+ const height = getViewHeight(viewData, columns, settings.showComments);
const isSelected = useMemo(() => {
return (
@@ -146,6 +154,45 @@ export default function View({ viewData, onPointerDown }) {
?.scrollIntoView({ behavior: "smooth" });
};
+ const resizeView = ({ width: nextWidth, x: nextX }) => {
+ updateView(
+ viewData.id,
+ nextX === undefined
+ ? { width: nextWidth }
+ : { width: nextWidth, x: nextX },
+ );
+ if (nextX === undefined) return;
+ setBulkSelectedElements((prev) =>
+ prev.map((el) =>
+ el.type === ObjectType.VIEW && el.id === viewData.id
+ ? {
+ ...el,
+ initialCoords: { ...el.initialCoords, x: nextX },
+ currentCoords: { ...el.currentCoords, x: nextX },
+ }
+ : el,
+ ),
+ );
+ };
+
+ const commitResize = (initial, final) => {
+ setUndoStack((prev) => [
+ ...prev,
+ {
+ action: Action.EDIT,
+ element: ObjectType.VIEW,
+ vid: viewData.id,
+ undo: initial,
+ redo: final,
+ message: t("edit_view", {
+ viewName: viewData.name,
+ extra: "[width]",
+ }),
+ },
+ ]);
+ setRedoStack([]);
+ };
+
if (viewData.hidden) return null;
return (
@@ -154,10 +201,12 @@ export default function View({ viewData, onPointerDown }) {
key={viewData.id}
x={viewData.x}
y={viewData.y}
- width={settings.tableWidth}
+ width={width}
height={height}
className="group drop-shadow-lg rounded-md cursor-move"
onPointerDown={onPointerDown}
+ onPointerEnter={(e) => e.isPrimary && setHovered(true)}
+ onPointerLeave={(e) => e.isPrimary && setHovered(false)}
>
<div
onDoubleClick={openEditor}
@@ -165,7 +214,13 @@ export default function View({ viewData, onPointerDown }) {
settings.mode === "light"
? "bg-zinc-100 text-zinc-800"
: "bg-zinc-800 text-zinc-200"
- } ${isSelected ? "border-solid border-blue-500" : borderColor}`}
+ } ${
+ resizeEngaged
+ ? "border-dashed border-blue-500"
+ : isSelected
+ ? "border-solid border-blue-500"
+ : borderColor
+ }`}
style={{ direction: "ltr" }}
>
<div
@@ -299,6 +354,19 @@ export default function View({ viewData, onPointerDown }) {
})}
</div>
</foreignObject>
+ {!layout.readOnly && !viewData.locked && (
+ <ResizeHandles
+ x={viewData.x}
+ y={viewData.y}
+ width={width}
+ height={height}
+ zoom={transform.zoom}
+ visible={hovered}
+ onResize={resizeView}
+ onResizeEnd={commitResize}
+ onEngagedChange={setResizeEngaged}
+ />
+ )}
<SideSheet
title={t("edit")}
size="small"
diff --git a/src/components/EditorHeader/ControlPanel.jsx b/src/components/EditorHeader/ControlPanel.jsx
index ff150f8e..8a2861cb 100644
--- a/src/components/EditorHeader/ControlPanel.jsx
+++ b/src/components/EditorHeader/ControlPanel.jsx
@@ -99,8 +99,12 @@ import { applyDiagramPlan } from "../../utils/dbml/applyPlan";
import { diffDiagram } from "../../utils/dbml/diff";
import { exportSavedData } from "../../utils/exportSavedData";
import { nanoid } from "nanoid";
-import { getTableHeight } from "../../utils/utils";
-import { getViewHeight, resolveViewColumns } from "../../utils/views";
+import { getTableHeight, getTableWidth } from "../../utils/utils";
+import {
+ getViewHeight,
+ getViewWidth,
+ resolveViewColumns,
+} from "../../utils/views";
import { autoArrange } from "../../utils/autoArrange";
import { findAutoFKRelationships } from "../../utils/autoRelationships";
import { deleteFromCache, STORAGE_KEY } from "../../utils/cache";
@@ -688,30 +692,23 @@ export default function ControlPanel({
tablesToFit.forEach((table) => {
minMaxXY.minX = Math.min(minMaxXY.minX, table.x);
minMaxXY.minY = Math.min(minMaxXY.minY, table.y);
- minMaxXY.maxX = Math.max(minMaxXY.maxX, table.x + settings.tableWidth);
+ minMaxXY.maxX = Math.max(minMaxXY.maxX, table.x + getTableWidth(table));
minMaxXY.maxY = Math.max(
minMaxXY.maxY,
- table.y +
- getTableHeight(
- table,
- settings.tableWidth,
- settings.showComments,
- relationships,
- ),
+ table.y + getTableHeight(table, settings.showComments, relationships),
);
});
views.forEach((view) => {
minMaxXY.minX = Math.min(minMaxXY.minX, view.x);
minMaxXY.minY = Math.min(minMaxXY.minY, view.y);
- minMaxXY.maxX = Math.max(minMaxXY.maxX, view.x + settings.tableWidth);
+ minMaxXY.maxX = Math.max(minMaxXY.maxX, view.x + getViewWidth(view));
minMaxXY.maxY = Math.max(
minMaxXY.maxY,
view.y +
getViewHeight(
view,
resolveViewColumns(view, tables),
- settings.tableWidth,
settings.showComments,
),
);
@@ -1931,10 +1928,6 @@ export default function ControlPanel({
function: () =>
setSettings((prev) => ({ ...prev, autosave: !prev.autosave })),
},
- table_width: {
- function: () => setModal(MODAL.TABLE_WIDTH),
- disabled: layout.readOnly,
- },
configure_custom_types: {
function: () => setModal(MODAL.CONFIG_CUSTOM_TYPES),
disabled: layout.readOnly,
diff --git a/src/components/EditorHeader/Modal/Modal.jsx b/src/components/EditorHeader/Modal/Modal.jsx
index f6fa1dac..205077f1 100644
--- a/src/components/EditorHeader/Modal/Modal.jsx
+++ b/src/components/EditorHeader/Modal/Modal.jsx
@@ -19,7 +19,6 @@ import {
useEnums,
useNavigateWithParams,
useNotes,
- useSettings,
useTransform,
useTypes,
useUndoRedo,
@@ -45,7 +44,6 @@ import Language from "./Language";
import New from "./New";
import Open from "./Open";
import Rename from "./Rename";
-import SetTableWidth from "./SetTableWidth";
import Share from "./Share";
import { mergeCustomTypes } from "../../../utils/customTypes";
@@ -76,12 +74,10 @@ export default function Modal({
const { setViews } = useViews();
const { setTransform } = useTransform();
const { setUndoStack, setRedoStack } = useUndoRedo();
- const { settings, setSettings } = useSettings();
const [uncontrolledTitle, setUncontrolledTitle] = useState(title);
const [uncontrolledLanguage, setUncontrolledLanguage] = useState(
i18n.language,
);
- const [tempTableWidth, setTempTableWidth] = useState(settings.tableWidth);
const [importSource, setImportSource] = useState({
src: "",
overwrite: false,
@@ -204,7 +200,10 @@ export default function Modal({
if (!result) return;
- const { diagram, warnings } = normalizeAiDiagram(result.diagram, database);
+ const { diagram, warnings } = normalizeAiDiagram(
+ result.diagram,
+ database,
+ );
const allWarnings = [...(result.warnings ?? []), ...warnings];
applyImportedDiagram(diagram);
@@ -274,10 +273,6 @@ export default function Modal({
i18n.changeLanguage(uncontrolledLanguage);
setModal(MODAL.NONE);
return;
- case MODAL.TABLE_WIDTH:
- setSettings((prev) => ({ ...prev, tableWidth: tempTableWidth }));
- setModal(MODAL.NONE);
- return;
default:
setModal(MODAL.NONE);
return;
@@ -365,13 +360,6 @@ export default function Modal({
</div>
);
}
- case MODAL.TABLE_WIDTH:
- return (
- <SetTableWidth
- tempWidth={tempTableWidth}
- setTempWidth={setTempTableWidth}
- />
- );
case MODAL.LANGUAGE:
return (
<Language
@@ -389,7 +377,6 @@ export default function Modal({
const handleCancel = () => {
if (modal === MODAL.RENAME) setUncontrolledTitle(title);
if (modal === MODAL.LANGUAGE) setUncontrolledLanguage(i18n.language);
- if (modal === MODAL.TABLE_WIDTH) setTempTableWidth(settings.tableWidth);
setModal(MODAL.NONE);
};
diff --git a/src/components/EditorHeader/Modal/SetTableWidth.jsx b/src/components/EditorHeader/Modal/SetTableWidth.jsx
deleted file mode 100644
index 56e8a6e1..00000000
--- a/src/components/EditorHeader/Modal/SetTableWidth.jsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { InputNumber } from "@douyinfe/semi-ui";
-import { useLayout } from "../../../hooks";
-
-export default function SetTableWidth({ tempWidth, setTempWidth }) {
- const { layout } = useLayout();
-
- return (
- <InputNumber
- className="w-full"
- value={tempWidth}
- readonly={layout.readOnly}
- onChange={(c) => {
- if (c < 180) return;
- setTempWidth(c);
- }}
- />
- );
-}
diff --git a/src/components/Thumbnail.jsx b/src/components/Thumbnail.jsx
index 623c2a1b..8607a070 100644
--- a/src/components/Thumbnail.jsx
+++ b/src/components/Thumbnail.jsx
@@ -7,6 +7,7 @@ import {
gridSize,
gridCircleRadius,
} from "../data/constants";
+import { getTableWidth } from "../utils/utils";
export default function Thumbnail({ diagram, i, zoom, theme }) {
return (
@@ -72,7 +73,7 @@ export default function Thumbnail({ diagram, i, zoom, theme }) {
<foreignObject
x={table.x}
y={table.y}
- width={200}
+ width={getTableWidth(table)}
height={height}
key={i}
>
diff --git a/src/context/SettingsContext.jsx b/src/context/SettingsContext.jsx
index 42268022..cbb0632a 100644
--- a/src/context/SettingsContext.jsx
+++ b/src/context/SettingsContext.jsx
@@ -1,6 +1,5 @@
import { createContext, useEffect, useState } from "react";
import { useSearchParams } from "react-router-dom";
-import { tableWidth } from "../data/constants";
import { queryConfig } from "../utils/queryConfig";
const defaultSettings = {
@@ -13,7 +12,6 @@ const defaultSettings = {
autosave: true,
showCardinality: true,
showRelationshipLabels: true,
- tableWidth: tableWidth,
showDebugCoordinates: false,
showComments: false,
};
diff --git a/src/data/constants.js b/src/data/constants.js
index 0b87c8ce..07405c94 100644
--- a/src/data/constants.js
+++ b/src/data/constants.js
@@ -19,6 +19,8 @@ export const otherColor = "text-zinc-500";
export const dateColor = "text-cyan-500";
export const tableHeaderHeight = 50;
export const tableWidth = 220;
+export const minTableWidth = 180;
+export const maxTableWidth = 480;
export const gridSize = 24;
export const gridCircleRadius = 0.85;
export const tableFieldHeight = 36;
@@ -89,7 +91,6 @@ export const MODAL = {
SAVEAS: 6,
NEW: 7,
IMPORT_SRC: 8,
- TABLE_WIDTH: 9,
LANGUAGE: 10,
SHARE: 11,
CONFIG_CUSTOM_TYPES: 12,
diff --git a/src/data/schemas.js b/src/data/schemas.js
index 00e9844e..55188eea 100644
--- a/src/data/schemas.js
+++ b/src/data/schemas.js
@@ -5,6 +5,7 @@ export const tableSchema = {
name: { type: "string" },
x: { type: "number" },
y: { type: "number" },
+ width: { type: "number" },
fields: {
type: "array",
items: {
@@ -154,6 +155,7 @@ export const viewSchema = {
name: { type: "string" },
x: { type: "number" },
y: { type: "number" },
+ width: { type: "number" },
baseTableId: { type: ["string", "integer", "null"] },
joins: {
type: "array",
diff --git a/src/i18n/locales/ar.js b/src/i18n/locales/ar.js
index bbe6a025..2b7fb590 100644
--- a/src/i18n/locales/ar.js
+++ b/src/i18n/locales/ar.js
@@ -67,7 +67,6 @@ const ar = {
coordinate_space: "الفضاء",
coordinate_space_screen: "الشاشة",
coordinate_space_diagram: "المخطط",
- table_width: "عرض الجدول",
language: "اللغة",
flush_storage: "مسح التخزين",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/as.js b/src/i18n/locales/as.js
index 85336b48..75a0bb8c 100644
--- a/src/i18n/locales/as.js
+++ b/src/i18n/locales/as.js
@@ -76,7 +76,6 @@ const as = {
coordinate_space: "স্থান",
coordinate_space_screen: "স্ক্ৰীণ",
coordinate_space_diagram: "ডায়াগ্ৰাম",
- table_width: "টেবুলৰ প্ৰস্থ",
language: "ভাষা",
flush_storage: "সংগ্ৰহস্থল খালি কৰক",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/bg.js b/src/i18n/locales/bg.js
index 86446988..7b8be525 100644
--- a/src/i18n/locales/bg.js
+++ b/src/i18n/locales/bg.js
@@ -74,7 +74,6 @@ const bg = {
coordinate_space: "Пространство",
coordinate_space_screen: "Екран",
coordinate_space_diagram: "Диаграма",
- table_width: "Ширина на таблицата",
language: "Език",
flush_storage: "Изчисти хранилището",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/bn.js b/src/i18n/locales/bn.js
index de0463fd..de999e74 100644
--- a/src/i18n/locales/bn.js
+++ b/src/i18n/locales/bn.js
@@ -73,7 +73,6 @@ const bn = {
coordinate_space: "স্থান",
coordinate_space_screen: "স্ক্রিন",
coordinate_space_diagram: "ডায়াগ্রাম",
- table_width: "টেবিলের প্রস্থ",
language: "ভাষা",
flush_storage: "স্টোরেজ ফ্লাশ করুন",
are_you_sure_flush_storage: "আপনি কি নিশ্চিত যে আপনি স্টোরেজ ফ্লাশ করতে চান? এই পদক্ষেপের ফলে আপনার সকল ডায়াগ্রাম ও কাস্টম টেমপ্লেট স্থায়ীভাবে মুছে যাবে এবং আর ফিরে পাওয়া যাবে না।",
diff --git a/src/i18n/locales/cz.js b/src/i18n/locales/cz.js
index 83adfb78..9a66dcaf 100644
--- a/src/i18n/locales/cz.js
+++ b/src/i18n/locales/cz.js
@@ -68,7 +68,6 @@ const cz = {
coordinate_space: "Prostor",
coordinate_space_screen: "Obrazovka",
coordinate_space_diagram: "Diagram",
- table_width: "Šířka stolu",
language: "Jazyk",
flush_storage: "Splachovací úložiště",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/da.js b/src/i18n/locales/da.js
index 67fc8ac2..5061e692 100644
--- a/src/i18n/locales/da.js
+++ b/src/i18n/locales/da.js
@@ -74,7 +74,6 @@ const da = {
coordinate_space: "Rum",
coordinate_space_screen: "Skærm",
coordinate_space_diagram: "Diagram",
- table_width: "Tabel bredde",
language: "Sprog",
flush_storage: "Tøm lagring",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/de.js b/src/i18n/locales/de.js
index cb742900..19eaf05d 100644
--- a/src/i18n/locales/de.js
+++ b/src/i18n/locales/de.js
@@ -67,7 +67,6 @@ const de = {
coordinate_space: "Achse",
coordinate_space_screen: "Bildschirm",
coordinate_space_diagram: "Diagramm",
- table_width: "Tabellenbreite",
language: "Sprache",
flush_storage: "Speicher leeren",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/el.js b/src/i18n/locales/el.js
index 4026498a..4f461760 100644
--- a/src/i18n/locales/el.js
+++ b/src/i18n/locales/el.js
@@ -72,7 +72,6 @@ const el = {
coordinate_space: "Χώρος",
coordinate_space_screen: "Οθόνη",
coordinate_space_diagram: "Διάγραμμα",
- table_width: "Πλάτος πίνακα",
language: "Γλώσσα",
flush_storage: "Εκκαθάριση αποθήκευσης",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/en.js b/src/i18n/locales/en.js
index ab31fa63..2e58557d 100644
--- a/src/i18n/locales/en.js
+++ b/src/i18n/locales/en.js
@@ -76,7 +76,6 @@ const en = {
coordinate_space: "Space",
coordinate_space_screen: "Screen",
coordinate_space_diagram: "Diagram",
- table_width: "Table width",
language: "Language",
flush_storage: "Flush storage",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/es.js b/src/i18n/locales/es.js
index e4d27e3a..e6eddaf0 100644
--- a/src/i18n/locales/es.js
+++ b/src/i18n/locales/es.js
@@ -75,7 +75,6 @@ const es = {
coordinate_space: "Espacio de coordenadas",
coordinate_space_screen: "Espacio de coordenadas de pantalla",
coordinate_space_diagram: "Espacio de coordenadas de diagrama",
- table_width: "Ancho de la tabla",
language: "Idioma",
flush_storage: "Vaciar almacenamiento",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/fa.js b/src/i18n/locales/fa.js
index 8ff5fe87..c57e7403 100644
--- a/src/i18n/locales/fa.js
+++ b/src/i18n/locales/fa.js
@@ -60,7 +60,6 @@ const fa = {
show_timeline: "نمایش خط زمانی",
autosave: "ذخیره خودکار",
panning: "پانینگ",
- table_width: "عرض جدول",
language: "زبان",
flush_storage: "پاک کردن حافظه",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/fi.js b/src/i18n/locales/fi.js
index 5e815363..e28527a6 100644
--- a/src/i18n/locales/fi.js
+++ b/src/i18n/locales/fi.js
@@ -74,7 +74,6 @@ const fi = {
coordinate_space: "Avaruus",
coordinate_space_screen: "Näyttö",
coordinate_space_diagram: "Kaavio",
- table_width: "Taulun leveys",
language: "Kieli",
flush_storage: "Tyhjennä tallennustila",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/fr.js b/src/i18n/locales/fr.js
index 56251ab2..082a286c 100644
--- a/src/i18n/locales/fr.js
+++ b/src/i18n/locales/fr.js
@@ -60,7 +60,6 @@ const fr = {
show_timeline: "Afficher la chronologie",
autosave: "Sauvegarde automatique",
panning: "Panoramique",
- table_width: "Largeur de la table",
language: "Langue",
flush_storage: "Vider le stockage",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/gu.js b/src/i18n/locales/gu.js
index 536c8f79..06a68dbd 100644
--- a/src/i18n/locales/gu.js
+++ b/src/i18n/locales/gu.js
@@ -74,7 +74,6 @@ const gu = {
coordinate_space: "જગ્યા",
coordinate_space_screen: "સ્ક્રીન",
coordinate_space_diagram: "ડાયાગ્રામ",
- table_width: "ટેબલની પહોળાઈ",
language: "ભાષા",
flush_storage: "સ્ટોરેજ ફ્લશ કરો",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/he.js b/src/i18n/locales/he.js
index ab107909..fae0f9d9 100644
--- a/src/i18n/locales/he.js
+++ b/src/i18n/locales/he.js
@@ -67,7 +67,6 @@ const he = {
coordinate_space: "מרחב",
coordinate_space_screen: "מסך",
coordinate_space_diagram: "דיאגרמה",
- table_width: "רוחב טבלה",
language: "שפה",
flush_storage: "נקה אחסון",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/hi.js b/src/i18n/locales/hi.js
index e2b71100..eb9542f2 100644
--- a/src/i18n/locales/hi.js
+++ b/src/i18n/locales/hi.js
@@ -61,7 +61,6 @@ const hi = {
show_timeline: "टाइमलाइन दिखाएं",
autosave: "ऑटोसेव",
panning: "पैनिंग",
- table_width: "टेबल की चौड़ाई",
language: "भाषा",
flush_storage: "स्टोरेज साफ़ करें",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/hu.js b/src/i18n/locales/hu.js
index ec8d60b8..b6a78ba6 100644
--- a/src/i18n/locales/hu.js
+++ b/src/i18n/locales/hu.js
@@ -76,7 +76,6 @@ const hu = {
coordinate_space: "Tér",
coordinate_space_screen: "Szerkesztő",
coordinate_space_diagram: "Diagram",
- table_width: "Táblák szélessége",
language: "Nyelv",
flush_storage: "Tárhely ürítése",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/hy.js b/src/i18n/locales/hy.js
index e6390305..c73b4f03 100644
--- a/src/i18n/locales/hy.js
+++ b/src/i18n/locales/hy.js
@@ -67,7 +67,6 @@ const hy = {
coordinate_space: "Տարածք",
coordinate_space_screen: "Էկրան",
coordinate_space_diagram: "Սխեմա",
- table_width: "Աղյուսակի լայնություն",
language: "Լեզու",
flush_storage: "Դատարկել պահեստը",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/id.js b/src/i18n/locales/id.js
index c422c68e..954d0d95 100644
--- a/src/i18n/locales/id.js
+++ b/src/i18n/locales/id.js
@@ -69,7 +69,6 @@ const id = {
coordinate_space: "Ruang",
coordinate_space_screen: "Layar",
coordinate_space_diagram: "Diagram",
- table_width: "Lebar tabel",
language: "Bahasa",
flush_storage: "Bersihkan penyimpanan",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/it.js b/src/i18n/locales/it.js
index 19cde9d2..2cd3e76f 100644
--- a/src/i18n/locales/it.js
+++ b/src/i18n/locales/it.js
@@ -69,7 +69,6 @@ const it = {
coordinate_space: "Spazio",
coordinate_space_screen: "Schermo",
coordinate_space_diagram: "Diagramma",
- table_width: "Larghezza della tabella",
language: "Lingua",
flush_storage: "Pulizia memoria",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/jp.js b/src/i18n/locales/jp.js
index 3080476b..4b9be0c4 100644
--- a/src/i18n/locales/jp.js
+++ b/src/i18n/locales/jp.js
@@ -67,7 +67,6 @@ const jp = {
coordinate_space: "空間",
coordinate_space_screen: "スクリーン",
coordinate_space_diagram: "ダイアグラム",
- table_width: "テーブル幅",
language: "言語",
flush_storage: "ストレージを消去",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ka.js b/src/i18n/locales/ka.js
index ae22abdc..7628fc9e 100644
--- a/src/i18n/locales/ka.js
+++ b/src/i18n/locales/ka.js
@@ -74,7 +74,6 @@ const ka = {
coordinate_space: "ಅಂತರ",
coordinate_space_screen: "ಪರದೆ",
coordinate_space_diagram: "ಚಿತ್ರ",
- table_width: "ಕೋಷ್ಟಕದ ಅಗಲ",
language: "ಭಾಷೆ",
flush_storage: "ಸಂಗ್ರಹವನ್ನು ಫ್ಲಷ್ ಮಾಡಿ",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ko.js b/src/i18n/locales/ko.js
index 2a873fac..687100b3 100644
--- a/src/i18n/locales/ko.js
+++ b/src/i18n/locales/ko.js
@@ -67,7 +67,6 @@ const ko = {
coordinate_space: "좌표 공간",
coordinate_space_screen: "화면",
coordinate_space_diagram: "다이어그램",
- table_width: "테이블 너비",
language: "언어",
flush_storage: "저장소 비우기",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ml.js b/src/i18n/locales/ml.js
index 81cace6f..1ac10462 100644
--- a/src/i18n/locales/ml.js
+++ b/src/i18n/locales/ml.js
@@ -71,7 +71,6 @@ const ml = {
coordinate_space: "സ്പേസ്",
coordinate_space_screen: "സ്ക്രീൻ",
coordinate_space_diagram: "ഡയഗ്രം",
- table_width: "ടേബിൾ വീതി",
language: "ഭാഷ",
flush_storage: "സ്റ്റോറേജ് ഫ്ലഷ് ചെയ്യുക",
are_you_sure_flush_storage: "സ്റ്റോറേജ് ഫ്ലഷ് ചെയ്യണമെന്ന് ഉറപ്പാണോ? ഇത് നിങ്ങളുടെ എല്ലാ ഡയഗ്രമുകളും കസ്റ്റം ടെംപ്ലേറ്റുകളും ഇല്ലാതാക്കും.",
diff --git a/src/i18n/locales/mn.js b/src/i18n/locales/mn.js
index e3c3af3c..6efe732b 100644
--- a/src/i18n/locales/mn.js
+++ b/src/i18n/locales/mn.js
@@ -74,7 +74,6 @@ const mn = {
coordinate_space: "Координатын орон",
coordinate_space_screen: "Дэлгэц",
coordinate_space_diagram: "Диаграмм",
- table_width: "Хүснэгтийн өргөн",
language: "Хэл",
flush_storage: "Хадгалалт цэвэрлэх",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/mr.js b/src/i18n/locales/mr.js
index 501a0208..040be665 100644
--- a/src/i18n/locales/mr.js
+++ b/src/i18n/locales/mr.js
@@ -71,7 +71,6 @@ const mr = {
coordinate_space: "स्पेस",
coordinate_space_screen: "स्क्रीन",
coordinate_space_diagram: "डायग्राम",
- table_width: "टेबलची रुंदी",
language: "भाषा",
flush_storage: "स्टोरेज साफ करा",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ms.js b/src/i18n/locales/ms.js
index 24bf6c41..170b610a 100644
--- a/src/i18n/locales/ms.js
+++ b/src/i18n/locales/ms.js
@@ -71,7 +71,6 @@ const ms = {
coordinate_space: "Ruang koordinat",
coordinate_space_screen: "Skrin",
coordinate_space_diagram: "Rajah",
- table_width: "Lebar jadual",
language: "Bahasa",
flush_storage: "Kosongkan storan",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ne.js b/src/i18n/locales/ne.js
index fa4ccd9a..caf94a88 100644
--- a/src/i18n/locales/ne.js
+++ b/src/i18n/locales/ne.js
@@ -62,7 +62,6 @@ const ne = {
show_timeline: "टाइमलाइन देखाउनुहोस्",
autosave: "स्वतः सेभ",
panning: "प्यानिङ",
- table_width: "टेबल चौडाइ",
language: "भाषा",
flush_storage: "स्टोरेज सफा गर्नुहोस्",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/nl.js b/src/i18n/locales/nl.js
index f02c4a3b..2882c22d 100644
--- a/src/i18n/locales/nl.js
+++ b/src/i18n/locales/nl.js
@@ -74,7 +74,6 @@ const nl = {
coordinate_space: "Ruimte",
coordinate_space_screen: "Scherm",
coordinate_space_diagram: "Diagram",
- table_width: "Tabelbreedte",
language: "Taal",
flush_storage: "Opslag legen",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/no.js b/src/i18n/locales/no.js
index dab76a09..67c6edf1 100644
--- a/src/i18n/locales/no.js
+++ b/src/i18n/locales/no.js
@@ -67,7 +67,6 @@ const no = {
coordinate_space: "Koordinatsystem",
coordinate_space_screen: "Skjerm",
coordinate_space_diagram: "Diagram",
- table_width: "Tabellbredde",
language: "Språk",
flush_storage: "Tøm lagring",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/od.js b/src/i18n/locales/od.js
index ce33fe26..66996341 100644
--- a/src/i18n/locales/od.js
+++ b/src/i18n/locales/od.js
@@ -59,7 +59,6 @@ const od = {
show_timeline: "ଟାଇମଲାଇନ୍ ଦେଖାନ୍ତୁ",
autosave: "ଅଟୋସେଭ୍",
panning: "ପ୍ୟାନିଂ",
- table_width: "ଟେବଲ୍ ଚଉଡ଼ା",
language: "ଭାଷା",
flush_storage: "ସ୍ଟୋରେଜ୍ ସଫା କରନ୍ତୁ",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/pa-pk.js b/src/i18n/locales/pa-pk.js
index d7a0387c..774e72c4 100644
--- a/src/i18n/locales/pa-pk.js
+++ b/src/i18n/locales/pa-pk.js
@@ -74,7 +74,6 @@ const pa_pk = {
coordinate_space: "جگہ",
coordinate_space_screen: "سکرین",
coordinate_space_diagram: "ڈایاگرام",
- table_width: "ٹیبل دی چوڑائی",
language: "زبان",
flush_storage: "سٹوریج صاف کرو",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/pa.js b/src/i18n/locales/pa.js
index cb7ce1bb..cb4e44af 100644
--- a/src/i18n/locales/pa.js
+++ b/src/i18n/locales/pa.js
@@ -74,7 +74,6 @@ const pa = {
coordinate_space: "ਸਪੇਸ",
coordinate_space_screen: "ਸਕ੍ਰੀਨ",
coordinate_space_diagram: "ਡਾਯਾਗ੍ਰਾਮ",
- table_width: "ਟੇਬਲ ਦੀ ਚੌੜਾਈ",
language: "ਭਾਸ਼ਾ",
flush_storage: "ਸਟੋਰੇਜ ਸਾਫ਼ ਕਰੋ",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/pl.js b/src/i18n/locales/pl.js
index af8cbaca..e1553ef8 100644
--- a/src/i18n/locales/pl.js
+++ b/src/i18n/locales/pl.js
@@ -67,7 +67,6 @@ const pl = {
coordinate_space: "Przestrzeń",
coordinate_space_screen: "Ekran",
coordinate_space_diagram: "Diagram",
- table_width: "Szerokość tabeli",
language: "Język",
flush_storage: "Wyczyść pamięć",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/pt-br.js b/src/i18n/locales/pt-br.js
index c97ab041..84162cc7 100644
--- a/src/i18n/locales/pt-br.js
+++ b/src/i18n/locales/pt-br.js
@@ -68,7 +68,6 @@ const pt = {
coordinate_space: "Espaço de coordenadas",
coordinate_space_screen: "Tela",
coordinate_space_diagram: "Diagrama",
- table_width: "Largura da tabela",
language: "Idioma",
flush_storage: "Limpar armazenamento",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ro.js b/src/i18n/locales/ro.js
index 1c2aab99..904a908f 100644
--- a/src/i18n/locales/ro.js
+++ b/src/i18n/locales/ro.js
@@ -67,7 +67,6 @@ const ro = {
coordinate_space: "Spațiu",
coordinate_space_screen: "Ecran",
coordinate_space_diagram: "Diagramă",
- table_width: "Lățimea tabelului",
language: "Limbă",
flush_storage: "Golește depozitorea",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ru.js b/src/i18n/locales/ru.js
index 21199837..b35f15b4 100644
--- a/src/i18n/locales/ru.js
+++ b/src/i18n/locales/ru.js
@@ -60,7 +60,6 @@ const ru = {
show_timeline: "Показать временную шкалу",
autosave: "Автосохранение",
panning: "Панорамирование",
- table_width: "Ширина таблицы",
language: "Язык",
flush_storage: "Очистить хранилище",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/sd.js b/src/i18n/locales/sd.js
index 3aa86eeb..fb6c1e68 100644
--- a/src/i18n/locales/sd.js
+++ b/src/i18n/locales/sd.js
@@ -74,7 +74,6 @@ const sd = {
coordinate_space: "جڳهه",
coordinate_space_screen: "اسڪرين",
coordinate_space_diagram: "ڊاياگرام",
- table_width: "ٽيبل جي ويڪر",
language: "ٻولي",
flush_storage: "اسٽوريج صاف ڪريو",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/sv-se.js b/src/i18n/locales/sv-se.js
index 8a7422e7..e23f1e4b 100644
--- a/src/i18n/locales/sv-se.js
+++ b/src/i18n/locales/sv-se.js
@@ -67,7 +67,6 @@ const sv = {
coordinate_space: "Koordinatsystem",
coordinate_space_screen: "Skärm",
coordinate_space_diagram: "Diagram",
- table_width: "Tabell-bredd",
language: "Språk",
flush_storage: "Töm lagring",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/sw.js b/src/i18n/locales/sw.js
index f8b068af..2207c881 100644
--- a/src/i18n/locales/sw.js
+++ b/src/i18n/locales/sw.js
@@ -74,7 +74,6 @@ const sw = {
coordinate_space: "Nafasi ya kuratibu",
coordinate_space_screen: "Skrini",
coordinate_space_diagram: "Mchoro",
- table_width: "Upana wa jedwali",
language: "Lugha",
flush_storage: "Safisha hifadhi",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/te.js b/src/i18n/locales/te.js
index f5285e75..9e6ddc22 100644
--- a/src/i18n/locales/te.js
+++ b/src/i18n/locales/te.js
@@ -60,7 +60,6 @@ const te = {
show_timeline: "టైమ్‌లైన్ చూపించు",
autosave: "ఆటోసేవ్",
panning: "ప్యానింగ్",
- table_width: "పట్టిక వెడల్పు",
language: "భాష",
flush_storage: "స్టోరేజ్ క్లియర్ చేయి",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/th.js b/src/i18n/locales/th.js
index dfd2728b..02889c97 100644
--- a/src/i18n/locales/th.js
+++ b/src/i18n/locales/th.js
@@ -74,7 +74,6 @@ const th = {
coordinate_space: "พื้นที่พิกัด",
coordinate_space_screen: "หน้าจอ",
coordinate_space_diagram: "ไดอะแกรม",
- table_width: "ความกว้างของตาราง",
language: "ภาษา",
flush_storage: "ล้างข้อมูลเก็บ",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/tl.js b/src/i18n/locales/tl.js
index ffff937e..e63acefa 100644
--- a/src/i18n/locales/tl.js
+++ b/src/i18n/locales/tl.js
@@ -74,7 +74,6 @@ const tl = {
coordinate_space: "Space",
coordinate_space_screen: "Screen",
coordinate_space_diagram: "Diagram",
- table_width: "Lapad ng Talahanayan",
language: "Wika",
flush_storage: "I-flush ang Storage",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/tm.js b/src/i18n/locales/tm.js
index 7ee81795..2e72e935 100644
--- a/src/i18n/locales/tm.js
+++ b/src/i18n/locales/tm.js
@@ -74,7 +74,6 @@ const tm = {
coordinate_space: "இடம்",
coordinate_space_screen: "திரை",
coordinate_space_diagram: "வரைபடம்",
- table_width: "அட்டவணை அகலம்",
language: "மொழி",
flush_storage: "சேமிப்பகத்தை காலி செய்",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/tr.js b/src/i18n/locales/tr.js
index 4c9f73be..43218277 100644
--- a/src/i18n/locales/tr.js
+++ b/src/i18n/locales/tr.js
@@ -67,7 +67,6 @@ const tr = {
coordinate_space: "Koordinat uzayı",
coordinate_space_screen: "Ekran",
coordinate_space_diagram: "Diagram",
- table_width: "Tablo genişliği",
language: "Dil",
flush_storage: "Depoyu temizle",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ug.js b/src/i18n/locales/ug.js
index f4199952..c5a5d762 100644
--- a/src/i18n/locales/ug.js
+++ b/src/i18n/locales/ug.js
@@ -60,7 +60,6 @@ const ug = {
show_timeline: "ۋاقىت جەدۋىلىنى كۆرسىتىش",
autosave: "ئۆز-ئۆزىگە ساقلاش",
panning: "پانننگ",
- table_width: "جەدۋەل كەڭلىكى",
language: "تىل",
flush_storage: "ساقلاشنى تازىلاش",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/uk.js b/src/i18n/locales/uk.js
index 6199a93e..0e0f6891 100644
--- a/src/i18n/locales/uk.js
+++ b/src/i18n/locales/uk.js
@@ -74,7 +74,6 @@ const uk = {
coordinate_space: "Простір",
coordinate_space_screen: "Екран",
coordinate_space_diagram: "Діаграма",
- table_width: "Ширина таблиці",
language: "Мова",
flush_storage: "Очистити сховище",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/ur.js b/src/i18n/locales/ur.js
index c3eda84d..8234d202 100644
--- a/src/i18n/locales/ur.js
+++ b/src/i18n/locales/ur.js
@@ -74,7 +74,6 @@ const ur = {
coordinate_space: "اسپیس",
coordinate_space_screen: "سکرین",
coordinate_space_diagram: "ڈایاگرام",
- table_width: "ٹیبل کی چوڑائی",
language: "زبان",
flush_storage: "اسٹوریج صاف کریں",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/vi.js b/src/i18n/locales/vi.js
index 23b405a0..19443137 100644
--- a/src/i18n/locales/vi.js
+++ b/src/i18n/locales/vi.js
@@ -72,7 +72,6 @@ const vi = {
coordinate_space: "Không gian",
coordinate_space_screen: "Màn hình",
coordinate_space_diagram: "Sơ đồ",
- table_width: "Chiều rộng của bảng",
language: "Ngôn ngữ",
flush_storage: "Xóa bộ nhớ",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/zh-tw.js b/src/i18n/locales/zh-tw.js
index ea7cc740..6dadce64 100644
--- a/src/i18n/locales/zh-tw.js
+++ b/src/i18n/locales/zh-tw.js
@@ -76,7 +76,6 @@ const zh_tw = {
coordinate_space: "座標空間",
coordinate_space_screen: "螢幕座標",
coordinate_space_diagram: "圖表座標",
- table_width: "資料表寬度",
language: "語言",
flush_storage: "清除儲存空間",
are_you_sure_flush_storage:
diff --git a/src/i18n/locales/zh.js b/src/i18n/locales/zh.js
index 5d567070..95cd0c05 100644
--- a/src/i18n/locales/zh.js
+++ b/src/i18n/locales/zh.js
@@ -68,7 +68,6 @@ const zh = {
coordinate_space: "坐标空间",
coordinate_space_screen: "屏幕",
coordinate_space_diagram: "图表",
- table_width: "表格宽度",
language: "语言",
export_saved_data: "导出保存的数据",
flush_storage: "清除存储",
diff --git a/src/utils/autoArrange.js b/src/utils/autoArrange.js
index 149cf0b1..9e0dbfa1 100644
--- a/src/utils/autoArrange.js
+++ b/src/utils/autoArrange.js
@@ -1,5 +1,6 @@
import { graphlib, layout } from "@dagrejs/dagre";
-import { getTableHeight } from "./utils";
+import { tableWidth as defaultTableWidth } from "../data/constants";
+import { getTableHeight, getTableWidth } from "./utils";
const nodeSep = 60;
const rankSep = 110;
@@ -22,13 +23,8 @@ export function autoArrange(tables, relationships, settings) {
}
const sizeOf = (table) => ({
- width: settings.tableWidth,
- height: getTableHeight(
- table,
- settings.tableWidth,
- settings.showComments,
- relationships,
- ),
+ width: getTableWidth(table),
+ height: getTableHeight(table, settings.showComments, relationships),
});
const connected = movable.filter((table) => connectedIds.has(table.id));
@@ -66,7 +62,7 @@ export function autoArrange(tables, relationships, settings) {
}
if (isolated.length > 0) {
- const rowWidth = Math.max(maxX, 4 * settings.tableWidth + 3 * isolatedGap);
+ const rowWidth = Math.max(maxX, 4 * defaultTableWidth + 3 * isolatedGap);
let x = 0;
let y = connected.length > 0 ? maxY + rankSep : 0;
let rowHeight = 0;
diff --git a/src/utils/calcPath.js b/src/utils/calcPath.js
index f7be3195..478570cc 100644
--- a/src/utils/calcPath.js
+++ b/src/utils/calcPath.js
@@ -1,36 +1,38 @@
import { tableFieldHeight, tableHeaderHeight } from "../data/constants";
-import { getCommentHeight, getFieldOffsetY } from "./utils";
+import { getCommentHeight, getFieldOffsetY, getTableWidth } from "./utils";
/**
* Generates an SVG path string to visually represent a relationship between two fields.
*
* @param {{
- * startTable: { x: number, y: number },
- * endTable: { x: number, y: number },
+ * startTable: { x: number, y: number, width?: number },
+ * endTable: { x: number, y: number, width?: number },
* startFieldIndex: number,
* endFieldIndex: number
* }} r - Relationship data.
- * @param {number} tableWidth - Width of each table (used to calculate horizontal offsets).
* @param {number} zoom - Zoom level (used to scale vertical spacing).
* @returns {string} SVG path "d" attribute string.
*/
-export function calcPath(r, tableWidth = 200, zoom = 1, showComments = true) {
+export function calcPath(r, zoom = 1, showComments = true) {
if (!r) {
return "";
}
- const width = tableWidth * zoom;
+ const startTableWidth = getTableWidth(r.startTable);
+ const endTableWidth = getTableWidth(r.endTable);
+ const startWidth = startTableWidth * zoom;
+ const endWidth = endTableWidth * zoom;
let x1 = r.startTable.x;
let y1 =
r.startTable.y +
getFieldOffsetY(
r.startTable.fields ?? [],
r.startFieldIndex,
- tableWidth,
+ startTableWidth,
showComments,
) +
tableHeaderHeight +
- getCommentHeight(r.startTable.comment, tableWidth, showComments) +
+ getCommentHeight(r.startTable.comment, startTableWidth, showComments) +
tableFieldHeight / 2;
let x2 = r.endTable.x;
let y2 =
@@ -38,42 +40,43 @@ export function calcPath(r, tableWidth = 200, zoom = 1, showComments = true) {
getFieldOffsetY(
r.endTable.fields ?? [],
r.endFieldIndex,
- tableWidth,
+ endTableWidth,
showComments,
) +
- getCommentHeight(r.endTable.comment, tableWidth, showComments) +
+ getCommentHeight(r.endTable.comment, endTableWidth, showComments) +
tableHeaderHeight +
tableFieldHeight / 2;
let radius = 10 * zoom;
- const midX = (x2 + x1 + width) / 2;
- const endX = x2 + width < x1 ? x2 + width : x2;
+ const midX = (x2 + x1 + startWidth) / 2;
+ const endX = x2 + endWidth < x1 ? x2 + endWidth : x2;
if (Math.abs(y1 - y2) <= 36 * zoom) {
radius = Math.abs(y2 - y1) / 3;
if (radius <= 2) {
- if (x1 + width <= x2) return `M ${x1 + width} ${y1} L ${x2} ${y2 + 0.1}`;
- else if (x2 + width < x1)
- return `M ${x1} ${y1} L ${x2 + width} ${y2 + 0.1}`;
+ if (x1 + startWidth <= x2)
+ return `M ${x1 + startWidth} ${y1} L ${x2} ${y2 + 0.1}`;
+ else if (x2 + endWidth < x1)
+ return `M ${x1} ${y1} L ${x2 + endWidth} ${y2 + 0.1}`;
}
}
if (y1 <= y2) {
- if (x1 + width <= x2) {
- return `M ${x1 + width} ${y1} L ${
+ if (x1 + startWidth <= x2) {
+ return `M ${x1 + startWidth} ${y1} L ${
midX - radius
} ${y1} A ${radius} ${radius} 0 0 1 ${midX} ${y1 + radius} L ${midX} ${
y2 - radius
} A ${radius} ${radius} 0 0 0 ${midX + radius} ${y2} L ${endX} ${y2}`;
- } else if (x2 <= x1 + width && x1 <= x2) {
- return `M ${x1 + width} ${y1} L ${
- x2 + width
- } ${y1} A ${radius} ${radius} 0 0 1 ${x2 + width + radius} ${
+ } else if (x2 <= x1 + startWidth && x1 <= x2) {
+ return `M ${x1 + startWidth} ${y1} L ${
+ x2 + endWidth
+ } ${y1} A ${radius} ${radius} 0 0 1 ${x2 + endWidth + radius} ${
y1 + radius
- } L ${x2 + width + radius} ${y2 - radius} A ${radius} ${radius} 0 0 1 ${
- x2 + width
- } ${y2} L ${x2 + width} ${y2}`;
- } else if (x2 + width >= x1 && x2 + width <= x1 + width) {
+ } L ${x2 + endWidth + radius} ${y2 - radius} A ${radius} ${radius} 0 0 1 ${
+ x2 + endWidth
+ } ${y2} L ${x2 + endWidth} ${y2}`;
+ } else if (x2 + endWidth >= x1 && x2 + endWidth <= x1 + startWidth) {
return `M ${x1} ${y1} L ${
x2 - radius
} ${y1} A ${radius} ${radius} 0 0 0 ${x2 - radius - radius} ${
@@ -89,13 +92,13 @@ export function calcPath(r, tableWidth = 200, zoom = 1, showComments = true) {
} A ${radius} ${radius} 0 0 1 ${midX - radius} ${y2} L ${endX} ${y2}`;
}
} else {
- if (x1 + width <= x2) {
- return `M ${x1 + width} ${y1} L ${
+ if (x1 + startWidth <= x2) {
+ return `M ${x1 + startWidth} ${y1} L ${
midX - radius
} ${y1} A ${radius} ${radius} 0 0 0 ${midX} ${y1 - radius} L ${midX} ${
y2 + radius
} A ${radius} ${radius} 0 0 1 ${midX + radius} ${y2} L ${endX} ${y2}`;
- } else if (x1 + width >= x2 && x1 + width <= x2 + width) {
+ } else if (x1 + startWidth >= x2 && x1 + startWidth <= x2 + endWidth) {
return `M ${x1} ${y1} L ${
x1 - radius - radius
} ${y1} A ${radius} ${radius} 0 0 1 ${x1 - radius - radius - radius} ${
@@ -105,15 +108,15 @@ export function calcPath(r, tableWidth = 200, zoom = 1, showComments = true) {
} A ${radius} ${radius} 0 0 1 ${
x1 - radius - radius
} ${y2} L ${endX} ${y2}`;
- } else if (x1 >= x2 && x1 <= x2 + width) {
- return `M ${x1 + width} ${y1} L ${
- x1 + width + radius
- } ${y1} A ${radius} ${radius} 0 0 0 ${x1 + width + radius + radius} ${
+ } else if (x1 >= x2 && x1 <= x2 + endWidth) {
+ return `M ${x1 + startWidth} ${y1} L ${
+ x1 + startWidth + radius
+ } ${y1} A ${radius} ${radius} 0 0 0 ${x1 + startWidth + radius + radius} ${
y1 - radius
- } L ${x1 + width + radius + radius} ${
+ } L ${x1 + startWidth + radius + radius} ${
y2 + radius
- } A ${radius} ${radius} 0 0 0 ${x1 + width + radius} ${y2} L ${
- x2 + width
+ } A ${radius} ${radius} 0 0 0 ${x1 + startWidth + radius} ${y2} L ${
+ x2 + endWidth
} ${y2}`;
} else {
return `M ${x1} ${y1} L ${
@@ -132,8 +135,8 @@ export function calcPath(r, tableWidth = 200, zoom = 1, showComments = true) {
* forks back out to the columns on the other table.
*
* @param {{
- * startTable: { x: number, y: number, comment?: string, fields?: any[] },
- * endTable: { x: number, y: number, comment?: string, fields?: any[] },
+ * startTable: { x: number, y: number, width?: number, comment?: string, fields?: any[] },
+ * endTable: { x: number, y: number, width?: number, comment?: string, fields?: any[] },
* startFieldIndices: number[],
* endFieldIndices: number[],
* }} r
@@ -144,33 +147,35 @@ export function calcPath(r, tableWidth = 200, zoom = 1, showComments = true) {
* endCardinality: { x: number, y: number },
* } | null}
*/
-export function calcCompositePath(
- r,
- tableWidth = 200,
- zoom = 1,
- showComments = true,
-) {
+export function calcCompositePath(r, zoom = 1, showComments = true) {
if (!r || !r.startFieldIndices?.length || !r.endFieldIndices?.length) {
return null;
}
- const width = tableWidth * zoom;
- const anchorY = (table, index) =>
+ const startTableWidth = getTableWidth(r.startTable);
+ const endTableWidth = getTableWidth(r.endTable);
+ const startWidth = startTableWidth * zoom;
+ const endWidth = endTableWidth * zoom;
+ const anchorY = (table, index, tableWidth) =>
table.y +
tableHeaderHeight +
getCommentHeight(table.comment, tableWidth, showComments) +
getFieldOffsetY(table.fields ?? [], index, tableWidth, showComments) +
tableFieldHeight / 2;
- const startYs = r.startFieldIndices.map((i) => anchorY(r.startTable, i));
- const endYs = r.endFieldIndices.map((i) => anchorY(r.endTable, i));
+ const startYs = r.startFieldIndices.map((i) =>
+ anchorY(r.startTable, i, startTableWidth),
+ );
+ const endYs = r.endFieldIndices.map((i) =>
+ anchorY(r.endTable, i, endTableWidth),
+ );
// Connect each table on the edge facing the other table.
- const startCenter = r.startTable.x + width / 2;
- const endCenter = r.endTable.x + width / 2;
+ const startCenter = r.startTable.x + startWidth / 2;
+ const endCenter = r.endTable.x + endWidth / 2;
const startIsLeft = startCenter <= endCenter;
- const startX = startIsLeft ? r.startTable.x + width : r.startTable.x;
- const endX = startIsLeft ? r.endTable.x : r.endTable.x + width;
+ const startX = startIsLeft ? r.startTable.x + startWidth : r.startTable.x;
+ const endX = startIsLeft ? r.endTable.x : r.endTable.x + endWidth;
const dir = startIsLeft ? 1 : -1;
const fork = 24 * zoom;
const mergeStartX = startX + dir * fork;
@@ -196,7 +201,11 @@ export function calcCompositePath(
}
const dx = Math.sign(cornerX - fromX);
const dy = Math.sign(toY - fromY);
- const r = Math.min(radius, Math.abs(toY - fromY), Math.abs(cornerX - fromX));
+ const r = Math.min(
+ radius,
+ Math.abs(toY - fromY),
+ Math.abs(cornerX - fromX),
+ );
return `M ${fromX} ${fromY} L ${cornerX - dx * r} ${fromY} Q ${cornerX} ${fromY} ${cornerX} ${fromY + dy * r} L ${cornerX} ${toY}`;
};
@@ -219,7 +228,9 @@ export function calcCompositePath(
const segs = [];
// Each start column forks into the trunk.
- startYs.forEach((y) => segs.push(branch(startX, y, mergeStartX, trunkStartY)));
+ startYs.forEach((y) =>
+ segs.push(branch(startX, y, mergeStartX, trunkStartY)),
+ );
// Single trunk between the two collectors.
segs.push(trunk(mergeStartX, trunkStartY, mergeEndX, trunkEndY));
// Each end column forks out of the trunk.
diff --git a/src/utils/dbml/reconcile.js b/src/utils/dbml/reconcile.js
index 3fe42b34..dc84589f 100644
--- a/src/utils/dbml/reconcile.js
+++ b/src/utils/dbml/reconcile.js
@@ -1,7 +1,7 @@
import { nanoid } from "nanoid";
-import { defaultBlue, tableWidth } from "../../data/constants";
+import { defaultBlue } from "../../data/constants";
import { arrangeTables } from "../arrangeTables";
-import { isKeyword } from "../utils";
+import { getTableWidth, isKeyword } from "../utils";
import { isInlineEnumType, typeTakesSize } from "./types";
const NEW_TABLE_GAP_X = 80;
@@ -216,7 +216,8 @@ function placeNewTables(tables) {
}
const x =
- Math.max(...placed.map((table) => table.x + tableWidth)) + NEW_TABLE_GAP_X;
+ Math.max(...placed.map((table) => table.x + getTableWidth(table))) +
+ NEW_TABLE_GAP_X;
const y = Math.min(...placed.map((table) => table.y));
unplaced.forEach((table, i) => {
diff --git a/src/utils/modalData.js b/src/utils/modalData.js
index 65481337..f1b29a61 100644
--- a/src/utils/modalData.js
+++ b/src/utils/modalData.js
@@ -19,8 +19,6 @@ export const getModalTitle = (modal) => {
return i18n.t("save_as");
case MODAL.NEW:
return i18n.t("create_new_diagram");
- case MODAL.TABLE_WIDTH:
- return i18n.t("table_width");
case MODAL.LANGUAGE:
return i18n.t("language");
case MODAL.SHARE:
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 6503f62a..c53b33ed 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -4,6 +4,9 @@ import {
tableFieldHeight,
tableHeaderHeight,
tableColorStripHeight,
+ tableWidth as defaultTableWidth,
+ minTableWidth,
+ maxTableWidth,
} from "../data/constants";
export function dataURItoBlob(dataUrl) {
@@ -161,11 +164,17 @@ export function getFieldHeight(field, containerWidth, showComments = true) {
);
}
+export function clampTableWidth(width) {
+ return Math.min(maxTableWidth, Math.max(minTableWidth, Math.round(width)));
+}
+
+export function getTableWidth(table) {
+ const width = table?.width;
+ return typeof width === "number" && width > 0 ? width : defaultTableWidth;
+}
+
export function getRelationshipFields(relationship) {
- if (
- Array.isArray(relationship?.fields) &&
- relationship.fields.length > 0
- ) {
+ if (Array.isArray(relationship?.fields) && relationship.fields.length > 0) {
return relationship.fields;
}
return [
@@ -245,12 +254,8 @@ export function getFieldOffsetY(
return total;
}
-export function getTableHeight(
- table,
- width,
- showComments = true,
- relationships = [],
-) {
+export function getTableHeight(table, showComments = true, relationships = []) {
+ const width = getTableWidth(table);
const visibleFields = getVisibleFields(table, relationships);
return (
diff --git a/src/utils/views.js b/src/utils/views.js
index c85c7f19..717212e5 100644
--- a/src/utils/views.js
+++ b/src/utils/views.js
@@ -3,6 +3,7 @@ import {
tableFieldHeight,
tableHeaderHeight,
tableColorStripHeight,
+ tableWidth as defaultTableWidth,
} from "../data/constants";
import {
getCommentHeight,
@@ -44,18 +45,16 @@ const quoteFor = {
[DB.MSSQL]: (s) => `[${s}]`,
};
-const identifierQuote = (database) =>
- quoteFor[database] ?? ((s) => `"${s}"`);
+const identifierQuote = (database) => quoteFor[database] ?? ((s) => `"${s}"`);
export function operatorTakesValue(operator) {
return !valuelessOperators.has(operator);
}
export function viewTableIds(view) {
- return [
- view.baseTableId,
- ...(view.joins ?? []).map((j) => j.tableId),
- ].filter(Boolean);
+ return [view.baseTableId, ...(view.joins ?? []).map((j) => j.tableId)].filter(
+ Boolean,
+ );
}
export function viewScopeTables(view, tables = []) {
@@ -187,7 +186,9 @@ export function buildViewSQL(view, tables = [], database = DB.GENERIC) {
const joinTable = tables.find((t) => t.id === join.tableId);
if (!joinTable) continue;
- const left = join.on ? qualify(join.on.leftTableId, join.on.leftFieldId) : null;
+ const left = join.on
+ ? qualify(join.on.leftTableId, join.on.leftFieldId)
+ : null;
const right = join.on ? qualify(join.tableId, join.on.rightFieldId) : null;
const onClause = left && right ? ` ON ${left} = ${right}` : "";
lines.push(`${join.type} JOIN ${quote(joinTable.name)}${onClause}`);
@@ -271,11 +272,16 @@ export function appendViews(sql, obj, database = obj?.database) {
return sql.trimEnd() ? `${sql.trimEnd()}\n\n${views}` : views;
}
-export function getViewHeight(view, columns, width, showComments = true) {
+export function getViewWidth(view) {
+ const width = view?.width;
+ return typeof width === "number" && width > 0 ? width : defaultTableWidth;
+}
+
+export function getViewHeight(view, columns, showComments = true) {
return (
columns.length * (tableFieldHeight + 1) +
tableHeaderHeight +
tableColorStripHeight +
- getCommentHeight(view.comment, width, showComments)
+ getCommentHeight(view.comment, getViewWidth(view), showComments)
);
}