Skip to content

Commit f6a30aa

Browse files
authored
Merge pull request #10 from lastlink/dev
v 0.0.2
2 parents f6aae58 + afe4d3f commit f6a30aa

File tree

7 files changed

+34
-14
lines changed

7 files changed

+34
-14
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22
plugins for sql tooling in drawio
33

44
## Getting Started
5-
* see https://github.com/ariel-bentu/tam-drawio for install options with vscode
5+
* see https://github.com/ariel-bentu/tam-drawio for multiple install options
6+
* download plugin file
7+
* [sql.js](https://raw.githubusercontent.com/lastlink/sqltooling-drawio/main/dist/sql.js)
8+
* or clone project `git clone --branch main [email protected]:lastlink/sqltooling-drawio.git` and check `dist folder`
9+
* vscode [Draw.io Integration](https://marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio)
10+
* settings.json
11+
```json
12+
"hediet.vscode-drawio.plugins": [
13+
{
14+
"file": "xxx\\sqltooling-drawio\\dist\\sql.js"
15+
},
16+
```
17+
18+
## Examples
19+
* ![menu_from_sql](./assets/menu_from_sql.png)
20+
* ![menu_from_sql](./assets/menu_export_as_to_sql.png)
621

722
## Development
823
* `npm install`

assets/menu_export_as_to_sql.png

66 KB
Loading

assets/menu_from_sql.png

90.2 KB
Loading

dist/sql.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -896,11 +896,11 @@ const generate_sql_ddl_1 = require("@funktechno/little-mermaid-2-the-sql/lib/src
896896
const sqlsimpleparser_1 = require("@funktechno/sqlsimpleparser");
897897
/**
898898
* SQL Tools Plugin for importing diagrams from SQL DDL and exporting to SQL.
899-
* Version: 0.0.1
899+
* Version: 0.0.2
900900
*/
901901
Draw.loadPlugin(function (ui) {
902902
// export sql methods
903-
const pluginVersion = "0.0.1";
903+
const pluginVersion = "0.0.2";
904904
//Create Base div
905905
const divGenSQL = document.createElement("div");
906906
divGenSQL.style.userSelect = "none";
@@ -917,7 +917,7 @@ Draw.loadPlugin(function (ui) {
917917
const theMenuExportAs = ui.menus.get("exportAs");
918918
let buttonLabel = "tosql=To SQL";
919919
// vscode extension support
920-
if (!(theMenuExportAs && theMenuExportAs.enabled)) {
920+
if (!(theMenuExportAs && !window.VsCodeApi)) {
921921
buttonLabel = "tosql=Export As SQL";
922922
}
923923
// Extends Extras menu
@@ -1242,10 +1242,10 @@ Draw.loadPlugin(function (ui) {
12421242
const sqlInputFromSQL = document.createElement("textarea");
12431243
sqlInputFromSQL.style.height = "200px";
12441244
sqlInputFromSQL.style.width = "100%";
1245-
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 " +
1246-
"FirstName varchar(255),\n Address varchar(255),\n City varchar(255),\n Primary Key(PersonID)\n);\n\n" +
1247-
"CREATE TABLE Orders\n(\n OrderID int NOT NULL PRIMARY KEY,\n PersonID int NOT NULL,\n FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" +
1248-
"\n);";
1245+
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 " +
1246+
"FirstName varchar(255),\n Address varchar(255),\n City varchar(255),\n Primary Key(PersonID)\n);\n\n" +
1247+
"CREATE TABLE Orders\n(\n OrderID int NOT NULL PRIMARY KEY,\n PersonID int NOT NULL,\n FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" +
1248+
"\n);`;
12491249
sqlInputFromSQL.value = defaultReset;
12501250
mxUtils.br(divFromSQL);
12511251
divFromSQL.appendChild(sqlInputFromSQL);
@@ -1445,7 +1445,7 @@ Draw.loadPlugin(function (ui) {
14451445
ui.menus.addMenuItems(menu, ["fromSql"], parent);
14461446
};
14471447
}
1448-
if (theMenuExportAs && theMenuExportAs.enabled) {
1448+
if (theMenuExportAs && !window.VsCodeApi) {
14491449
var oldMenuExportAs = theMenuExportAs.funct;
14501450
theMenuExportAs.funct = function (...args) {
14511451
const [menu, parent] = args;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sqltooling-drawio",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "plugins for sql tooling in drawio",
55
"main": "index.js",
66
"engines": {

src/sql.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DbDefinition, DbRelationshipDefinition } from "@funktechno/little-merma
33
import { ColumnQuantifiers, TableAttribute, TableEntity } from "./types/sql-plugin-types";
44
import { SqlSimpleParser } from "@funktechno/sqlsimpleparser";
55
import { ForeignKeyModel, PrimaryKeyModel, PropertyModel, TableModel } from "@funktechno/sqlsimpleparser/lib/types";
6+
declare const window: Customwindow;
67

78
/**
89
* SQL Tools Plugin for importing diagrams from SQL DDL and exporting to SQL.
@@ -30,7 +31,7 @@ Draw.loadPlugin(function(ui) {
3031
const theMenuExportAs = ui.menus.get("exportAs");
3132
let buttonLabel = "tosql=To SQL";
3233
// vscode extension support
33-
if(!(theMenuExportAs && theMenuExportAs.enabled)) {
34+
if(!(theMenuExportAs && !window.VsCodeApi)) {
3435
buttonLabel = "tosql=Export As SQL";
3536
}
3637
// Extends Extras menu
@@ -391,10 +392,10 @@ Draw.loadPlugin(function(ui) {
391392
const sqlInputFromSQL = document.createElement("textarea");
392393
sqlInputFromSQL.style.height = "200px";
393394
sqlInputFromSQL.style.width = "100%";
394-
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 " +
395+
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 " +
395396
"FirstName varchar(255),\n Address varchar(255),\n City varchar(255),\n Primary Key(PersonID)\n);\n\n" +
396397
"CREATE TABLE Orders\n(\n OrderID int NOT NULL PRIMARY KEY,\n PersonID int NOT NULL,\n FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" +
397-
"\n);";
398+
"\n);`;
398399

399400
sqlInputFromSQL.value = defaultReset;
400401
mxUtils.br(divFromSQL);
@@ -639,7 +640,7 @@ Draw.loadPlugin(function(ui) {
639640
ui.menus.addMenuItems(menu, ["fromSql"], parent);
640641
};
641642
}
642-
if(theMenuExportAs && theMenuExportAs.enabled) {
643+
if(theMenuExportAs && !window.VsCodeApi) {
643644
var oldMenuExportAs = theMenuExportAs.funct;
644645

645646
theMenuExportAs.funct = function(...args) {

src/types/drawio-types.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ declare const Draw: {
33
loadPlugin(handler: (ui: DrawioUI) => void): void;
44
};
55

6+
interface Customwindow extends Window {
7+
VsCodeApi: any | undefined;
8+
}
9+
610
declare const log: any;
711
declare class mxCellHighlight {
812
constructor(graph: DrawioGraph, color: string, arg: number);

0 commit comments

Comments
 (0)