Skip to content

Commit

Permalink
fix: canvas controller
Browse files Browse the repository at this point in the history
  • Loading branch information
dineug committed Jan 19, 2024
1 parent be215f0 commit 7f0487d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 44 deletions.
5 changes: 5 additions & 0 deletions packages/erd-editor-vscode/src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export abstract class Editor {
) {}

get readonly() {
// TODO: scheme
// scheme: untitled, file, git, conflictResolution
// const editable = vscode.workspace.fs.isWritableFileSystem(
// this.document.uri.scheme
// );
return (
this.document.uri.scheme === 'git' ||
this.document.uri.scheme === 'conflictResolution'
Expand Down
2 changes: 1 addition & 1 deletion packages/erd-editor-vscode/src/erd-editor-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class ErdEditorProvider

const editor = this.createEditor(
document,
webviewPanel.webview,
webview,
this.context,
this.docToTupleMap
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ export const root = css`
left: 0;
will-change: transform;
`;

export const controller = css`
will-change: transform;
`;
70 changes: 40 additions & 30 deletions packages/erd-editor/src/components/erd/canvas/Canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ const Canvas: FC<CanvasProps> = (props, ctx) => {

return html`
<div
class=${styles.root}
${ref(props.canvas)}
class=${styles.controller}
style=${{
width: `${width}px`,
height: `${height}px`,
Expand All @@ -53,34 +52,45 @@ const Canvas: FC<CanvasProps> = (props, ctx) => {
'pointer-events': props.grabMove ? 'none' : 'auto',
}}
>
${cache(
isHighLevelTable(zoomLevel)
? html`${repeat(
tables,
table => table.id,
table => html`<${HighLevelTable} table=${table} />`
)}`
: html`${repeat(
tables,
table => table.id,
table => html`<${Table} table=${table} />`
)}`
)}
${repeat(
memos,
memo => memo.id,
memo => html`<${Memo} memo=${memo} />`
)}
${bHas(show, Show.relationship) ? html`<${CanvasSvg} />` : null}
${drawRelationship?.start
? html`
<${DrawRelationship}
root=${props.root}
draw=${drawRelationship}
/>
`
: null}
<${SharedMouseTracker} />
<div
class=${styles.root}
${ref(props.canvas)}
style=${{
width: `${width}px`,
height: `${height}px`,
'min-width': `${width}px`,
'min-height': `${height}px`,
}}
>
${cache(
isHighLevelTable(zoomLevel)
? html`${repeat(
tables,
table => table.id,
table => html`<${HighLevelTable} table=${table} />`
)}`
: html`${repeat(
tables,
table => table.id,
table => html`<${Table} table=${table} />`
)}`
)}
${repeat(
memos,
memo => memo.id,
memo => html`<${Memo} memo=${memo} />`
)}
${bHas(show, Show.relationship) ? html`<${CanvasSvg} />` : null}
${drawRelationship?.start
? html`
<${DrawRelationship}
root=${props.root}
draw=${drawRelationship}
/>
`
: null}
<${SharedMouseTracker} />
</div>
</div>
`;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { toJson } from '@dineug/erd-editor-schema';
import { nextTick } from '@dineug/r-html';

import { AppContext } from '@/components/appContext';
import { scrollToAction } from '@/engine/modules/settings/atom.actions';
import {
exportJSON,
exportPNG,
Expand All @@ -26,8 +24,8 @@ export function createExportMenus(
},
name: 'json',
onClick: () => {
exportJSON(toJson(store.state), databaseName);
onClose();
exportJSON(toJson(store.state), databaseName);
},
},
{
Expand All @@ -37,8 +35,8 @@ export function createExportMenus(
},
name: 'Schema SQL',
onClick: () => {
exportSchemaSQL(createSchemaSQL(store.state), databaseName);
onClose();
exportSchemaSQL(createSchemaSQL(store.state), databaseName);
},
},
{
Expand All @@ -49,15 +47,7 @@ export function createExportMenus(
name: 'png',
onClick: () => {
onClose();
store.dispatchSync(
scrollToAction({
scrollTop: 0,
scrollLeft: 0,
})
);
nextTick(() => {
exportPNG(root, databaseName);
});
exportPNG(root, databaseName);
},
},
];
Expand Down

0 comments on commit 7f0487d

Please sign in to comment.