Skip to content

Commit

Permalink
erd-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
recca0120 committed Aug 25, 2024
1 parent 404ced3 commit ded5caa
Show file tree
Hide file tree
Showing 9 changed files with 3,974 additions and 62 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
[![Total Downloads](https://img.shields.io/packagist/dt/recca0120/laravel-erd.svg?style=flat-square)](https://packagist.org/packages/recca0120/laravel-erd)

Laravel ERD automatically generates Entity-Relationship Diagrams from your Laravel models and displays them
using [Vuerd](https://github.com/dineug/erd-editor).
using [erd-editor](https://github.com/dineug/erd-editor).

## Preview

Here's a sample of what you can expect, generated from [migrations](database/migrations)
and [models](tests/Fixtures/Models):

> [View Live Demo](https://previewhtml.github.io/?url=https%3A%2F%2Fgithub.com%2Frecca0120%2Flaravel-erd%2Fblob%2Fmain%2Fdemo%2Findex.html)
> [View Live Demo](https://rawcdn.githack.com/recca0120/laravel-erd/73c9b5189b3a27ade665d70895c4acdbb39064aa/demo/index.html)
![Vuerd](demo/vuerd.jpg)
![erd-editor](demo/erd-editor.png)

## Requirements

Expand Down
Binary file added demo/erd-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 41 additions & 17 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,52 @@
</style>
</head>
<body>
<erd-editor automatic-layout></erd-editor>
<erd-editor automatic-layout system-dark-mode enable-theme-builder></erd-editor>
<script>
function loadScript(src, fallback, callback) {
const script = document.createElement('script');
if (callback) {
script.onload = () => callback();
}
const checkModuleSupport = () => 'supports' in HTMLScriptElement
? HTMLScriptElement.supports('module')
: 'noModule' in document.createElement('script');

if (fallback) {
script.onerror = () => loadScript(fallback, undefined, callback);
}
const createScript = (src) => {
return checkModuleSupport()
? import(src)
: new Promise((resolve, reject) => {
const script = document.createElement('script');
script.onload = () => resolve();
script.onerror = () => reject();
script.src = src;
document.body.appendChild(script);
});
};

script.src = src;
document.body.appendChild(script);
}
const loader = (src, fallback) => {
return createScript(src).catch(() => createScript(fallback));
};

function init() {
const editor = document.querySelector('erd-editor');
editor.loadSQLDDL(atob('Q1JFQVRFIFRBQkxFIGNhcnMgKAogICAgaWQgaW50ZWdlcigxMSkgTk9UIE5VTEwgQVVUT19JTkNSRU1FTlQsCiAgICBtb2RlbCB2YXJjaGFyKDI1NSkgTk9UIE5VTEwsCiAgICBtZWNoYW5pY19pZCBpbnRlZ2VyKDExKSBOT1QgTlVMTCwKICAgIFBSSU1BUlkgS0VZKGlkKQopCkNSRUFURSBUQUJMRSBjb21tZW50cyAoCiAgICBpZCBpbnRlZ2VyKDExKSBOT1QgTlVMTCBBVVRPX0lOQ1JFTUVOVCwKICAgIHBvc3RfaWQgaW50ZWdlcigxMSkgTk9UIE5VTEwsCiAgICB0aXRsZSB2YXJjaGFyKDI1NSkgTk9UIE5VTEwsCiAgICBjcmVhdGVkX2F0IGRhdGV0aW1lLAogICAgdXBkYXRlZF9hdCBkYXRldGltZSwKICAgIFBSSU1BUlkgS0VZKGlkKQopCkNSRUFURSBUQUJMRSBpbWFnZXMgKAogICAgaWQgaW50ZWdlcigxMSkgTk9UIE5VTEwgQVVUT19JTkNSRU1FTlQsCiAgICB1cmwgdmFyY2hhcigyNTUpIE5PVCBOVUxMLAogICAgaW1hZ2VhYmxlX3R5cGUgdmFyY2hhcigyNTUpIE5PVCBOVUxMLAogICAgaW1hZ2VhYmxlX2lkIGludGVnZXIoMTEpIE5PVCBOVUxMLAogICAgY3JlYXRlZF9hdCBkYXRldGltZSwKICAgIHVwZGF0ZWRfYXQgZGF0ZXRpbWUsCiAgICBQUklNQVJZIEtFWShpZCkKKQpDUkVBVEUgVEFCTEUgbWVjaGFuaWNzICgKICAgIGlkIGludGVnZXIoMTEpIE5PVCBOVUxMIEFVVE9fSU5DUkVNRU5ULAogICAgbmFtZSB2YXJjaGFyKDI1NSkgTk9UIE5VTE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IFRBQkxFIGltYWdlcyBBREQgRk9SRUlHTiBLRVkgKGltYWdlYWJsZV9pZCkgUkVGRVJFTkNFUyB1c2VycyAoaWQpCkFMVEVSIFRBQkxFIG1vZGVsX2hhc19wZXJtaXNzaW9ucyBBREQgRk9SRUlHTiBLRVkgKG1vZGVsX2lkKSBSRUZFUkVOQ0VTIHVzZXJzIChpZCkKQUxURVIgVEFCTEUgbW9kZWxfaGFzX3Blcm1pc3Npb25zIEFERCBGT1JFSUdOIEtFWSAocGVybWlzc2lvbl9pZCkgUkVGRVJFTkNFUyBwZXJtaXNzaW9ucyAoaWQpCkFMVEVSIFRBQkxFIG1vZGVsX2hhc19yb2xlcyBBREQgRk9SRUlHTiBLRVkgKG1vZGVsX2lkKSBSRUZFUkVOQ0VTIHVzZXJzIChpZCkKQUxURVIgVEFCTEUgbW9kZWxfaGFzX3JvbGVzIEFERCBGT1JFSUdOIEtFWSAocm9sZV9pZCkgUkVGRVJFTkNFUyByb2xlcyAoaWQpCkFMVEVSIFRBQkxFIHBlcm1pc3Npb25zIEFERCBGT1JFSUdOIEtFWSAoaWQpIFJFRkVSRU5DRVMgcm9sZV9oYXNfcGVybWlzc2lvbnMgKHBlcm1pc3Npb25faWQpCkFMVEVSIFRBQkxFIHBob25lcyBBREQgRk9SRUlHTiBLRVkgKHVzZXJfaWQpIFJFRkVSRU5DRVMgdXNlcnMgKGlkKQpBTFRFUiBUQUJMRSBwb3N0cyBBREQgRk9SRUlHTiBLRVkgKHVzZXJfaWQpIFJFRkVSRU5DRVMgdXNlcnMgKGlkKQpBTFRFUiBUQUJMRSByb2xlX2hhc19wZXJtaXNzaW9ucyBBREQgRk9SRUlHTiBLRVkgKHJvbGVfaWQpIFJFRkVSRU5DRVMgcm9sZXMgKGlkKQ==');
const editor = document.querySelector('erd-editor');

loadScript('../resources/dist/vuerd.min.js', 'https://cdn.jsdelivr.net/npm/vuerd/dist/vuerd.min.js', init);
const root = location.href.replace('demo/index.html', '');
if (checkModuleSupport()) {
const scripts = [[
root + 'resources/dist/erd-editor.esm.js',
'https://cdn.jsdelivr.net/npm/@dineug/erd-editor/+esm',
], [
root + 'resources/dist/erd-editor-shiki-worker.esm.js',
'https://cdn.jsdelivr.net/npm/@dineug/erd-editor-shiki-worker/+esm',
]].map(([src, fallback]) => loader(src, fallback));

Promise.all(scripts)
.then(([{ setGetShikiServiceCallback }, { getShikiService }]) => setGetShikiServiceCallback(getShikiService))
.then(() => editor.setSchemaSQL(sql));
} else {
const scripts = [[
root + 'resources/dist/vuerd.min.js',
'https://cdn.jsdelivr.net/npm/vuerd/dist/vuerd.min.js',
]].map(([src, fallback]) => loader(src, fallback));

Promise.all(scripts).then(() => editor.loadSQLDDL(sql));
}
</script>
</body>
</html>
Binary file removed demo/vuerd.jpg
Binary file not shown.
19 changes: 19 additions & 0 deletions resources/dist/erd-editor-shiki-worker.esm.js

Large diffs are not rendered by default.

3,846 changes: 3,846 additions & 0 deletions resources/dist/erd-editor.esm.js

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions resources/views/erd-editor.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Laravel Erd</title>
<style>
body {
margin: 0;
height: 100vh;
}
</style>
</head>
<body>
<erd-editor automatic-layout system-dark-mode enable-theme-builder></erd-editor>
<script>
const checkModuleSupport = () => 'supports' in HTMLScriptElement
? HTMLScriptElement.supports('module')
: 'noModule' in document.createElement('script');
const createScript = (src) => {
return checkModuleSupport()
? import(src)
: new Promise((resolve, reject) => {
const script = document.createElement('script');
script.onload = () => resolve();
script.onerror = () => reject();
script.src = src;
document.body.appendChild(script);
});
};
const loader = (src, fallback) => {
return createScript(src).catch(() => createScript(fallback));
};
const sql = atob('{{ base64_encode(File::get($path)) }}');
const editor = document.querySelector('erd-editor');
if (checkModuleSupport()) {
const scripts = [[
'{{ asset('vendor/laravel-erd/erd-editor.esm.js') }}',
'https://cdn.jsdelivr.net/npm/@dineug/erd-editor/+esm',
], [
'{{ asset('vendor/laravel-erd/erd-editor-shiki-worker.esm.js') }}',
'https://cdn.jsdelivr.net/npm/@dineug/erd-editor-shiki-worker/+esm',
]].map((src, fallback) => loader(src, fallback));
Promise.all(scripts)
.then(([{ setGetShikiServiceCallback }, { getShikiService }]) => setGetShikiServiceCallback(getShikiService))
.then(() => editor.setSchemaSQL(sql));
} else {
const scripts = [[
'{{ asset('vendor/laravel-erd/vuerd.min.js') }}',
'https://cdn.jsdelivr.net/npm/vuerd/dist/vuerd.min.js',
]].map((src, fallback) => loader(src, fallback));
Promise.all(scripts).then(() => editor.loadSQLDDL(sql));
}
</script>
</body>
</html>
41 changes: 0 additions & 41 deletions resources/views/vuerd.blade.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Http/Controllers/LaravelErdController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function index(?string $file = null): View
$extension = File::extension($file);

$path = $storagePath.'/'.$file;
$view = $extension === 'svg' ? 'svg' : 'vuerd';
$view = $extension === 'svg' ? 'svg' : 'erd-editor';

abort_unless(File::exists($path), 404);

Expand Down

0 comments on commit ded5caa

Please sign in to comment.