Skip to content

Commit

Permalink
feat: husky
Browse files Browse the repository at this point in the history
  • Loading branch information
alswl committed May 12, 2024
1 parent ed8800d commit 2bbfbd6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export default defineConfig({
path: 'https://twitter.com/alswl',
external: true,
},

],
npmClient: 'pnpm',
esbuildMinifyIIFE: true,
analytics: {
ga_v2: 'G-SFYS0VCR5W', // Google Analytics 的 key (GA 4)
baidu: '4d80269d802b65e5b0356366f7fbb125',
}
},
configProvider: {},
});
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# dbml-editor

Online editor for [DBML](https://dbml.dbdiagram.io/home/) files.

![build-status](https://github.com/alswl/dbml-editor/actions/workflows/ci.yaml/badge.svg)

Online editor for [DBML](https://dbml.dbdiagram.io/home/) files.

## Online Editor

[dbml-editor](https://dbml-editor.alswl.com/)
Expand Down
18 changes: 6 additions & 12 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { DagreLayout, GridLayout } from '@antv/layout';
import { Graph, Model } from '@antv/x6';
import { Parser } from '@dbml/core';
import { Col, Row, theme } from 'antd';
import { Col, Row } from 'antd';
import { debounce } from 'lodash-es';
import { useEffect, useRef, useState } from 'react';
import MonacoEditor from 'react-monaco-editor';

import parseDatabaseToER from '@/parser/parser';
import { PageContainer } from '@ant-design/pro-components';
import { Snapline } from '@antv/x6-plugin-snapline';
import './index.less';
import { PageContainer } from '@ant-design/pro-components';
import { useModel } from '@umijs/max';

export default () => {
// constructor
const {
token: { colorBgContainer, borderRadiusLG },
} = theme.useToken();
const initCode = `Table users {
id integer
username varchar
Expand All @@ -43,7 +38,7 @@ Enum post_status {
Ref: posts.user_id > users.id // many-to-one
`;
const [code, setCode] = useState(initCode);
const [code] = useState(initCode);
const [models, setModels] = useState<Model.FromJSONData>({});
const containerRef = useRef(null);
const parser = new Parser();
Expand Down Expand Up @@ -106,23 +101,22 @@ Ref: posts.user_id > users.id // many-to-one
}, [models]);

// editorDidMount
const editorDidMount = (editor: any, monaco: any) => {
const editorDidMount = () => {
const database = parser.parse(code, 'dbmlv2');
let models = parseDatabaseToER(database);
setModels(layout.layout(models));
};

// onchange
const onChange = (newValue: any, e: any) => {
const onChange = (newValue: any) => {
const database = parser.parse(newValue, 'dbmlv2');
console.log(database);
let models = parseDatabaseToER(database);
console.log(models);
setModels(layout.layout(models));
};
const debouncedOnChange = debounce(onChange, 500);

const { name } = useModel('global');
// const { name } = useModel('global');

return (
<PageContainer ghost header={{ title: '' }}>
Expand Down

0 comments on commit 2bbfbd6

Please sign in to comment.