-
Notifications
You must be signed in to change notification settings - Fork 103
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
26 changed files
with
481 additions
and
162 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -29,6 +29,6 @@ export const root = css` | |
} | ||
`; | ||
|
||
export const main = css` | ||
export const scope = css` | ||
${container}; | ||
`; |
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
30 changes: 30 additions & 0 deletions
30
packages/erd-editor/src/components/erd/erdShortcutPerformCheck.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,30 @@ | ||
import { Observable } from 'rxjs'; | ||
|
||
import { Open } from '@/constants/open'; | ||
import { CanvasType } from '@/constants/schema'; | ||
import { RootState } from '@/engine/state'; | ||
|
||
export const erdShortcutPerformCheck = | ||
({ editor, settings }: RootState) => | ||
<T>(source$: Observable<T>) => | ||
new Observable<T>(subscriber => | ||
source$.subscribe({ | ||
next: value => { | ||
const showAutomaticTablePlacement = | ||
editor.openMap[Open.automaticTablePlacement]; | ||
const showTableProperties = editor.openMap[Open.tableProperties]; | ||
const isCanvasType = settings.canvasType === CanvasType.ERD; | ||
|
||
const canPerform = | ||
isCanvasType && | ||
!showAutomaticTablePlacement && | ||
!showTableProperties; | ||
|
||
if (canPerform) { | ||
subscriber.next(value); | ||
} | ||
}, | ||
error: err => subscriber.error(err), | ||
complete: () => subscriber.complete(), | ||
}) | ||
); |
31 changes: 31 additions & 0 deletions
31
packages/erd-editor/src/components/erd/table-properties/TableProperties.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,31 @@ | ||
import { css } from '@dineug/r-html'; | ||
|
||
export const root = css` | ||
position: absolute; | ||
inset: 0; | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 16px; | ||
&::after { | ||
content: ''; | ||
position: absolute; | ||
inset: 0; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
} | ||
`; | ||
|
||
export const container = css` | ||
width: 100%; | ||
max-width: 900px; | ||
max-height: calc(100% - 32px); | ||
overflow: auto; | ||
z-index: 1; | ||
border-radius: 6px; | ||
padding: 12px; | ||
background-color: var(--context-menu-background); | ||
border: 1px solid var(--context-menu-border); | ||
`; |
59 changes: 59 additions & 0 deletions
59
packages/erd-editor/src/components/erd/table-properties/TableProperties.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,59 @@ | ||
import { FC, html, onMounted } from '@dineug/r-html'; | ||
|
||
import { useAppContext } from '@/components/appContext'; | ||
import { Open } from '@/constants/open'; | ||
import { changeOpenMapAction } from '@/engine/modules/editor/atom.actions'; | ||
import { useUnmounted } from '@/hooks/useUnmounted'; | ||
import { onStop } from '@/utils/domEvent'; | ||
import { KeyBindingName } from '@/utils/keyboard-shortcut'; | ||
|
||
import * as styles from './TableProperties.styles'; | ||
|
||
export type TablePropertiesProps = { | ||
tableId: string; | ||
}; | ||
|
||
const TableProperties: FC<TablePropertiesProps> = (props, ctx) => { | ||
const app = useAppContext(ctx); | ||
const { addUnsubscribe } = useUnmounted(); | ||
|
||
const handleClose = () => { | ||
const { store } = app.value; | ||
store.dispatch(changeOpenMapAction({ [Open.tableProperties]: false })); | ||
}; | ||
|
||
const handleOutsideClick = (event: MouseEvent) => { | ||
const el = event.target as HTMLElement | null; | ||
if (!el) return; | ||
|
||
const canClose = !el.closest(`.${styles.container}`); | ||
canClose && handleClose(); | ||
}; | ||
|
||
onMounted(() => { | ||
const { shortcut$ } = app.value; | ||
|
||
addUnsubscribe( | ||
shortcut$.subscribe(({ type }) => { | ||
type === KeyBindingName.stop && handleClose(); | ||
}) | ||
); | ||
}); | ||
|
||
return () => html` | ||
<div | ||
class=${styles.root} | ||
@contextmenu=${onStop} | ||
@mousedown=${onStop} | ||
@touchstart=${onStop} | ||
@wheel=${onStop} | ||
@click=${handleOutsideClick} | ||
> | ||
<div class=${['scrollbar', styles.container]}> | ||
<div style=${{ width: '800px', height: '400px' }}>TableProperties</div> | ||
</div> | ||
</div> | ||
`; | ||
}; | ||
|
||
export default TableProperties; |
Oops, something went wrong.