Skip to content

Commit

Permalink
Merge pull request #10 from lastlink/dev
Browse files Browse the repository at this point in the history
v 0.0.2
  • Loading branch information
lastlink authored Jun 23, 2024
2 parents f6aae58 + afe4d3f commit f6a30aa
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
plugins for sql tooling in drawio

## Getting Started
* see https://github.com/ariel-bentu/tam-drawio for install options with vscode
* see https://github.com/ariel-bentu/tam-drawio for multiple install options
* download plugin file
* [sql.js](https://raw.githubusercontent.com/lastlink/sqltooling-drawio/main/dist/sql.js)
* or clone project `git clone --branch main git@github.com:lastlink/sqltooling-drawio.git` and check `dist folder`
* vscode [Draw.io Integration](https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio)
* settings.json
```json
"hediet.vscode-drawio.plugins": [
{
"file": "xxx\\sqltooling-drawio\\dist\\sql.js"
},
```

## Examples
* ![menu_from_sql](./assets/menu_from_sql.png)
* ![menu_from_sql](./assets/menu_export_as_to_sql.png)

## Development
* `npm install`
Expand Down
Binary file added assets/menu_export_as_to_sql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu_from_sql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions dist/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,11 +896,11 @@ const generate_sql_ddl_1 = require("@funktechno/little-mermaid-2-the-sql/lib/src
const sqlsimpleparser_1 = require("@funktechno/sqlsimpleparser");
/**
* SQL Tools Plugin for importing diagrams from SQL DDL and exporting to SQL.
* Version: 0.0.1
* Version: 0.0.2
*/
Draw.loadPlugin(function (ui) {
// export sql methods
const pluginVersion = "0.0.1";
const pluginVersion = "0.0.2";
//Create Base div
const divGenSQL = document.createElement("div");
divGenSQL.style.userSelect = "none";
Expand All @@ -917,7 +917,7 @@ Draw.loadPlugin(function (ui) {
const theMenuExportAs = ui.menus.get("exportAs");
let buttonLabel = "tosql=To SQL";
// vscode extension support
if (!(theMenuExportAs && theMenuExportAs.enabled)) {
if (!(theMenuExportAs && !window.VsCodeApi)) {
buttonLabel = "tosql=Export As SQL";
}
// Extends Extras menu
Expand Down Expand Up @@ -1242,10 +1242,10 @@ Draw.loadPlugin(function (ui) {
const sqlInputFromSQL = document.createElement("textarea");
sqlInputFromSQL.style.height = "200px";
sqlInputFromSQL.style.width = "100%";
const defaultReset = "/*\n\tDrawio default value\n\tPlugin: sql\n\tVersion: ${pluginVersion}\n*/\n\nCREATE TABLE Persons\n(\n PersonID int NOT NULL,\n LastName varchar(255),\n " +
"FirstName varchar(255),\n Address varchar(255),\n City varchar(255),\n Primary Key(PersonID)\n);\n\n" +
"CREATE TABLE Orders\n(\n OrderID int NOT NULL PRIMARY KEY,\n PersonID int NOT NULL,\n FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" +
"\n);";
const defaultReset = `/*\n\tDrawio default value\n\tPlugin: sql\n\tVersion: ${pluginVersion}\n*/\n\nCREATE TABLE Persons\n(\n PersonID int NOT NULL,\n LastName varchar(255),\n " +
"FirstName varchar(255),\n Address varchar(255),\n City varchar(255),\n Primary Key(PersonID)\n);\n\n" +
"CREATE TABLE Orders\n(\n OrderID int NOT NULL PRIMARY KEY,\n PersonID int NOT NULL,\n FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" +
"\n);`;
sqlInputFromSQL.value = defaultReset;
mxUtils.br(divFromSQL);
divFromSQL.appendChild(sqlInputFromSQL);
Expand Down Expand Up @@ -1445,7 +1445,7 @@ Draw.loadPlugin(function (ui) {
ui.menus.addMenuItems(menu, ["fromSql"], parent);
};
}
if (theMenuExportAs && theMenuExportAs.enabled) {
if (theMenuExportAs && !window.VsCodeApi) {
var oldMenuExportAs = theMenuExportAs.funct;
theMenuExportAs.funct = function (...args) {
const [menu, parent] = args;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sqltooling-drawio",
"version": "0.0.1",
"version": "0.0.2",
"description": "plugins for sql tooling in drawio",
"main": "index.js",
"engines": {
Expand Down
9 changes: 5 additions & 4 deletions src/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DbDefinition, DbRelationshipDefinition } from "@funktechno/little-merma
import { ColumnQuantifiers, TableAttribute, TableEntity } from "./types/sql-plugin-types";
import { SqlSimpleParser } from "@funktechno/sqlsimpleparser";
import { ForeignKeyModel, PrimaryKeyModel, PropertyModel, TableModel } from "@funktechno/sqlsimpleparser/lib/types";
declare const window: Customwindow;

/**
* SQL Tools Plugin for importing diagrams from SQL DDL and exporting to SQL.
Expand Down Expand Up @@ -30,7 +31,7 @@ Draw.loadPlugin(function(ui) {
const theMenuExportAs = ui.menus.get("exportAs");
let buttonLabel = "tosql=To SQL";
// vscode extension support
if(!(theMenuExportAs && theMenuExportAs.enabled)) {
if(!(theMenuExportAs && !window.VsCodeApi)) {
buttonLabel = "tosql=Export As SQL";
}
// Extends Extras menu
Expand Down Expand Up @@ -391,10 +392,10 @@ Draw.loadPlugin(function(ui) {
const sqlInputFromSQL = document.createElement("textarea");
sqlInputFromSQL.style.height = "200px";
sqlInputFromSQL.style.width = "100%";
const defaultReset = "/*\n\tDrawio default value\n\tPlugin: sql\n\tVersion: ${pluginVersion}\n*/\n\nCREATE TABLE Persons\n(\n PersonID int NOT NULL,\n LastName varchar(255),\n " +
const defaultReset = `/*\n\tDrawio default value\n\tPlugin: sql\n\tVersion: ${pluginVersion}\n*/\n\nCREATE TABLE Persons\n(\n PersonID int NOT NULL,\n LastName varchar(255),\n " +
"FirstName varchar(255),\n Address varchar(255),\n City varchar(255),\n Primary Key(PersonID)\n);\n\n" +
"CREATE TABLE Orders\n(\n OrderID int NOT NULL PRIMARY KEY,\n PersonID int NOT NULL,\n FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" +
"\n);";
"\n);`;

sqlInputFromSQL.value = defaultReset;
mxUtils.br(divFromSQL);
Expand Down Expand Up @@ -639,7 +640,7 @@ Draw.loadPlugin(function(ui) {
ui.menus.addMenuItems(menu, ["fromSql"], parent);
};
}
if(theMenuExportAs && theMenuExportAs.enabled) {
if(theMenuExportAs && !window.VsCodeApi) {
var oldMenuExportAs = theMenuExportAs.funct;

theMenuExportAs.funct = function(...args) {
Expand Down
4 changes: 4 additions & 0 deletions src/types/drawio-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ declare const Draw: {
loadPlugin(handler: (ui: DrawioUI) => void): void;
};

interface Customwindow extends Window {
VsCodeApi: any | undefined;
}

declare const log: any;
declare class mxCellHighlight {
constructor(graph: DrawioGraph, color: string, arg: number);
Expand Down

0 comments on commit f6a30aa

Please sign in to comment.