@dineug/erd-editor 3.10.0 → 4.0.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.
Files changed (347) hide show
  1. package/README.md +316 -147
  2. package/dist/components/appContext.d.ts +4 -0
  3. package/dist/components/erd/Erd.d.ts +3 -0
  4. package/dist/components/erd/automatic-table-placement/AutomaticTablePlacement.d.ts +2 -1
  5. package/dist/components/erd/automatic-table-placement/createAutomaticTablePlacement.d.ts +38 -2
  6. package/dist/components/erd/automatic-table-placement/elkPlacement.d.ts +42 -0
  7. package/dist/components/erd/automatic-table-placement/flowPlacement.d.ts +21 -0
  8. package/dist/components/erd/automatic-table-placement/placementActions.d.ts +14 -0
  9. package/dist/components/erd/automatic-table-placement/runElkPlacement.d.ts +0 -11
  10. package/dist/components/erd/canvas/SceneIcon.template.d.ts +2 -2
  11. package/dist/components/erd/canvas/entityDrag.d.ts +17 -1
  12. package/dist/components/erd/canvas/middleButtonPan.d.ts +11 -0
  13. package/dist/components/erd/canvas/sceneTokens.d.ts +38 -0
  14. package/dist/components/erd/canvas/table/Table.d.ts +9 -1
  15. package/dist/components/erd/canvas/table/doubleClick.d.ts +3 -4
  16. package/dist/components/erd/canvas/table-group/TableGroup.d.ts +17 -0
  17. package/dist/components/erd/canvas/table-group/TableGroupBody.d.ts +17 -0
  18. package/dist/components/erd/canvas/table-group/TableGroupDropTarget.d.ts +10 -0
  19. package/dist/components/erd/canvas/table-group/TableGroupSash.d.ts +35 -0
  20. package/dist/components/erd/canvas/table-group/TableGroups.d.ts +10 -0
  21. package/dist/components/erd/canvas/table-group/tableGroupBox.d.ts +40 -0
  22. package/dist/components/erd/canvas/table-group/titleLayout.d.ts +45 -0
  23. package/dist/components/erd/canvas/useMoveEntity.d.ts +2 -0
  24. package/dist/components/erd/draw-target/DrawTargetButtons.d.ts +16 -0
  25. package/dist/components/erd/draw-target/DrawTargetButtons.styles.d.ts +14 -0
  26. package/dist/components/erd/draw-target/drawTargetState.d.ts +26 -0
  27. package/dist/components/erd/draw-target/findDrawTarget.d.ts +29 -0
  28. package/dist/components/erd/draw-target/placePill.d.ts +49 -0
  29. package/dist/components/erd/erd-context-menu/ErdContextMenu.d.ts +6 -0
  30. package/dist/components/erd/erd-context-menu/menus/drawRelationshipMenus.d.ts +3 -0
  31. package/dist/components/erd/erd-context-menu/menus/exportMenus.d.ts +7 -2
  32. package/dist/components/erd/erd-context-menu/menus/importMenus.d.ts +5 -1
  33. package/dist/components/erd/erd-context-menu/menus/relationshipMenus.d.ts +6 -2
  34. package/dist/components/erd/erd-context-menu/menus/showMenus.d.ts +3 -1
  35. package/dist/components/erd/erd-context-menu/menus/tablePlacementMenus.d.ts +3 -0
  36. package/dist/components/erd/floating-toolbar/ToolbarCompass.template.d.ts +3 -1
  37. package/dist/components/erd/hitTest.d.ts +16 -1
  38. package/dist/components/erd/minimap/MinimapScene.d.ts +1 -1
  39. package/dist/components/erd/minimap/table/Table.d.ts +3 -3
  40. package/dist/components/erd/minimap/table-group/TableGroup.d.ts +17 -0
  41. package/dist/components/erd/table-group/TableGroupDraft.d.ts +15 -0
  42. package/dist/components/erd/table-group/TableGroupDraft.styles.d.ts +6 -0
  43. package/dist/components/erd/table-group/tableGroupName.d.ts +21 -0
  44. package/dist/components/erd/table-group/useTableGroupDraw.d.ts +25 -0
  45. package/dist/components/erd/table-properties/TableProperties.styles.d.ts +2 -2
  46. package/dist/components/erd/table-properties/table-properties-indexes/indexes-key/IndexesKey.d.ts +6 -0
  47. package/dist/components/erd/table-properties/table-properties-tabs/TablePropertiesTabs.d.ts +3 -0
  48. package/dist/components/erd/welcome-screen/WelcomeScreen.d.ts +17 -0
  49. package/dist/components/erd/welcome-screen/WelcomeScreen.styles.d.ts +17 -0
  50. package/dist/components/erd/welcome-screen/welcome-hints/WelcomeHints.d.ts +21 -0
  51. package/dist/components/erd/welcome-screen/welcome-hints/WelcomeHints.styles.d.ts +14 -0
  52. package/dist/components/erd/welcome-screen/welcome-hints/hintArrows.d.ts +10 -0
  53. package/dist/components/erd/welcome-screen/welcomeLayout.d.ts +87 -0
  54. package/dist/components/erd-editor/ErdEditor.d.ts +66 -6
  55. package/dist/components/erd-editor/useErdEditorAttachElement.d.ts +14 -1
  56. package/dist/components/export-image/ExportImage.d.ts +23 -0
  57. package/dist/components/export-image/ExportImage.styles.d.ts +34 -0
  58. package/dist/components/export-image/exportImageActions.d.ts +48 -0
  59. package/dist/components/find-replace/panelLayout.d.ts +4 -1
  60. package/dist/components/generator-code/GeneratorCode.d.ts +1 -0
  61. package/dist/components/generator-code/generator-code-context-menu/GeneratorCodeContextMenu.d.ts +3 -0
  62. package/dist/components/generator-code/generator-code-context-menu/menus/columnNameCaseMenus.d.ts +3 -0
  63. package/dist/components/generator-code/generator-code-context-menu/menus/languageMenus.d.ts +8 -0
  64. package/dist/components/generator-code/generator-code-context-menu/menus/tableNameCaseMenus.d.ts +3 -0
  65. package/dist/components/generator-code/generator-code-options/GeneratorCodeOptions.d.ts +17 -0
  66. package/dist/components/generator-code/generator-code-options/GeneratorCodeOptions.styles.d.ts +5 -0
  67. package/dist/components/generator-code/generatorCodeView.d.ts +12 -0
  68. package/dist/components/generator-code/languageSettings.d.ts +14 -0
  69. package/dist/components/locale-picker/LocalePicker.d.ts +13 -0
  70. package/dist/components/locale-picker/LocalePicker.styles.d.ts +19 -0
  71. package/dist/components/localeContext.d.ts +10 -0
  72. package/dist/components/localized/Localized.d.ts +18 -0
  73. package/dist/components/map-columns/MapColumnsBody.d.ts +24 -0
  74. package/dist/components/map-columns/MapColumnsDialog.d.ts +13 -0
  75. package/dist/components/map-columns/MapColumnsDialog.styles.d.ts +38 -0
  76. package/dist/components/map-columns/mapColumnsAction.d.ts +13 -0
  77. package/dist/components/map-columns/nameOf.d.ts +6 -0
  78. package/dist/components/map-columns/openMapColumns.d.ts +9 -0
  79. package/dist/components/primitives/code-block/CodeBlock.d.ts +6 -1
  80. package/dist/components/primitives/code-block/CodeBlock.styles.d.ts +2 -0
  81. package/dist/components/primitives/color-picker/ColorPicker.d.ts +10 -1
  82. package/dist/components/primitives/color-picker/ColorPicker.styles.d.ts +25 -0
  83. package/dist/components/primitives/color-picker/colorModel.d.ts +36 -0
  84. package/dist/components/primitives/color-picker/presetColors.d.ts +13 -0
  85. package/dist/components/primitives/color-picker/resolveColor.d.ts +7 -0
  86. package/dist/components/primitives/context-menu/ContextMenu.d.ts +2 -0
  87. package/dist/components/primitives/context-menu/context-menu-content/ContextMenuContent.d.ts +1 -0
  88. package/dist/components/primitives/context-menu/context-menu-content/fitMenu.d.ts +4 -4
  89. package/dist/components/primitives/context-menu/context-menu-separator/ContextMenuSeparator.d.ts +8 -0
  90. package/dist/components/primitives/context-menu/context-menu-separator/ContextMenuSeparator.styles.d.ts +2 -0
  91. package/dist/components/primitives/context-menu/menu/Menu.d.ts +2 -0
  92. package/dist/components/primitives/context-menu/submenu-chevron/SubmenuChevron.d.ts +5 -0
  93. package/dist/components/primitives/dialog/Dialog.d.ts +21 -0
  94. package/dist/components/primitives/dialog/Dialog.styles.d.ts +12 -0
  95. package/dist/components/primitives/highlighted-text/HighlightedText.d.ts +2 -5
  96. package/dist/components/primitives/icon/icons.d.ts +17 -0
  97. package/dist/components/primitives/select/Select.d.ts +18 -0
  98. package/dist/components/primitives/select/Select.styles.d.ts +13 -0
  99. package/dist/components/primitives/text-input/TextInput.d.ts +2 -0
  100. package/dist/components/primitives/toast/Toast.d.ts +5 -1
  101. package/dist/components/primitives/toast/Toast.styles.d.ts +2 -2
  102. package/dist/components/quick-search/QuickSearch.d.ts +2 -1
  103. package/dist/components/quick-search/actions.d.ts +40 -5
  104. package/dist/components/quick-search/hangul.d.ts +16 -10
  105. package/dist/components/quick-search/paletteQuery.d.ts +5 -4
  106. package/dist/components/quick-search/scopedActions.d.ts +6 -5
  107. package/dist/components/schema-sql/SchemaSQL.d.ts +2 -0
  108. package/dist/components/schema-sql/SchemaSQL.styles.d.ts +7 -0
  109. package/dist/components/schema-sql/schema-sql-context-menu/SchemaSQLContextMenu.d.ts +3 -0
  110. package/dist/components/schema-sql/schema-sql-context-menu/menus/bracketMenus.d.ts +3 -0
  111. package/dist/components/schema-sql/schema-sql-context-menu/menus/headerMenus.d.ts +29 -0
  112. package/dist/components/schema-sql/schema-sql-context-menu/menus/statementsMenus.d.ts +27 -0
  113. package/dist/components/schema-sql/schema-sql-options/SchemaSQLOptions.d.ts +24 -0
  114. package/dist/components/schema-sql/schema-sql-options/SchemaSQLOptions.styles.d.ts +45 -0
  115. package/dist/components/schema-sql/schema-sql-options/ScriptEditor.d.ts +20 -0
  116. package/dist/components/schema-sql/schema-sql-options/ScriptEditor.styles.d.ts +13 -0
  117. package/dist/components/schema-sql/schema-sql-options/dropWarning.d.ts +8 -0
  118. package/dist/components/schema-sql/schemaSQLView.d.ts +71 -0
  119. package/dist/components/settings/Settings.styles.d.ts +7 -0
  120. package/dist/components/settings/columnTypeLabels.d.ts +8 -0
  121. package/dist/components/settings/lockSettingRows.d.ts +16 -0
  122. package/dist/components/settings/settings-lnb/SettingsLnb.d.ts +3 -0
  123. package/dist/components/settings/settingsPage.d.ts +10 -0
  124. package/dist/components/theme-builder/ThemeBuilder.d.ts +9 -1
  125. package/dist/components/theme-builder/ThemeBuilder.styles.d.ts +8 -5
  126. package/dist/components/toast-container/openStatusToast.d.ts +29 -0
  127. package/dist/components/toast-container/openToastWhileRunning.d.ts +1 -1
  128. package/dist/components/toolbar/Toolbar.d.ts +1 -0
  129. package/dist/components/visualization/graph-node/GraphNode.d.ts +2 -2
  130. package/dist/components/visualization/graphPan.d.ts +12 -0
  131. package/dist/components/visualization/visualizationView.d.ts +2 -2
  132. package/dist/constants/language.d.ts +1 -1
  133. package/dist/constants/layout.d.ts +34 -0
  134. package/dist/constants/open.d.ts +3 -0
  135. package/dist/constants/schema.d.ts +25 -4
  136. package/dist/constants/sql/dataType/PostgreSQL.d.ts +2 -1
  137. package/dist/constants/sql/dataType/SQLite.d.ts +3 -1
  138. package/dist/engine/actions.d.ts +20 -2
  139. package/dist/engine/context.d.ts +6 -0
  140. package/dist/engine/index.js +26 -21
  141. package/dist/engine/modules/editor/actions.d.ts +10 -2
  142. package/dist/engine/modules/editor/atom.actions.d.ts +49 -11
  143. package/dist/engine/modules/editor/generator.actions.d.ts +107 -8
  144. package/dist/engine/modules/editor/state.d.ts +16 -3
  145. package/dist/engine/modules/editor/utils/color.d.ts +21 -0
  146. package/dist/engine/modules/editor/utils/duplicate.d.ts +28 -1
  147. package/dist/engine/modules/editor/utils/focus.d.ts +16 -0
  148. package/dist/engine/modules/editor/utils/releaseHidden.d.ts +16 -0
  149. package/dist/engine/modules/editor/utils/selection.d.ts +12 -0
  150. package/dist/engine/modules/relationship/actions.d.ts +6 -0
  151. package/dist/engine/modules/relationship/atom.actions.d.ts +57 -1
  152. package/dist/engine/modules/relationship/endFlags.d.ts +14 -0
  153. package/dist/engine/modules/relationship/fkColumns.d.ts +25 -6
  154. package/dist/engine/modules/relationship/history.d.ts +1 -0
  155. package/dist/engine/modules/relationship/hooks.d.ts +0 -11
  156. package/dist/engine/modules/relationship/referenceType.d.ts +12 -0
  157. package/dist/engine/modules/settings/actions.d.ts +17 -4
  158. package/dist/engine/modules/settings/atom.actions.d.ts +63 -19
  159. package/dist/engine/modules/settings/generator.actions.d.ts +7 -0
  160. package/dist/engine/modules/settings/history.d.ts +1 -0
  161. package/dist/engine/modules/table/actions.d.ts +8 -0
  162. package/dist/engine/modules/table/atom.actions.d.ts +31 -0
  163. package/dist/engine/modules/table/generator.actions.d.ts +3 -3
  164. package/dist/engine/modules/table/history.d.ts +1 -0
  165. package/dist/engine/modules/table-column/generator.actions.d.ts +8 -0
  166. package/dist/engine/modules/table-column/hooks.d.ts +0 -6
  167. package/dist/engine/modules/table-column/keys.d.ts +14 -0
  168. package/dist/engine/modules/table-column/utils/dataType.d.ts +19 -1
  169. package/dist/engine/modules/table-group/actions.d.ts +63 -0
  170. package/dist/engine/modules/table-group/atom.actions.d.ts +238 -0
  171. package/dist/engine/modules/table-group/generator.actions.d.ts +111 -0
  172. package/dist/engine/modules/table-group/history.d.ts +13 -0
  173. package/dist/engine/peer-store.d.ts +9 -3
  174. package/dist/engine/replication-store.d.ts +6 -3
  175. package/dist/engine/rx-operators/groupByStreamActions.d.ts +5 -1
  176. package/dist/engine/rx-operators/lockIgnoreFilter.d.ts +8 -0
  177. package/dist/engine/rx-store.d.ts +2 -0
  178. package/dist/engine/settle.d.ts +9 -0
  179. package/dist/engine/store-hooks.d.ts +0 -8
  180. package/dist/erd-editor.umd.js +2100 -4194
  181. package/dist/hooks/useNavigatorLanguages.d.ts +7 -0
  182. package/dist/i18n/locales.d.ts +126 -0
  183. package/dist/i18n/menuLabel.d.ts +12 -0
  184. package/dist/i18n/messages/ar-SA.d.ts +399 -0
  185. package/dist/i18n/messages/de-DE.d.ts +375 -0
  186. package/dist/i18n/messages/en/code.d.ts +17 -0
  187. package/dist/i18n/messages/en/colorPicker.d.ts +35 -0
  188. package/dist/i18n/messages/en/common.d.ts +65 -0
  189. package/dist/i18n/messages/en/contextMenu.d.ts +29 -0
  190. package/dist/i18n/messages/en/exportImage.d.ts +25 -0
  191. package/dist/i18n/messages/en/feedback.d.ts +11 -0
  192. package/dist/i18n/messages/en/findReplace.d.ts +36 -0
  193. package/dist/i18n/messages/en/floatingToolbar.d.ts +12 -0
  194. package/dist/i18n/messages/en/index.d.ts +378 -0
  195. package/dist/i18n/messages/en/mapColumns.d.ts +39 -0
  196. package/dist/i18n/messages/en/palette.d.ts +40 -0
  197. package/dist/i18n/messages/en/schemaSql.d.ts +28 -0
  198. package/dist/i18n/messages/en/settings.d.ts +22 -0
  199. package/dist/i18n/messages/en/shortcuts.d.ts +32 -0
  200. package/dist/i18n/messages/en/tableProperties.d.ts +34 -0
  201. package/dist/i18n/messages/en/themeBuilder.d.ts +7 -0
  202. package/dist/i18n/messages/en/toolbar.d.ts +9 -0
  203. package/dist/i18n/messages/en/visualization.d.ts +12 -0
  204. package/dist/i18n/messages/en/welcome.d.ts +13 -0
  205. package/dist/i18n/messages/es-ES.d.ts +381 -0
  206. package/dist/i18n/messages/eu-ES.d.ts +375 -0
  207. package/dist/i18n/messages/fa-IR.d.ts +375 -0
  208. package/dist/i18n/messages/fr-FR.d.ts +381 -0
  209. package/dist/i18n/messages/he-IL.d.ts +381 -0
  210. package/dist/i18n/messages/id-ID.d.ts +369 -0
  211. package/dist/i18n/messages/index.d.ts +11 -0
  212. package/dist/i18n/messages/it-IT.d.ts +381 -0
  213. package/dist/i18n/messages/ja-JP.d.ts +369 -0
  214. package/dist/i18n/messages/ko-KR.d.ts +369 -0
  215. package/dist/i18n/messages/nl-NL.d.ts +375 -0
  216. package/dist/i18n/messages/pl-PL.d.ts +387 -0
  217. package/dist/i18n/messages/pt-BR.d.ts +381 -0
  218. package/dist/i18n/messages/pt-PT.d.ts +381 -0
  219. package/dist/i18n/messages/ro-RO.d.ts +381 -0
  220. package/dist/i18n/messages/ru-RU.d.ts +387 -0
  221. package/dist/i18n/messages/sk-SK.d.ts +387 -0
  222. package/dist/i18n/messages/sl-SI.d.ts +387 -0
  223. package/dist/i18n/messages/sv-SE.d.ts +375 -0
  224. package/dist/i18n/messages/tr-TR.d.ts +375 -0
  225. package/dist/i18n/messages/uk-UA.d.ts +387 -0
  226. package/dist/i18n/messages/zh-CN.d.ts +369 -0
  227. package/dist/i18n/messages/zh-TW.d.ts +369 -0
  228. package/dist/i18n/resolveLocale.d.ts +11 -0
  229. package/dist/i18n/source.d.ts +7 -0
  230. package/dist/i18n/translate.d.ts +58 -0
  231. package/dist/index.d.ts +2 -0
  232. package/dist/index.js +29797 -13894
  233. package/dist/internal-types/index.d.ts +2 -4
  234. package/dist/konva/scene/contentBounds.d.ts +18 -12
  235. package/dist/konva/scene/metrics.d.ts +2 -0
  236. package/dist/konva/scene/renderScene.d.ts +10 -4
  237. package/dist/konva/scene/stacking.d.ts +21 -0
  238. package/dist/konva/scene/viewLayout.d.ts +2 -1
  239. package/dist/loadValue-B3EFSe9k.js +12925 -0
  240. package/dist/peer/index.d.ts +6 -3
  241. package/dist/peer/index.js +83 -76
  242. package/dist/services/elk-layout/elkGraph.d.ts +6 -4
  243. package/dist/services/elk-layout/elkLayoutOptions.d.ts +20 -0
  244. package/dist/services/elk-layout/elkLayoutService.d.ts +3 -3
  245. package/dist/services/export-png/ExportScene.d.ts +3 -3
  246. package/dist/services/export-png/documentScene.d.ts +14 -9
  247. package/dist/services/export-png/exportBox.d.ts +40 -5
  248. package/dist/services/export-png/exportPngService.d.ts +15 -0
  249. package/dist/services/export-png/exportTheme.d.ts +26 -0
  250. package/dist/services/export-png/index.d.ts +44 -11
  251. package/dist/services/export-png/renderPng.d.ts +18 -10
  252. package/dist/services/export-png/renderSvg.d.ts +22 -0
  253. package/dist/services/export-png/sceneSvg.d.ts +54 -0
  254. package/dist/services/shiki/graphqlGrammar.d.ts +8 -0
  255. package/dist/shared-store-fUggY7sI.js +1341 -0
  256. package/dist/themes/radix-ui-theme.d.ts +11 -3
  257. package/dist/themes/tokens.d.ts +9 -0
  258. package/dist/utils/calcTable.d.ts +9 -0
  259. package/dist/utils/clipboard.d.ts +9 -0
  260. package/dist/utils/collection/tableGroup.entity.d.ts +3 -0
  261. package/dist/utils/contrastText.d.ts +21 -0
  262. package/dist/utils/deepMerge.d.ts +8 -0
  263. package/dist/utils/device-detect/index.d.ts +2 -6
  264. package/dist/utils/domEvent.d.ts +18 -0
  265. package/dist/utils/dragSelect.d.ts +2 -0
  266. package/dist/utils/draw-relationship/bezier.d.ts +2 -0
  267. package/dist/utils/draw-relationship/corner.d.ts +9 -0
  268. package/dist/utils/draw-relationship/index.d.ts +18 -18
  269. package/dist/utils/draw-relationship/loop.d.ts +29 -0
  270. package/dist/utils/draw-relationship/pathFinding.d.ts +1 -1
  271. package/dist/utils/draw-relationship/sort.d.ts +8 -1
  272. package/dist/utils/draw-relationship/stub.d.ts +4 -3
  273. package/dist/utils/emitter.d.ts +53 -6
  274. package/dist/utils/file/exportFile.d.ts +15 -5
  275. package/dist/utils/file/importFile.d.ts +9 -5
  276. package/dist/utils/file/importSchema.d.ts +45 -0
  277. package/dist/utils/find-replace/findMatches.d.ts +1 -1
  278. package/dist/utils/find-replace/present.d.ts +5 -3
  279. package/dist/utils/generator-code/columnTypes.d.ts +99 -0
  280. package/dist/utils/generator-code/doctrine.d.ts +6 -0
  281. package/dist/utils/generator-code/doctrineReservedWords.d.ts +7 -0
  282. package/dist/utils/generator-code/graphql.d.ts +6 -0
  283. package/dist/utils/generator-code/heck.d.ts +5 -0
  284. package/dist/utils/generator-code/java.d.ts +28 -0
  285. package/dist/utils/generator-code/jsonSchema.d.ts +50 -0
  286. package/dist/utils/generator-code/jsonShape.d.ts +37 -0
  287. package/dist/utils/generator-code/kotlin.d.ts +1 -0
  288. package/dist/utils/generator-code/mermaid.d.ts +5 -0
  289. package/dist/utils/generator-code/php.d.ts +28 -0
  290. package/dist/utils/generator-code/rust.d.ts +13 -0
  291. package/dist/utils/generator-code/rustTypes.d.ts +44 -0
  292. package/dist/utils/generator-code/scala.d.ts +1 -0
  293. package/dist/utils/generator-code/seaorm.d.ts +22 -0
  294. package/dist/utils/generator-code/swift.d.ts +44 -0
  295. package/dist/utils/generator-code/utils.d.ts +19 -0
  296. package/dist/utils/generator-code/zod.d.ts +25 -0
  297. package/dist/utils/globalEventObservable.d.ts +10 -1
  298. package/dist/utils/highlightWords.d.ts +29 -0
  299. package/dist/utils/index.d.ts +1 -2
  300. package/dist/utils/keyboard-shortcut/bindKeys.d.ts +9 -0
  301. package/dist/utils/keyboard-shortcut/index.d.ts +11 -4
  302. package/dist/utils/keyboard-shortcut/utils.d.ts +21 -0
  303. package/dist/utils/map-columns/alignTypes.d.ts +37 -0
  304. package/dist/utils/map-columns/buildRows.d.ts +102 -0
  305. package/dist/utils/map-columns/candidateKeys.d.ts +24 -0
  306. package/dist/utils/map-columns/index.d.ts +8 -0
  307. package/dist/utils/map-columns/mapping.d.ts +67 -0
  308. package/dist/utils/map-columns/prefill.d.ts +26 -0
  309. package/dist/utils/map-columns/toMapColumnsActions.d.ts +10 -0
  310. package/dist/utils/map-columns/validate.d.ts +45 -0
  311. package/dist/utils/memo.d.ts +4 -0
  312. package/dist/utils/schema-aml-parser/types.d.ts +2 -0
  313. package/dist/utils/schema-dbml-parser/tokenizer.d.ts +2 -0
  314. package/dist/utils/schema-dbml-parser/types.d.ts +11 -0
  315. package/dist/utils/schema-sql/Databricks.d.ts +8 -3
  316. package/dist/utils/schema-sql/MSSQL.d.ts +14 -2
  317. package/dist/utils/schema-sql/MariaDB.d.ts +6 -5
  318. package/dist/utils/schema-sql/MySQL.d.ts +13 -4
  319. package/dist/utils/schema-sql/Oracle.d.ts +19 -5
  320. package/dist/utils/schema-sql/PostgreSQL.d.ts +16 -4
  321. package/dist/utils/schema-sql/SQLite.d.ts +16 -4
  322. package/dist/utils/schema-sql/Snowflake.d.ts +8 -3
  323. package/dist/utils/schema-sql/index.d.ts +16 -1
  324. package/dist/utils/schema-sql/options.d.ts +57 -0
  325. package/dist/utils/schema-sql/utils.d.ts +101 -2
  326. package/dist/utils/stageCursor.d.ts +20 -0
  327. package/dist/utils/table-clipboard/placement.d.ts +2 -0
  328. package/dist/utils/tableColor.d.ts +29 -0
  329. package/dist/utils/tableGroup.d.ts +142 -0
  330. package/dist/utils/tableKeys.d.ts +11 -3
  331. package/dist/workers/elkLayout.shared-worker.js +1 -1
  332. package/dist/workers/exportPng.shared-worker.js +30 -30
  333. package/dist/workers/shiki.shared-worker.js +1 -1
  334. package/dist/workers/spawn.d.ts +1 -2
  335. package/dist/workers/spawn.inline.d.ts +0 -1
  336. package/package.json +6 -13
  337. package/dist/components/generator-code/GeneratorCode.styles.d.ts +0 -2
  338. package/dist/loadValue-Mdc5K4qO.js +0 -10858
  339. package/dist/schemaGCService-CZtGFh2z.js +0 -42
  340. package/dist/services/schema-gc/index.d.ts +0 -18
  341. package/dist/services/schema-gc/procGC.d.ts +0 -4
  342. package/dist/services/schema-gc/schemaGC.shared-worker.d.ts +0 -2
  343. package/dist/services/schema-gc/schemaGCService.d.ts +0 -10
  344. package/dist/shared-store-D82WVL5a.js +0 -1129
  345. package/dist/styles/colorPicker.style.d.ts +0 -7
  346. package/dist/utils/draw-relationship/chamfer.d.ts +0 -3
  347. package/dist/workers/schemaGC.shared-worker.js +0 -1
