Skip to content

Commit 94066bd

Browse files
Release v0.0.74
1 parent 159f087 commit 94066bd

17 files changed

Lines changed: 502 additions & 320 deletions

dist/index.css

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.css.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43262,12 +43262,13 @@ var SchemaDesignerToolbar = class {
4326243262
this._toolbarDiv = document.createElement("div");
4326343263
this._container.appendChild(this._toolbarDiv);
4326443264
this._toolbarDiv.classList.add("sd-toolbar");
43265+
this._toolbarDiv.style.color = this._config.colors.toolbarForeground;
4326543266
}
4326643267
addButton(icon, title, callback, onDragEndCallback) {
4326743268
const button = document.createElement("div");
4326843269
this._toolbarDiv.appendChild(button);
4326943270
button.classList.add("sd-toolbar-button");
43270-
button.style.backgroundImage = `url(${icon})`;
43271+
button.innerHTML = icon;
4327143272
button.onclick = callback;
4327243273
button.title = title;
4327343274
if (onDragEndCallback) {
@@ -43393,8 +43394,9 @@ var SchemaDesignerEntity = class {
4339343394
const header = document.createElement("div");
4339443395
header.classList.add("sd-table-header");
4339543396
const headerIcon = document.createElement("div");
43397+
headerIcon.innerHTML = this._config.icons.entityIcon;
4339643398
headerIcon.classList.add("sd-table-header-icon");
43397-
headerIcon.style.backgroundImage = `url(${this._config.icons.entityIcon})`;
43399+
headerIcon.innerHTML = this._config.icons.entityIcon;
4339843400
header.appendChild(headerIcon);
4339943401
const headerText = document.createElement("div");
4340043402
headerText.classList.add("sd-table-header-text");
@@ -43408,11 +43410,13 @@ var SchemaDesignerEntity = class {
4340843410
columnDiv.classList.add("sd-table-column");
4340943411
const columnIcon = document.createElement("div");
4341043412
columnIcon.classList.add("sd-table-column-icon");
43411-
if (this._config.icons.dataTypeIcons[column.datatype]) {
43412-
columnIcon.style.backgroundImage = `url(${this._config.icons.dataTypeIcons[column.datatype]})`;
43413+
if (this._config.icons.dataTypeIcons[column.dataType] !== void 0) {
43414+
columnIcon.innerHTML = this._config.icons.dataTypeIcons[column.dataType];
4341343415
} else {
43414-
columnIcon.style.backgroundImage = `url(${this._config.icons.customDataTypeIcon})`;
43416+
console.log(column.dataType);
43417+
columnIcon.innerHTML = this._config.icons.customDataTypeIcon;
4341543418
}
43419+
columnIcon.title = column.dataType;
4341643420
columnDiv.appendChild(columnIcon);
4341743421
const columnText = document.createElement("div");
4341843422
columnText.classList.add("sd-table-column-text");
@@ -43456,9 +43460,85 @@ var SchemaDesignerLayout = class extends mxGraphFactory.mxHierarchicalLayout {
4345643460
super(graph, mxGraphFactory.mxConstants.DIRECTION_EAST, true);
4345743461
}
4345843462
execute(parent) {
43463+
this.graph.getModel().beginUpdate();
4345943464
this.interHierarchySpacing = 100;
4346043465
this.orientation = mxGraphFactory.mxConstants.DIRECTION_WEST;
4346143466
super.execute(parent);
43467+
let cells = this.graph.getModel().getChildCells(this.graph.getDefaultParent());
43468+
this.graph.moveCells(cells, 100, 0, false);
43469+
cells = cells.filter((cell2) => !cell2.edge);
43470+
const cellSet = new Set(cells.map((cell2) => cell2.id));
43471+
const subGraphs = [];
43472+
for (const cell2 of cells) {
43473+
if (cellSet.has(cell2.id)) {
43474+
const subGraph = [];
43475+
const queue = [cell2];
43476+
cellSet.delete(cell2.id);
43477+
while (queue.length > 0) {
43478+
const current = queue.shift();
43479+
cellSet.delete(current.id);
43480+
subGraph.push(current);
43481+
const edges = this.graph.getModel().getEdges(current);
43482+
for (const edge of edges) {
43483+
let nextNode = void 0;
43484+
if (edge.source.id === current.id) {
43485+
nextNode = edge.target;
43486+
} else if (edge.target.id === current.id) {
43487+
nextNode = edge.source;
43488+
}
43489+
if (nextNode !== void 0) {
43490+
if (cellSet.has(nextNode.id)) {
43491+
queue.push(nextNode);
43492+
cellSet.delete(nextNode.id);
43493+
}
43494+
}
43495+
}
43496+
}
43497+
subGraphs.push(subGraph);
43498+
}
43499+
}
43500+
const boundingBoxes = subGraphs.map((subGraph) => {
43501+
let minX = Number.MAX_VALUE;
43502+
let minY = Number.MAX_VALUE;
43503+
let maxX2 = Number.MIN_VALUE;
43504+
let maxY = Number.MIN_VALUE;
43505+
for (const cell2 of subGraph) {
43506+
const geo = cell2.getGeometry();
43507+
if (geo) {
43508+
minX = Math.min(minX, geo.x);
43509+
minY = Math.min(minY, geo.y);
43510+
maxX2 = Math.max(maxX2, geo.x + geo.width);
43511+
maxY = Math.max(maxY, geo.y + geo.height);
43512+
}
43513+
}
43514+
return { minX, minY, maxX: maxX2, maxY };
43515+
});
43516+
const maxX = Math.max(...boundingBoxes.map((box) => box.maxX));
43517+
const standaloneCells = [];
43518+
for (const subGraph of subGraphs) {
43519+
if (subGraph.length === 1) {
43520+
standaloneCells.push(...subGraph);
43521+
}
43522+
}
43523+
const startX = Math.min(...standaloneCells.map((cell2) => cell2.geometry.x));
43524+
const startY = Math.min(...standaloneCells.map((cell2) => cell2.geometry.y));
43525+
const intercellSpacing = 100;
43526+
let currentX = startX;
43527+
let currentY = startY;
43528+
let currentRowMaxHeight = 0;
43529+
for (let i = 0; i < standaloneCells.length; i++) {
43530+
if (currentX + intercellSpacing > maxX) {
43531+
currentX = startX;
43532+
currentY = currentY + currentRowMaxHeight + intercellSpacing;
43533+
currentRowMaxHeight = 0;
43534+
}
43535+
const cell2 = standaloneCells[i];
43536+
cell2.geometry.x = currentX;
43537+
cell2.geometry.y = currentY;
43538+
currentX = currentX + cell2.geometry.width + intercellSpacing;
43539+
currentRowMaxHeight = Math.max(currentRowMaxHeight, cell2.geometry.height);
43540+
}
43541+
this.graph.getModel().endUpdate();
4346243542
}
4346343543
};
4346443544

@@ -43495,6 +43575,8 @@ var SchemaDesigner = class {
4349543575
this._container.style.setProperty("--sd-border-color", this._config.colors.cellBorder);
4349643576
this._container.style.setProperty("--sd-cell-html-foreground", this._config.colors.cellForeground);
4349743577
this._container.style.setProperty("--sd-cell-html-hover-column-background", this._config.colors.cellColumnHover);
43578+
this._container.style.setProperty("--sd-cell-divider-color", this._config.colors.cellDivider);
43579+
this._container.style.setProperty("--sd-graph-background-color", this._config.colors.cellBackground);
4349843580
this._graph.getStylesheet().getDefaultVertexStyle()["fillColor"] = this._config.colors.cellBackground;
4349943581
this._graph.getStylesheet().getDefaultEdgeStyle()["strokeColor"] = this._config.colors.edge;
4350043582
this._graph.getStylesheet().getDefaultVertexStyle()["cellHighlightColor"] = this._config.colors.cellHighlight;
@@ -43841,17 +43923,17 @@ var SchemaDesigner = class {
4384143923
schema: "dbo",
4384243924
columns: [{
4384343925
name: "Column1",
43844-
datatype: "int",
43926+
dataType: "int",
4384543927
isPrimaryKey: true,
4384643928
isIdentity: true
4384743929
}, {
4384843930
name: "Column2",
43849-
datatype: "int",
43931+
dataType: "int",
4385043932
isPrimaryKey: false,
4385143933
isIdentity: false
4385243934
}, {
4385343935
name: "Column2",
43854-
datatype: "int",
43936+
dataType: "int",
4385543937
isPrimaryKey: false,
4385643938
isIdentity: false
4385743939
}]

dist/index.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/ts/schemaDesigner/schemaDesigner.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class SchemaDesigner {
4141
this._container.style.setProperty("--sd-border-color", this._config.colors.cellBorder);
4242
this._container.style.setProperty("--sd-cell-html-foreground", this._config.colors.cellForeground);
4343
this._container.style.setProperty("--sd-cell-html-hover-column-background", this._config.colors.cellColumnHover);
44+
this._container.style.setProperty("--sd-cell-divider-color", this._config.colors.cellDivider);
45+
this._container.style.setProperty("--sd-graph-background-color", this._config.colors.cellBackground);
4446
this._graph.getStylesheet().getDefaultVertexStyle()["fillColor"] = this._config.colors.cellBackground;
4547
this._graph.getStylesheet().getDefaultEdgeStyle()["strokeColor"] = this._config.colors.edge;
4648
this._graph.getStylesheet().getDefaultVertexStyle()['cellHighlightColor'] = this._config.colors.cellHighlight;
@@ -420,17 +422,17 @@ class SchemaDesigner {
420422
schema: "dbo",
421423
columns: [{
422424
name: "Column1",
423-
datatype: "int",
425+
dataType: "int",
424426
isPrimaryKey: true,
425427
isIdentity: true
426428
}, {
427429
name: "Column2",
428-
datatype: "int",
430+
dataType: "int",
429431
isPrimaryKey: false,
430432
isIdentity: false
431433
}, {
432434
name: "Column2",
433-
datatype: "int",
435+
dataType: "int",
434436
isPrimaryKey: false,
435437
isIdentity: false
436438
}]

dist/src/ts/schemaDesigner/schemaDesignerEntity.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ class SchemaDesignerEntity {
2424
const header = document.createElement("div");
2525
header.classList.add("sd-table-header");
2626
const headerIcon = document.createElement("div");
27+
headerIcon.innerHTML = this._config.icons.entityIcon;
2728
headerIcon.classList.add("sd-table-header-icon");
28-
headerIcon.style.backgroundImage = `url(${this._config.icons.entityIcon})`;
29+
headerIcon.innerHTML = this._config.icons.entityIcon;
2930
header.appendChild(headerIcon);
3031
const headerText = document.createElement("div");
3132
headerText.classList.add("sd-table-header-text");
@@ -39,12 +40,14 @@ class SchemaDesignerEntity {
3940
columnDiv.classList.add("sd-table-column");
4041
const columnIcon = document.createElement("div");
4142
columnIcon.classList.add("sd-table-column-icon");
42-
if (this._config.icons.dataTypeIcons[column.datatype]) {
43-
columnIcon.style.backgroundImage = `url(${this._config.icons.dataTypeIcons[column.datatype]})`;
43+
if (this._config.icons.dataTypeIcons[column.dataType] !== undefined) {
44+
columnIcon.innerHTML = this._config.icons.dataTypeIcons[column.dataType];
4445
}
4546
else {
46-
columnIcon.style.backgroundImage = `url(${this._config.icons.customDataTypeIcon})`;
47+
console.log(column.dataType);
48+
columnIcon.innerHTML = this._config.icons.customDataTypeIcon;
4749
}
50+
columnIcon.title = column.dataType;
4851
columnDiv.appendChild(columnIcon);
4952
const columnText = document.createElement("div");
5053
columnText.classList.add("sd-table-column-text");

dist/src/ts/schemaDesigner/schemaDesignerInterfaces.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface IColumn {
2424
/**
2525
* Data type of the column
2626
*/
27-
datatype: string;
27+
dataType: string;
2828
/**
2929
* Is the column primary key
3030
*/
@@ -94,6 +94,7 @@ export interface SchemaDesignerConfig {
9494
cellBackground: string;
9595
cellBorder: string;
9696
cellColumnHover: string;
97+
cellDivider: string;
9798
toolbarBackground: string;
9899
toolbarForeground: string;
99100
toolbarHoverBackground: string;

0 commit comments

Comments
 (0)