-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
597 additions
and
92 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/erd-editor/src/components/erd/canvas/draw-relationship/DrawRelationship.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { css } from '@dineug/r-html'; | ||
|
||
export const root = css` | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
pointer-events: none; | ||
stroke: var(--key-fk); | ||
overflow: visible; | ||
`; |
91 changes: 91 additions & 0 deletions
91
packages/erd-editor/src/components/erd/canvas/draw-relationship/DrawRelationship.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { FC, onMounted, Ref, svg } from '@dineug/r-html'; | ||
import { fromEvent } from 'rxjs'; | ||
|
||
import { useAppContext } from '@/components/appContext'; | ||
import { drawRelationshipAction } from '@/engine/modules/editor/atom.actions'; | ||
import { DrawRelationship as DrawRelationshipType } from '@/engine/modules/editor/state'; | ||
import { useUnmounted } from '@/hooks/useUnmounted'; | ||
import { getDraw } from '@/utils/draw-relationship/drawRelationship'; | ||
|
||
import * as styles from './DrawRelationship.styles'; | ||
|
||
export type DrawRelationshipProps = { | ||
root: Ref<HTMLDivElement>; | ||
draw: DrawRelationshipType; | ||
}; | ||
|
||
const DrawRelationship: FC<DrawRelationshipProps> = (props, ctx) => { | ||
const app = useAppContext(ctx); | ||
const { addUnsubscribe } = useUnmounted(); | ||
|
||
onMounted(() => { | ||
const $root = props.root.value; | ||
const { store } = app.value; | ||
|
||
addUnsubscribe( | ||
fromEvent<MouseEvent>($root, 'mousemove').subscribe(event => { | ||
event.preventDefault(); | ||
const { x, y } = $root.getBoundingClientRect(); | ||
|
||
store.dispatch( | ||
drawRelationshipAction({ | ||
x: event.clientX - x, | ||
y: event.clientY - y, | ||
}) | ||
); | ||
}) | ||
); | ||
}); | ||
|
||
return () => { | ||
const { store } = app.value; | ||
const { | ||
settings: { width, height }, | ||
} = store.state; | ||
|
||
const { path, line } = getDraw(store.state, props.draw); | ||
|
||
return svg` | ||
<svg | ||
class=${styles.root} | ||
style=${{ | ||
width: `${width}px`, | ||
height: `${height}px`, | ||
'min-width': `${width}px`, | ||
'min-height': `${height}px`, | ||
}} | ||
> | ||
<g> | ||
<path | ||
d=${path.path.d()} | ||
stroke-dasharray="10" | ||
stroke-width="3" | ||
fill="transparent" | ||
></path> | ||
<line | ||
x1=${path.line.start.x1} y1=${path.line.start.y1} | ||
x2=${path.line.start.x2} y2=${path.line.start.y2} | ||
stroke-width="3" | ||
></line> | ||
<line | ||
x1=${line.start.base.x1} y1=${line.start.base.y1} | ||
x2=${line.start.base.x2} y2=${line.start.base.y2} | ||
stroke-width="3" | ||
></line> | ||
<line | ||
x1=${line.start.base2.x1} y1=${line.start.base2.y1} | ||
x2=${line.start.base2.x2} y2=${line.start.base2.y2} | ||
stroke-width="3" | ||
></line> | ||
<line | ||
x1=${line.start.center2.x1} y1=${line.start.center2.y1} | ||
x2=${line.start.center2.x2} y2=${line.start.center2.y2} | ||
stroke-width="3" | ||
></line> | ||
</g> | ||
</svg> | ||
`; | ||
}; | ||
}; | ||
|
||
export default DrawRelationship; |
2 changes: 1 addition & 1 deletion
2
packages/erd-editor/src/components/erd/canvas/high-level-table/HighLevelTable.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/erd-editor/src/components/erd/canvas/table/column/Column.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.