package/README.md CHANGED
@@ -2,32 +2,157 @@
2
2
 
3
3
  > Entity-Relationship Diagram Editor as a custom element
4
4
 
5
- ![erd-editor](https://github.com/dineug/erd-editor/blob/main/img/erd-editor-vscode.png?raw=true)
5
+ ![ERD Editor](https://github.com/dineug/erd-editor/blob/main/img/erd-editor-vscode.png?raw=true)
6
6
 
7
- `<erd-editor>` is a full database-schema editor in a single custom element. It has no
8
- framework dependency and renders into a closed shadow root, so it drops into any page —
7
+ `<erd-editor>` is a database-schema editor in a single custom element: design tables and
8
+ relationships visually, import SQL DDL, GraphQL SDL, DBML or AML, and export DDL or generated code.
9
+ It has no framework dependency and renders into a closed shadow root, so it drops into any page —
9
10
  React, Vue, Svelte, or plain HTML — without leaking styles either way.
10
11
 
11
- This is the same editor that powers [erd-editor.io](https://erd-editor.io), the
12
+ It is the same editor as [erd-editor.io](https://erd-editor.io), the
12
13
  [Google Drive app](https://workspace.google.com/marketplace/app/erd_editor/428467403360), the
13
- [VS Code extension](https://marketplace.visualstudio.com/items?itemName=dineug.vuerd-vscode),
14
- the [IntelliJ plugin](https://plugins.jetbrains.com/plugin/23594-erd-editor) and the
14
+ [VS Code extension](https://marketplace.visualstudio.com/items?itemName=dineug.vuerd-vscode), the
15
+ [IntelliJ plugin](https://plugins.jetbrains.com/plugin/23594-erd-editor) and the
15
16
  [Obsidian plugin](https://community.obsidian.md/plugins/erd-editor).
16
17
 
17
18
  ## Features
18
19
 
19
- - Visual schema design — tables, columns, memos, and four relationship cardinalities
20
- (zero-one, zero-N, one-only, one-N)
21
- - Import — a `.sql` dump, a GraphQL SDL schema from any tool that emits one, a `.dbml` file, or
22
- an `.aml` file
23
- - SQL DDL export — Databricks, MariaDB, MSSQL, MySQL, Oracle, PostgreSQL, Snowflake and SQLite
24
- - Code generation — TypeScript, GraphQL, C#, Java, JPA, Kotlin, Scala, Go,
25
- SQLAlchemy, TypeORM, Sequelize, Drizzle, DBML, AML
26
- - Export — `.erd.json`, `.sql`, `.png`
27
- - Force-directed visualization of table relationships
28
- - Quick search over commands, and over tables, columns, comments and memos after `#`, `@` or `:`,
29
- find and replace, undo / redo, remappable keyboard shortcuts, and a built-in theme builder
30
- - Collaboration hooks — the editor emits and applies actions; you supply the transport
20
+ ### Design
21
+
22
+ - **Visual schema design** — tables, columns, memos, and four relationship cardinalities (Zero One,
23
+ Zero N, One Only, One N)
24
+ - **Quick edits** — `Alt`+`N` adds a table and `Alt`+`Enter` a column, `Alt`+`K` toggles the primary
25
+ key on the focused column, or on every selected column when it is one of them, and `Delete` or
26
+ `Backspace` removes the selection, each in one undo step; the Shortcuts page of the editor's
27
+ Settings tab lists every key, and `setKeyBindingMap` remaps them
28
+ - **Link existing columns** — while you draw a relationship with a mouse or a pen, the buttons
29
+ beside the table it ends on either map the parent's key onto columns that table already has or add
30
+ new ones, named after the parent table when the key is one word (`user_id` for `user`'s `id`), and
31
+ **Map Columns** in a relationship's right-click menu changes its columns later
32
+ - **Referential actions** — set **On Delete** and **On Update** (NO ACTION, CASCADE, SET NULL, SET
33
+ DEFAULT, RESTRICT) from a relationship's right-click menu, which marks one the current database
34
+ leaves out; the line shows them at its child end as `D:C U:R`, and View Option's Referential
35
+ Actions hides the labels. SQL, DBML and AML import read them, and the DDL export and the code
36
+ generators that have a place for them write the ones the target supports
37
+ - **Alternate keys** — View Option's Alternate Key marks the columns of each unique index over two
38
+ or more columns as `AK1.1`, `AK1.2`, and SQL import reads a UNIQUE over several columns as one
39
+ such index
40
+ - **Table groups** — draw a box behind related tables, which you name and can color, with
41
+ **New Table Group** in the canvas menu or the command palette, or group the selected tables from
42
+ their right-click menu. A table joins a group when you drop it inside and leaves when you drop it
43
+ outside, dragging a group by its title moves its tables with it, each member's header takes the
44
+ group's color, View Option hides the groups, and DBML import and the Code Generator's DBML carry
45
+ them as `TableGroup`s
46
+ - **Auto Layout** — place every table again by Force, Flow or a vertical or horizontal tree from the
47
+ canvas menu or the command palette, table groups kept together, in one undo step; Force shows a
48
+ preview you apply or cancel, and the others land at once
49
+ - **Copy, paste and colors** — copy tables and memos and paste them as new ones, into another
50
+ diagram too or into a spreadsheet as a grid, hold `Alt` while dragging to duplicate them, and
51
+ color a table, memo or table group from its right-click menu
52
+ - **Clean diffs** — the scroll position and zoom, the open tab, the code generator's language and
53
+ name cases and the bracket type are locked in a new document
54
+ ([Loading and saving](#loading-and-saving)), so the file keeps the values they had when locked
55
+ and looking around never changes it; the file, written in a fixed order, also leaves out
56
+ measured widths, connector anchors and removed items
57
+
58
+ ### Import
59
+
60
+ - **SQL DDL import** — bring in a `.sql` dump from any of the eight vendors below. The parser reads
61
+ `CREATE TABLE`, `CREATE INDEX`, `ALTER TABLE` constraints and table and column comments
62
+ (`COMMENT ON`, SQL Server's `sp_addextendedproperty`), and skips what it does not recognize, so an
63
+ awkward dump imports partially rather than failing outright
64
+ - **GraphQL SDL import** — bring in a schema from any tool that emits SDL. Object types become
65
+ tables, scalars map to the diagram's own dialect, and the fields that point at another type become
66
+ the relationships; the root types and the wrapper types Relay, Federation and Hasura generate are
67
+ left out rather than drawn as tables
68
+ - **DBML import** — bring in a `.dbml` file written for dbdiagram.io or dbdocs.io, or emitted by
69
+ `sql2dbml` or `prisma-dbml-generator`. Tables, columns, indexes, enums, header colors, every `Ref`
70
+ spelling and each `TableGroup` arrive; a `Project` or a sticky `Note` is skipped rather than
71
+ refused
72
+ - **AML import** — bring in an `.aml` file written for [Azimutt](https://azimutt.app), in either the
73
+ v2 or the legacy v1 spelling. Entities, attributes, indexes, enums, colors and every relation
74
+ arrow arrive; a check and a struct type are skipped rather than refused, and a view arrives as a
75
+ table
76
+ - **Imports land laid out** — a schema picked from the Import menu, the command palette or a host's
77
+ file dialog arrives with its tables placed by their relationships (in rows when it has none), and
78
+ one undo puts the previous diagram back; a `setSchema*` call, as from your own file dialog, is
79
+ laid out the same way when given `{ placement: 'auto' }`
80
+ - **Import and Add** — the menu beside Import, and its five formats in the command palette, add a
81
+ `.sql`, GraphQL, DBML, AML or `.erd.json` file to the diagram instead of replacing it: its tables
82
+ arrive below everything already there, laid out the same way (an `.erd.json` file keeps its own
83
+ placement), selected, and one undo takes them away. A table whose name is already taken arrives as
84
+ a second table rather than merging, and a foreign key to a table outside the file is dropped;
85
+ `{ mode: 'append' }` does the same from `setSchemaJSON` and the four `setSchema*` methods, which
86
+ lay the tables out only with `placement: 'auto'` and stand them in rows otherwise
87
+
88
+ ### Export and code
89
+
90
+ - **SQL DDL export** — Databricks, MariaDB, MSSQL, MySQL, Oracle, PostgreSQL, Snowflake and SQLite,
91
+ from the Schema SQL tab, which saves the DDL as a `.sql` file or copies it, and from
92
+ `getSchemaSQL(vendor?, options?)`
93
+ - **Schema SQL options** — a panel beside the DDL picks the database and the bracket type, CREATE
94
+ TABLE IF NOT EXISTS or drop and re-create and a `USE` or `CREATE + USE` header, each where the
95
+ database has it, and the tables by table group, and keeps SQL of your own to write before and
96
+ after the tables. The statements, header and tables stay with this editor until the element goes
97
+ and never reach the file; the scripts are saved in the document
98
+ - **Code generation** — TypeScript, GraphQL, C#, Java, JPA, Kotlin, Scala, Go, SQLAlchemy, TypeORM,
99
+ Sequelize, Drizzle, DBML, AML, Mermaid, PHP, Doctrine, Rust, SeaORM, Swift, Zod and JSON Schema,
100
+ from the Code Generator tab. Its options panel picks the language, the database, the table and
101
+ column name cases and, for Doctrine, JPA and SeaORM, the bracket type, and saves the code as a
102
+ file with the language's extension
103
+ - **Export** — `.erd.json`, `.sql`, and a `.png` or `.svg` from a dialog with a preview: transparent
104
+ background, light or dark, the PNG at 1x to 3x or copied to the clipboard instead
105
+
106
+ ### Find and navigate
107
+
108
+ - **Quick search** — `Ctrl`/`Cmd`+`K` opens the command palette to run editor commands (new table,
109
+ import, export, Auto Layout, tabs, theme, language and more), or to jump to a table after `#`, a
110
+ column after `@`, and a comment or memo after `:`; Korean also matches by its initial consonants
111
+ (`ㅅㅇㅈ` finds 사용자)
112
+ - **Find and replace** — `Ctrl`/`Cmd`+`F` searches table and column names, comments and memos, with
113
+ match case, whole word and regular expressions, and one undo takes back a Replace All
114
+ - **Visualization** — Graph mode draws a force-directed view of how the tables relate. Flow mode
115
+ lays them out by their relationships, lights a table you hover and the tables it relates to, and
116
+ shows names only, keys only or all fields; **Focus on this table** in a table's right-click menu
117
+ opens Flow on that table and its neighbours, or, when it is one of several selected tables, as
118
+ **Focus on selected tables** on all of them and their neighbours, as `Alt`+`F` does for the
119
+ selection, and neither view writes its layout into the file
120
+ - **Zoom and pan** — pinch a trackpad or two fingers to zoom, drag with the middle button to pan
121
+ from anywhere, and click the zoom level on the floating toolbar to go back to 100%
122
+ - **Time travel** — replay this editing session's history on the canvas and jump to any point in it,
123
+ from the toolbar
124
+ - **Diff viewer** — compare the diagram with another `.json` file from the canvas menu, or from
125
+ `setDiffValue`
126
+ - **Undo / redo** — every edit, from the toolbar or `Ctrl`/`Cmd`+`Z` and `Ctrl`/`Cmd`+`Shift`+`Z`,
127
+ in the editor's own history
128
+
129
+ ### Language and theme
130
+
131
+ - **Display language** — the editor's menus, panels, dialogs, command palette and messages in 25
132
+ languages, Arabic, Hebrew and Persian laid out right to left while the diagram stays left to
133
+ right. The element shows English until the host turns on `enable-locale-picker`, which adds the
134
+ toolbar's language button and **Display Language** and follows System, or calls `setLocale`
135
+ ([Display language](#display-language)); table and column names, SQL keywords, data types and
136
+ generated code stay as they are
137
+ - **Theme** — once the host sets `enable-theme-builder`, the toolbar's theme builder picks the
138
+ appearance, a gray color and an accent color, and **Theme** in the command palette picks the
139
+ appearance; System follows the OS color scheme or what `setSystemAppearance` names, and the
140
+ element stores nothing (`changePresetTheme` tells the host)
141
+ - **Welcome screen** — opt-in with `enable-welcome-screen`: an empty diagram you can edit opens on a
142
+ menu of New Table, New Memo, Import, Command Palette and Shortcuts, with arrows at the toolbar's
143
+ search, theme and language buttons where the element shows them and at the floating toolbar where
144
+ the canvas has room, until its first table, shown memo or shown table group
145
+
146
+ ### Collaboration hooks
147
+
148
+ - **Collaboration hooks** — the editor emits the actions it makes and applies a peer's through
149
+ `getSharedStore()`; you supply the transport, and seed a joining editor with its `runtimeValue`
150
+ ([Collaboration](#collaboration))
151
+ - **Headless entries** — `engine.js` runs a replica with no DOM, so a worker can apply the same
152
+ actions and serialize the document off the main thread, and `peer.js` runs a peer that edits by
153
+ dispatching actions, which the
154
+ [ERD Editor MCP server](https://github.com/dineug/erd-editor/tree/main/packages/mcp-server#readme)
155
+ is built on
31
156
 
32
157
  ## Install
33
158
 
@@ -35,13 +160,11 @@ the [IntelliJ plugin](https://plugins.jetbrains.com/plugin/23594-erd-editor) and
35
160
  npm install @dineug/erd-editor
36
161
  ```
37
162
 
38
- The package ships ES modules with its dependencies left as bare imports, so any bundler
39
- (Vite, webpack, Rspack, esbuild, …) resolves, dedupes and tree-shakes them like the rest of
40
- your app. Four features run in shared workers — schema garbage collection, the PNG export, the
41
- automatic table placement and the syntax highlighting — constructed as
42
- `new SharedWorker(new URL('./workers/…', import.meta.url))`, which those bundlers emit as worker
43
- files beside your chunks; a strict CSP needs `worker-src 'self'`. Without a bundler, use the UMD
44
- file described under [Script tag](#script-tag) instead.
163
+ Your bundler resolves, dedupes and tree-shakes the package's ES modules and dependencies. The PNG
164
+ and SVG export, the Flow and tree layouts and the syntax highlighting run in shared workers spawned
165
+ as `new SharedWorker(new URL('./workers/…', import.meta.url), { type: 'module', name })`, which
166
+ Vite, webpack and Rspack emit beside your chunks and esbuild does not. A strict CSP needs
167
+ `worker-src 'self'`. Without a bundler, use the [Script tag](#script-tag) build.
45
168
 
46
169
  ## Usage
47
170
 
@@ -49,26 +172,20 @@ file described under [Script tag](#script-tag) instead.
49
172
  import '@dineug/erd-editor';
50
173
 
51
174
  const editor = document.createElement('erd-editor');
52
- // the editor fills its container, and a custom element is inline by default
175
+ // a custom element is inline, and the editor fills its box
53
176
  Object.assign(editor.style, { display: 'block', width: '100%', height: '100vh' });
54
177
  document.body.appendChild(editor);
55
178
 
56
- // load a document without adding an undo entry, then keep it in sync
57
179
  editor.setInitialValue(localStorage.getItem('my-diagram') ?? '');
58
180
  editor.addEventListener('change', () => {
59
181
  localStorage.setItem('my-diagram', editor.value);
60
182
  });
61
183
  ```
62
184
 
63
- `setInitialValue('')` starts a new document, as an element given no value shows: it saves neither
64
- the scroll nor the zoom (Save Scroll Information and Save Zoom Information off), so looking around
65
- leaves `value` as it was. A document loaded from text keeps the switches it names, and one that
66
- names none saves both.
67
-
68
185
  ### Server-side rendering
69
186
 
70
- Importing the package registers the custom element at module scope, so it needs a DOM and
71
- throws in Node. In Next.js, Nuxt, SvelteKit or Astro, reach it from a client-only path:
187
+ Importing the package registers the element, which throws without a DOM, so in Next.js, Nuxt,
188
+ SvelteKit or Astro import it on the client:
72
189
 
73
190
  ```js
74
191
  useEffect(() => {
@@ -78,215 +195,267 @@ useEffect(() => {
78
195
 
79
196
  ### Vite
80
197
 
81
- In development Vite pre-bundles dependencies into its cache directory, and the worker files
82
- would then be looked up there rather than beside the package. Exclude the editor packages from
83
- that step; a production build needs nothing.
198
+ In development Vite would look the worker files up in its pre-bundle cache, so exclude the editor
199
+ and include the CommonJS ELK bundle its layout worker imports, or the Flow and tree layouts fail. A
200
+ production build needs nothing.
84
201
 
85
202
  ```js
86
203
  // vite.config.js
87
204
  export default {
88
205
  optimizeDeps: {
89
206
  exclude: ['@dineug/erd-editor'],
207
+ include: ['@dineug/erd-editor > elkjs/lib/elk.bundled.js'],
90
208
  },
91
209
  };
92
210
  ```
93
211
 
94
212
  ### Script tag
95
213
 
96
- `dist/erd-editor.umd.js` is a self-contained build for a plain `<script>` tag: every
97
- dependency and all four workers are inside it, and it registers `<erd-editor>` and exposes the
98
- two file callbacks as `window.ErdEditor`. It is what `unpkg` and `jsdelivr` serve.
214
+ `dist/erd-editor.umd.js`, served by `unpkg` and `jsdelivr`, bundles every dependency and worker,
215
+ registers `<erd-editor>` and puts `setExportFileCallback`, `setImportFileCallback` and
216
+ `createKeyBindingMap` on `window.ErdEditor`. Its workers are `data:` URLs, so a strict CSP needs
217
+ `worker-src data:`. Pin a version in the URL beyond a demo.
99
218
 
100
219
  ```html
101
220
  <erd-editor style="display: block; width: 100%; height: 100vh"></erd-editor>
102
221
  <script src="https://cdn.jsdelivr.net/npm/@dineug/erd-editor/dist/erd-editor.umd.js"></script>
103
222
  ```
104
223
 
105
- The workers travel inside the file as `data:` URLs, so a strict CSP needs `worker-src data:`
106
- for this build. Pin a version in the URL for anything beyond a demo.
107
-
108
224
  ### HTML
109
225
 
226
+ In a page a bundler serves:
227
+
110
228
  ```html
111
- <erd-editor system-dark-mode enable-theme-builder></erd-editor>
229
+ <erd-editor system-dark-mode style="display: block; height: 100vh"></erd-editor>
112
230
  <script type="module">
113
231
  import '@dineug/erd-editor';
114
-
115
- const editor = document.querySelector('erd-editor');
116
232
  </script>
117
233
  ```
118
234
 
119
- ```css
120
- erd-editor {
121
- display: block;
122
- width: 100%;
123
- height: 100vh;
124
- }
125
- ```
126
-
127
235
  ## API
128
236
 
237
+ The package exports the element's type as `ErdEditorElement`.
238
+
129
239
  ### Attributes
130
240
 
131
241
  | Attribute | Property | Description |
132
242
  | --- | --- | --- |
133
- | `readonly` | `readonly` | Blocks editing and suppresses the `change` event. Assigning `value`, `setSchemaSQL()`, `setSchemaGraphQL()`, `setSchemaDBML()`, `setSchemaAML()` and `clear()` are ignored while it is set — load with `setInitialValue()` instead. Viewport actions and the SQL/code output settings still apply. |
134
- | `system-dark-mode` | `systemDarkMode` | Follows the OS color scheme |
135
- | `enable-theme-builder` | `enableThemeBuilder` | Shows the built-in theme builder |
243
+ | `readonly` | `readonly` | Blocks editing and `change`; `clear()` and every load you start but `setInitialValue()` are ignored. |
244
+ | `system-dark-mode` | `systemDarkMode` | On, sets the appearance to `system`; off, keeps the light or dark it shows. |
245
+ | `enable-theme-builder` | `enableThemeBuilder` | Shows the theme builder's toolbar button and the palette's Theme. |
246
+ | `enable-locale-picker` | `enableLocalePicker` | Shows the toolbar's language button and the palette's Display Language, and makes System the default. |
247
+ | `enable-welcome-screen` | `enableWelcomeScreen` | Shows the welcome screen over an empty, editable diagram, again after an undo back to empty. |
248
+
249
+ An attribute is on when present with no value or `"true"`, off for any other value (`"false"`,
250
+ `"readonly"`).
136
251
 
137
252
  ### Properties
138
253
 
139
254
  | Property | Description |
140
255
  | --- | --- |
141
- | `value: string` | The document as JSON — an `.erd.json` document ([schema](https://github.com/dineug/erd-editor/blob/main/json-schema/schema.json)). Assigning it loads the document as an edit, so it lands in the undo history; use `setInitialValue` to load without one. Assigning an empty string loads a new document, as `setInitialValue('')` does. |
256
+ | `value: string` | The document as a file saves it ([schema](https://github.com/dineug/erd-editor/blob/main/json-schema/schema.json)). Assigning one, or `''` for a new one, is an undoable load. |
257
+ | `runtimeValue: string` | Read only. The document as this editor holds it, to seed a collaborator. |
142
258
 
143
259
  ### Methods
144
260
 
145
261
  | Method | Description |
146
262
  | --- | --- |
147
- | `setInitialValue(value: string)` | Load the initial document. Does not create a history entry, and clears the undo history, so nothing done before the load can be undone or redone onto it. |
148
- | `getSchemaSQL(vendor?)` | Export DDL. `vendor` is one of `Databricks`, `MariaDB`, `MSSQL`, `MySQL`, `Oracle`, `PostgreSQL`, `Snowflake`, `SQLite`; omit it to use the document's own setting. |
149
- | `setSchemaSQL(value: string)` | Parse a DDL string and **replace** the current document with it. Lands in the undo history; an empty string is ignored. |
150
- | `setSchemaGraphQL(value: string)` | Parse a GraphQL SDL string and **replace** the current document with it. Object types become tables, scalars map to the document's own dialect, and relationships are read from the fields that point at another type. Lands in the undo history; an empty string is ignored. |
151
- | `setSchemaDBML(value: string)` | Parse a DBML string and **replace** the current document with it. Tables, columns, indexes and every `Ref` spelling are read; a `Project`, `TableGroup` or sticky `Note` is skipped, and text it cannot read loads an empty document rather than being refused. Lands in the undo history; an empty string is ignored. |
152
- | `setSchemaAML(value: string)` | Parse an [AML](https://azimutt.app) string and **replace** the current document with it. Entities, attributes, indexes and every relation arrow are read, in the v2 and the legacy v1 spelling; a check, a struct type and a view are skipped, and text it cannot read loads an empty document rather than being refused. Lands in the undo history; an empty string is ignored. |
153
- | `setDiffValue(value: string)` | Open the diff viewer against another document. |
154
- | `setPresetTheme(options)` | Set `appearance`, `grayColor` and `accentColor`. |
155
- | `setTheme(theme)` | Override individual theme tokens. |
156
- | `setKeyBindingMap(map)` | Remap shortcuts, `search` and `findReplace` among them. `edit`, `stop`, `undo`, `redo`, `zoomIn`, `zoomOut` and `zoomReset` are reserved. |
157
- | `getSharedStore(config?)` | Returns `{ subscribe, dispatch, dispatchSync, connection, disconnect, destroy }`. `subscribe` gives you this editor's actions to relay; `dispatch` applies a peer's. You supply the transport. `config` is `{ getNickname?, mouseTracker?, focusTracker? }`; both trackers default to `true` and broadcast this editor's cursor and table focus to peers. |
158
- | `focus()` / `blur()` | Move focus in and out of the editor. |
159
- | `clear()` | Empty the document. Its settings stay, the save switches included, so a cleared file keeps saving what it saved. |
160
- | `destroy()` | Tear the editor down and release its listeners, subscriptions and shared stores. |
263
+ | `setInitialValue(value)` | Load a document with no undo entry, clearing the history; `''` starts a new one. |
264
+ | `getSchemaSQL(vendor?, options?)` | DDL for one of the [eight vendors](#export-and-code), by default the document's, scripts included. `options` (`SchemaSQLOptions`): `statements` `create` (default), `ifNotExists` or `recreate`; `header` `none` (default), `use` or `createAndUse`, written only for a plain-identifier database name. |
265
+ | `setSchemaSQL(value, options?)`, `setSchemaGraphQL`, `setSchemaDBML`, `setSchemaAML` | Replace the document with parsed DDL, GraphQL SDL, DBML or AML, or append it ([Importing a schema](#importing-a-schema)). |
266
+ | `setSchemaJSON(value, options?)` | Load an `.erd.json` document as `value` does, or append it. |
267
+ | `setDiffValue(value)` | Diff another document over the ERD tab without switching to it; it opens nothing before that tab first shows. |
268
+ | `setPresetTheme(options)` | Set `appearance` (`light`, `dark`, `system`), `grayColor` and `accentColor`. |
269
+ | `setSystemAppearance(appearance)` | Name the light or dark `system` shows; `null` follows the OS. |
270
+ | `setLocale(locale)` | Set the display language, `'system'` or a [code](#display-language); emits nothing. |
271
+ | `setSystemLocale(tag)` | Name, as a BCP 47 tag, the language `system` shows, for a host with its own UI language; `null` reads `navigator.languages`. |
272
+ | `setTheme(theme)` | Override theme tokens with string values. Each call replaces the earlier overrides, which outlast `setPresetTheme`. |
273
+ | `setKeyBindingMap(map)` | Remap [shortcuts](#key-bindings) but `edit`, `stop`, `undo`, `redo` and the zoom keys. |
274
+ | `getSharedStore(config?)` | A [shared store](#collaboration): `subscribe`, `dispatch`, `dispatchSync`, `connection`, `disconnect`, `flushStreamBuffers`, `destroy`. |
275
+ | `focus()` / `blur()` | Move focus in or out. |
276
+ | `clear()` | Empty the document and keep its settings; one undo brings it back. |
277
+ | `destroy()` | Release the editor's listeners, subscriptions and shared stores. |
161
278
 
162
279
  ### Events
163
280
 
164
281
  | Event | Description |
165
282
  | --- | --- |
166
- | `change` | The document changed. Debounced, and never fired while `readonly`. Read `editor.value`. A scroll or a zoom fires it too. A scroll leaves `value` as it was with Save Scroll Information off; a zoom moves the scroll position too, so it leaves `value` as it was only with Save Zoom Information and Save Scroll Information both off. `value` differs from a file another release or machine wrote from the load on, so a host that writes files tells an edit from such a change by a [headless replica](#headless-replica)'s `changed`, not by comparing bytes with the file. |
167
- | `changePresetTheme` | The theme was changed from inside the editor. `event.detail` carries the new options. |
283
+ | `change` | The document changed; read `editor.value` ([Loading and saving](#loading-and-saving)). |
284
+ | `changePresetTheme` | The theme changed in the editor; `event.detail` holds the options (`appearance: 'system'` for System). |
285
+ | `changeLocale` | A language was picked in the editor; `event.detail.locale` holds it. |
168
286
 
169
- ## Key bindings
287
+ ### Loading and saving
288
+
289
+ Save `value`; `runtimeValue`, which also keeps removed entities, only seeds a
290
+ [collaborator](#collaboration).
291
+
292
+ A new document locks each setting the Settings tab lists under **Lock**, which then saves its value
293
+ at locking. A loaded document keeps its locks, or has all on if it predates them. A replacing load
294
+ (`value`, an import, a peer's load, or the undo of a load or of `clear()`) keeps on screen what the
295
+ incoming document locks (for an import, the current locks), scroll and zoom aside, and takes its
296
+ values for the rest.
297
+
298
+ `change` fires 200 ms after the last change, never under `readonly` or for a scroll, zoom, tab, code
299
+ setting or bracket type under its lock. A file another release wrote, or one edited by hand, can
300
+ differ from `value` once loaded: detect edits by a [replica](#headless-replica)'s `changed`, not by
301
+ bytes.
302
+
303
+ Under `readonly`, only the scroll, zoom, tab, database, code language, name cases and bracket type
304
+ change; a peer's actions relayed into `getSharedStore().dispatch` still apply.
305
+
306
+ ### Importing a schema
307
+
308
+ The four text `setSchema*` methods take
309
+ `{ placement?: 'auto' | 'grid', mode?: 'replace' | 'append' }`, `setSchemaJSON` only `mode`; each
310
+ lands in one undo step and ignores `''`; a replace with unreadable text loads an empty document.
311
+
312
+ `'grid'`, the default, lands at once in rows. `'auto'` lays the tables out first, as the Import menu
313
+ does, and returns a `Promise` that resolves on landing, keeping settings changed meanwhile. A load
314
+ before then (a replacing import, `value`, `setInitialValue`, `clear()`, a peer's load or the undo of
315
+ a load or `clear()`) supersedes it, and it resolves with nothing loaded; a readonly editor resolves
316
+ at once.
317
+
318
+ `mode: 'append'` is [Import and Add](#import), table groups included: it lands below hidden groups
319
+ too, keeps every setting but the tab and scroll, and selects new groups while groups show. An
320
+ `'auto'` append supersedes nothing: it lands after earlier `'auto'` imports, below the diagram as it
321
+ stands then, and only a later load or replace drops it. From another tab it brings up the ERD tab
322
+ first; a readonly editor adds nothing.
170
323
 
171
- `createKeyBindingMap()` returns the shortcuts an editor listens for until `setKeyBindingMap`
172
- changes them, as a new map on every call. Each is a [tinykeys](https://github.com/jamiebuilds/tinykeys)
173
- chord that names its key by `KeyboardEvent.code`, where `$mod` is Cmd on macOS and Ctrl elsewhere.
324
+ ### Theme and language
325
+
326
+ The element starts dark; `setPresetTheme({ appearance: 'system' })` follows the OS, or the light or
327
+ dark `setSystemAppearance` names. `setLocale` applies at once, so one set before appending paints
328
+ the first frame. `setSystemLocale` matters only under System and shows English for a tag the
329
+ editor lacks. Neither choice is stored; keep what `changePresetTheme` and `changeLocale` report.
330
+
331
+ ## Collaboration
332
+
333
+ A joiner starts from the first editor's runtime value, so an undo there restores removed entities
334
+ whole in both; then each relays its actions:
174
335
 
175
336
  ```js
176
- import { createKeyBindingMap } from '@dineug/erd-editor';
337
+ joiner.setInitialValue(editor.runtimeValue);
177
338
 
178
- const shortcuts = Object.values(createKeyBindingMap())
179
- .flat()
180
- .map(({ shortcut }) => shortcut); // '$mod+KeyK', 'Alt+Enter', ...
339
+ const local = editor.getSharedStore();
340
+ const remote = joiner.getSharedStore();
341
+ local.subscribe(actions => remote.dispatch(actions));
342
+ remote.subscribe(actions => local.dispatch(actions));
181
343
  ```
182
344
 
183
- The editor listens on its own element, so a host that takes keys before the page does, with
184
- global hotkeys or a capture-phase `keydown` listener, has to let these through while the editor
185
- is focused. The `KeyBindingMap`, `KeyBindingName` and `ShortcutOption` types come with it.
345
+ An editor never forwards what it received, so with three or more, send each one's batches to every
346
+ other.
186
347
 
187
- The page's own find is among them: while the editor is focused, on any of its tabs, `$mod+KeyF`
188
- opens its Find and Replace, bringing the ERD tab up, and is prevented, so the browser opens no find
189
- bar; while the diff viewer, time travel or the automatic placement preview covers the ERD tab, the
190
- press goes on to the page. `setKeyBindingMap({ findReplace: [] })` leaves it to the page on every
191
- tab, and the toolbar button, the quick search and the context menu still open Find and Replace.
348
+ `getSharedStore` takes `{ getNickname?, mouseTracker?, focusTracker? }`; `mouseTracker` broadcasts
349
+ the cursor and `focusTracker` the focused cell, selection and drag box, both on by default.
350
+ `disconnect()` holds outgoing actions while your transport is down; `connection()` releases them.
351
+ Call `flushStreamBuffers()` before destroying the store or editor, or drags, color changes and memo
352
+ resizes in their quiet period never reach the peers.
192
353
 
193
- ## Syntax highlighting
354
+ ## Key bindings
194
355
 
195
- The SQL and code-generation panels are highlighted by [Shiki](https://shiki.style), in a shared
196
- worker of its own. There is nothing to install or register: the worker is built the first time a
197
- code panel renders, so a page that opens none never fetches the grammars.
356
+ `createKeyBindingMap()` returns a new map of the default shortcuts. A chord is its modifiers
357
+ (`Shift`, `Alt`, `Control`, `Meta`, or `$mod`: Cmd on macOS and iOS, Ctrl elsewhere) joined by `+`,
358
+ then a `KeyboardEvent.code` or a `key` in any case, matching only those exact modifiers.
198
359
 
199
- | | |
200
- | --- | --- |
201
- | Languages | SQL, TypeScript, GraphQL, C#, Java, Kotlin, Scala, Go, Python |
202
- | Themes | `github-dark`, `github-light`, picked from the editor's light / dark appearance |
360
+ Entries are `ShortcutOption`s, `{ shortcut, preventDefault?, stopPropagation? }`; a remapped one
361
+ without flags lets the browser default run and the keydown bubble. `setKeyBindingMap` replaces each
362
+ list it names. The defaults stop `search`, `findReplace`, `undo`, `redo`, `focusView`, zoom and
363
+ `zenMode`, so bubble-phase listeners miss them while the editor is focused, and a host that takes
364
+ keys first (global hotkeys, a capture listener) must let them through, or leave `$mod+KeyF` to the
365
+ page with `setKeyBindingMap({ findReplace: [] })`. The `KeyBindingMap`, `KeyBindingName` and
366
+ `ShortcutOption` types are exported.
367
+
368
+ ## Display language
203
369
 
204
- Those are exactly the languages the panels emit — the JPA generator emits Java, the SQLAlchemy
205
- generator emits Python, the TypeORM, Sequelize and Drizzle generators emit TypeScript, and the
206
- DBML and AML generators are highlighted as SQL, the closest grammar shiki ships.
370
+ The codes are `en`, `ar-SA`, `de-DE`, `es-ES`, `eu-ES`, `fa-IR`, `fr-FR`, `he-IL`, `id-ID`, `it-IT`,
371
+ `ja-JP`, `ko-KR`, `nl-NL`, `pl-PL`, `pt-BR`, `pt-PT`, `ro-RO`, `ru-RU`, `sk-SK`, `sl-SI`, `sv-SE`,
372
+ `tr-TR`, `uk-UA`, `zh-CN` and `zh-TW`. `setLocale('system')` follows System even without
373
+ `enable-locale-picker`. The `LocaleCode` and `LocaleOption` types are exported; cast a stored
374
+ string `as LocaleOption`, since an unknown value is ignored.
375
+
376
+ ## Syntax highlighting
207
377
 
208
- Where `SharedWorker` is missing — Chrome on Android, Safari before 16.4 — the underlying error is
209
- logged and the panels render as plain text; nothing else is affected. The regex engine is plain
210
- JavaScript, so no host CSP needs `wasm-unsafe-eval`.
378
+ [Shiki](https://shiki.style) highlights the panels' code, DBML and AML as SQL, with a JavaScript
379
+ regex engine, so a CSP needs no `wasm-unsafe-eval`, from a shared worker built when a code panel
380
+ first renders; with a bundler, a page that opens none never fetches the grammars (the UMD file
381
+ carries them).
382
+
383
+ Without `SharedWorker`, as in Chrome on Android before Chrome 148, the panels log the error and show
384
+ plain text, the Flow view places nothing, Auto Layout's Flow and tree placements say "Could not
385
+ place tables" (Force works), an `'auto'` import lands in rows, and PNG and SVG exports draw on the
386
+ main thread.
211
387
 
212
388
  ## File dialogs
213
389
 
214
- Import and export go through injectable callbacks, so a host without a browser file dialog —
215
- an IDE webview, for example — can supply its own. The two are not symmetric: export hands you
216
- the finished file, while import only asks for one, and you push the content back in yourself.
390
+ Import and export go through page-wide callbacks, so a host without a browser file dialog (an IDE
391
+ webview) supplies its own:
217
392
 
218
393
  ```js
219
394
  import { setExportFileCallback, setImportFileCallback } from '@dineug/erd-editor';
220
395
 
221
396
  setExportFileCallback((blob, { fileName }) => host.writeFile(fileName, blob));
222
397
 
223
- setImportFileCallback(async ({ type, op, accept }) => {
398
+ setImportFileCallback(async ({ type, op, accept, mode }) => {
224
399
  const text = await host.pickFile(accept);
225
-
226
- if (op === 'diff') {
227
- editor.setDiffValue(text);
228
- } else if (type === 'json') {
229
- editor.value = text;
230
- } else if (type === 'sql') {
231
- editor.setSchemaSQL(text);
232
- } else if (type === 'graphql') {
233
- editor.setSchemaGraphQL(text);
234
- } else if (type === 'dbml') {
235
- editor.setSchemaDBML(text);
236
- } else if (type === 'aml') {
237
- editor.setSchemaAML(text);
238
- }
400
+ if (op === 'diff') return editor.setDiffValue(text);
401
+ if (type === 'json') return editor.setSchemaJSON(text, { mode });
402
+ const format = { sql: 'SQL', graphql: 'GraphQL', dbml: 'DBML', aml: 'AML' }[type];
403
+ if (format) editor[`setSchema${format}`](text, { placement: 'auto', mode });
239
404
  });
240
405
  ```
241
406
 
242
- Dispatch on every `type` you handle and ignore the rest. Assigning `value` clears the
243
- document before it parses, so routing a payload there that is not an `.erd.json` document —
244
- through a catch-all `else`, or because a `type` added later fell through — empties the
245
- diagram instead of importing anything. `accept` carries the extensions for that type
246
- (`.json`, `.sql`, or `.graphql,.gql,.graphqls`), ready to hand to a host file dialog.
247
-
248
- Left unset, the editor uses the browser's own download and file-picker behavior.
407
+ Export gets `.erd.json`, `.sql`, PNG, SVG and the Code Generator's file. An import's `op` is
408
+ `'diff'` for the Diff Viewer, whose file goes to `setDiffValue()`, so test it first; otherwise it is
409
+ `'set'`. Skip a `type` you do not handle: a replacing `setSchemaJSON()` empties the document on any
410
+ other payload. `accept` lists the type's extensions (`.json`, `.sql`,
411
+ `.graphql,.gql,.graphqls`, `.dbml`, `.aml`), and `mode` is `'append'` from Import and Add. Unset or
412
+ `null`, the browser's download and file picker work.
249
413
 
250
414
  ## Headless replica
251
415
 
252
- A second entry point runs the document store with no DOM, for hosts that need to apply an
253
- action stream and serialize the result off the main thread:
416
+ The `engine.js` replica takes the same actions with no DOM:
254
417
 
255
418
  ```js
256
419
  import { createReplicationStore } from '@dineug/erd-editor/engine.js';
257
420
 
258
- // `toWidth` measures text for layout — a worker has no DOM, so you supply it
259
- const store = createReplicationStore({ toWidth });
260
-
421
+ const store = createReplicationStore({ toWidth }); // a worker has no DOM to measure text
261
422
  store.setInitialValue(savedJson);
262
423
  store.on({ change: ({ value, changed }) => changed && persist(value) });
263
- store.dispatch(actions); // actions relayed from a live editor's shared store
424
+ store.dispatch(actions);
264
425
  ```
265
426
 
266
- `change` comes 200 ms after the last action that can change the document. `changed` is false
267
- when those actions left `value` as it was, such as a scroll with Save Scroll Information off, or a
268
- zoom with Save Zoom Information and Save Scroll Information both off: a zoom moves the scroll
269
- position too, so with only the scroll saved it changes `value`. It compares with the value the
270
- store last reported, or loaded, never with your file: a file another release or machine wrote
271
- serializes differently from the start.
427
+ `value` and `runtimeValue` mirror the element's; `dispatch` applies on the next microtask,
428
+ `dispatchSync` at once, and `destroy` releases the store. `change` comes 200 ms after the last
429
+ document action, locked settings included, with `changed` false when `value` matches what the store
430
+ last reported or loaded, never your file. `ReplicationStore` and `ReplicationChange` are exported
431
+ types.
272
432
 
273
- ## Development
433
+ ### Headless peer
434
+
435
+ `peer.js` runs a collaboration peer with no DOM, the base of the ERD Editor MCP server. Its
436
+ `createPeerStore({ nickname })` store dispatches actions, receives a peer's batches and undoes its
437
+ own dispatches; `PeerStoreError`, per-module action barrels (`tableActions`, `tableActions$`, …) and
438
+ `createSchemaSQL` come with it.
274
439
 
275
- This package is the editor core of the [erd-editor monorepo](https://github.com/dineug/erd-editor);
276
- work on it from a workspace checkout.
440
+ ## Development
277
441
 
278
442
  ```sh
279
- pnpm --filter @dineug/erd-editor dev # builds workspace deps, then a dev server
443
+ pnpm --filter @dineug/erd-editor dev # dev server, workspace deps built first
280
444
  pnpm --filter @dineug/erd-editor dev:storybook # component playground
281
445
  pnpm exec vp run --filter @dineug/erd-editor --fail-if-no-match test
282
446
  pnpm --filter @dineug/erd-editor e2e # Playwright
283
447
  ```
284
448
 
449
+ What a change runs and carries is in
450
+ [AGENTS.md](https://github.com/dineug/erd-editor/blob/main/packages/erd-editor/AGENTS.md).
451
+
285
452
  ## Documentation
286
453
 
454
+ - [Editing Guide](https://docs.erd-editor.io/docs/category/guides) — editing, import and export,
455
+ relationships, quick search, visualization, code generation, settings
456
+ - [Element API](https://docs.erd-editor.io/docs/api/erd-editor-element) — the `<erd-editor>`
457
+ element's API
287
458
  - [Documentation](https://docs.erd-editor.io)
288
- - [Editing Guide](https://docs.erd-editor.io/docs/category/guides)
289
- - [Element API](https://docs.erd-editor.io/docs/api/erd-editor-element)
290
459
 
291
460
  ## Issues
292
461