@dineug/erd-editor 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -24
- package/dist/components/erd/automatic-table-placement/AutomaticTablePlacement.d.ts +5 -0
- package/dist/components/erd/automatic-table-placement/runElkPlacement.d.ts +12 -0
- package/dist/components/erd/erd-context-menu/menus/tablePlacementMenus.d.ts +24 -0
- package/dist/components/primitives/code-block/CodeBlock.d.ts +2 -2
- package/dist/components/primitives/icon/icons.d.ts +4 -0
- package/dist/constants/tablePlacement.d.ts +15 -0
- package/dist/erd-editor.umd.js +260 -260
- package/dist/index.d.ts +0 -1
- package/dist/index.dev.d.ts +0 -1
- package/dist/index.js +3556 -3337
- package/dist/services/elk-layout/elkGraph.d.ts +44 -0
- package/dist/services/elk-layout/elkLayout.shared-worker.d.ts +2 -0
- package/dist/services/elk-layout/elkLayoutOptions.d.ts +25 -0
- package/dist/services/elk-layout/elkLayoutService.d.ts +21 -0
- package/dist/services/elk-layout/elkWorkerRealm.d.ts +2 -0
- package/dist/services/elk-layout/index.d.ts +13 -0
- package/dist/services/shiki/index.d.ts +10 -0
- package/dist/services/shiki/shiki.shared-worker.d.ts +2 -0
- package/dist/services/shiki/shikiService.d.ts +18 -0
- package/dist/utils/domEvent.d.ts +6 -0
- package/dist/utils/emitter.d.ts +14 -7
- package/dist/utils/globalEventObservable.d.ts +6 -1
- package/dist/utils/promise.d.ts +6 -0
- package/dist/workers/elkLayout.shared-worker.js +1 -0
- package/dist/workers/exportPng.shared-worker.js +26 -26
- package/dist/workers/shiki.shared-worker.js +1 -0
- package/dist/workers/spawn.d.ts +5 -3
- package/dist/workers/spawn.inline.d.ts +2 -0
- package/package.json +7 -4
- package/dist/services/shikiService.d.ts +0 -9
package/README.md
CHANGED
|
@@ -34,10 +34,11 @@ npm install @dineug/erd-editor
|
|
|
34
34
|
|
|
35
35
|
The package ships ES modules with its dependencies left as bare imports, so any bundler
|
|
36
36
|
(Vite, webpack, Rspack, esbuild, …) resolves, dedupes and tree-shakes them like the rest of
|
|
37
|
-
your app.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
your app. Four features run in shared workers — schema garbage collection, the PNG export, the
|
|
38
|
+
automatic table placement and the syntax highlighting — constructed as
|
|
39
|
+
`new SharedWorker(new URL('./workers/…', import.meta.url))`, which those bundlers emit as worker
|
|
40
|
+
files beside your chunks; a strict CSP needs `worker-src 'self'`. Without a bundler, use the UMD
|
|
41
|
+
file described under [Script tag](#script-tag) instead.
|
|
41
42
|
|
|
42
43
|
## Usage
|
|
43
44
|
|
|
@@ -79,7 +80,7 @@ that step; a production build needs nothing.
|
|
|
79
80
|
// vite.config.js
|
|
80
81
|
export default {
|
|
81
82
|
optimizeDeps: {
|
|
82
|
-
exclude: ['@dineug/erd-editor'
|
|
83
|
+
exclude: ['@dineug/erd-editor'],
|
|
83
84
|
},
|
|
84
85
|
};
|
|
85
86
|
```
|
|
@@ -87,16 +88,12 @@ export default {
|
|
|
87
88
|
### Script tag
|
|
88
89
|
|
|
89
90
|
`dist/erd-editor.umd.js` is a self-contained build for a plain `<script>` tag: every
|
|
90
|
-
dependency and
|
|
91
|
-
|
|
91
|
+
dependency and all four workers are inside it, and it registers `<erd-editor>` and exposes the
|
|
92
|
+
two file callbacks as `window.ErdEditor`. It is what `unpkg` and `jsdelivr` serve.
|
|
92
93
|
|
|
93
94
|
```html
|
|
94
95
|
<erd-editor style="display: block; width: 100%; height: 100vh"></erd-editor>
|
|
95
96
|
<script src="https://cdn.jsdelivr.net/npm/@dineug/erd-editor/dist/erd-editor.umd.js"></script>
|
|
96
|
-
<script src="https://cdn.jsdelivr.net/npm/@dineug/erd-editor-shiki-worker/dist/erd-editor-shiki-worker.umd.js"></script>
|
|
97
|
-
<script>
|
|
98
|
-
ErdEditor.setGetShikiServiceCallback(ErdEditorShikiWorker.getShikiService);
|
|
99
|
-
</script>
|
|
100
97
|
```
|
|
101
98
|
|
|
102
99
|
The workers travel inside the file as `data:` URLs, so a strict CSP needs `worker-src data:`
|
|
@@ -165,22 +162,22 @@ erd-editor {
|
|
|
165
162
|
|
|
166
163
|
## Syntax highlighting
|
|
167
164
|
|
|
168
|
-
The SQL and code-generation panels
|
|
169
|
-
|
|
170
|
-
|
|
165
|
+
The SQL and code-generation panels are highlighted by [Shiki](https://shiki.style), in a shared
|
|
166
|
+
worker of its own. There is nothing to install or register: the worker is built the first time a
|
|
167
|
+
code panel renders, so a page that opens none never fetches the grammars.
|
|
171
168
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
| | |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| Languages | SQL, TypeScript, GraphQL, C#, Java, Kotlin, Scala, Go, Python |
|
|
172
|
+
| Themes | `github-dark`, `github-light`, picked from the editor's light / dark appearance |
|
|
175
173
|
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
Those are exactly the languages the panels emit — the JPA generator emits Java, the SQLAlchemy
|
|
175
|
+
generator emits Python, the TypeORM, Sequelize and Drizzle generators emit TypeScript, and the
|
|
176
|
+
DBML and AML generators are highlighted as SQL, the closest grammar shiki ships.
|
|
178
177
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
});
|
|
183
|
-
```
|
|
178
|
+
Where `SharedWorker` is missing — Chrome on Android, Safari before 16.4 — the underlying error is
|
|
179
|
+
logged and the panels render as plain text; nothing else is affected. The regex engine is plain
|
|
180
|
+
JavaScript, so no host CSP needs `wasm-unsafe-eval`.
|
|
184
181
|
|
|
185
182
|
## File dialogs
|
|
186
183
|
|
|
@@ -24,6 +24,11 @@ export declare const PREVIEW_ZOOM_MAX = 0.7;
|
|
|
24
24
|
* between the floor every zoom has and the ceiling above.
|
|
25
25
|
*/
|
|
26
26
|
export declare function previewZoomLevel(content: Rect, viewport: Viewport): number;
|
|
27
|
+
/** How far the simulation has cooled, from 0 to 1. */
|
|
28
|
+
export type PlacementToastState = {
|
|
29
|
+
progress: number;
|
|
30
|
+
};
|
|
31
|
+
export declare function placementDescription({ progress, }: PlacementToastState): string;
|
|
27
32
|
declare const AutomaticTablePlacement: FC<AutomaticTablePlacementProps>;
|
|
28
33
|
export default AutomaticTablePlacement;
|
|
29
34
|
//# sourceMappingURL=AutomaticTablePlacement.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AppContext } from '../../appContext';
|
|
2
|
+
import { ElkLayoutPoint, ElkPlacement } from '../../../services/elk-layout';
|
|
3
|
+
/**
|
|
4
|
+
* Places every table by ELK and hands the layout straight over. No preview
|
|
5
|
+
* overlay: one layout arrives at once, there is nothing to weigh before it
|
|
6
|
+
* lands, and a single undo puts every table back.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* runElkPlacement(app.value, placement, handleChangeAutomaticTablePlacement);
|
|
10
|
+
*/
|
|
11
|
+
export declare function runElkPlacement(app: AppContext, placement: ElkPlacement, onChange: (tables: ElkLayoutPoint[]) => void): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=runElkPlacement.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AppContext } from '../../../appContext';
|
|
2
|
+
import { IconName } from '../../../primitives/icon/icons';
|
|
3
|
+
import { TablePlacement } from '../../../../constants/tablePlacement';
|
|
4
|
+
type Menu = {
|
|
5
|
+
name: string;
|
|
6
|
+
iconName: IconName;
|
|
7
|
+
placement: TablePlacement;
|
|
8
|
+
};
|
|
9
|
+
export declare const menus: Menu[];
|
|
10
|
+
/**
|
|
11
|
+
* The placements the author can ask for. Each one emits the same action, and
|
|
12
|
+
* the editor reads the placement to decide between the preview it watches
|
|
13
|
+
* settle and the layout ELK answers in one go.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* createTablePlacementMenus(app.value, props.onClose).map(menu => ...);
|
|
17
|
+
*/
|
|
18
|
+
export declare function createTablePlacementMenus({ emitter }: AppContext, onClose: () => void): {
|
|
19
|
+
name: string;
|
|
20
|
+
iconName: IconName;
|
|
21
|
+
onClick: () => void;
|
|
22
|
+
}[];
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=tablePlacementMenus.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FC } from '@dineug/r-html';
|
|
2
|
-
import {
|
|
2
|
+
import { Lang } from '../../../constants/language';
|
|
3
3
|
export type CodeBlockProps = {
|
|
4
4
|
value: string;
|
|
5
|
-
lang:
|
|
5
|
+
lang: Lang;
|
|
6
6
|
theme?: 'dark' | 'light';
|
|
7
7
|
onCopy?: (value: string) => void;
|
|
8
8
|
};
|
|
@@ -4,6 +4,8 @@ export declare const ICON_VIEW_BOX = "0 0 24 24";
|
|
|
4
4
|
export declare const ICON_STROKE_WIDTH = 2;
|
|
5
5
|
export type IconNodeChild = IconNode[number];
|
|
6
6
|
declare const LUCIDE_ICON: {
|
|
7
|
+
'align-horizontal-distribute-center': IconNode;
|
|
8
|
+
'align-vertical-distribute-center': IconNode;
|
|
7
9
|
'arrow-right': IconNode;
|
|
8
10
|
atom: IconNode;
|
|
9
11
|
braces: IconNode;
|
|
@@ -43,6 +45,8 @@ declare const LUCIDE_ICON: {
|
|
|
43
45
|
table: IconNode;
|
|
44
46
|
'table-properties': IconNode;
|
|
45
47
|
'undo-2': IconNode;
|
|
48
|
+
'wand-sparkles': IconNode;
|
|
49
|
+
waypoints: IconNode;
|
|
46
50
|
workflow: IconNode;
|
|
47
51
|
x: IconNode;
|
|
48
52
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ValuesType } from '../internal-types';
|
|
2
|
+
/**
|
|
3
|
+
* How the editor lays a document out when the author asks it to. Force is the
|
|
4
|
+
* simulation the editor has always run, and the three below it are ELK
|
|
5
|
+
* algorithms answered off the main thread.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TablePlacement: {
|
|
8
|
+
readonly force: "force";
|
|
9
|
+
readonly layeredHorizontal: "layeredHorizontal";
|
|
10
|
+
readonly layeredVertical: "layeredVertical";
|
|
11
|
+
readonly flow: "flow";
|
|
12
|
+
};
|
|
13
|
+
export type TablePlacement = ValuesType<typeof TablePlacement>;
|
|
14
|
+
export declare const DEFAULT_TABLE_PLACEMENT: TablePlacement;
|
|
15
|
+
//# sourceMappingURL=tablePlacement.d.ts.map
|