yangpei
4 years ago
77 changed files with 777 additions and 809 deletions
@ -1,24 +1,20 @@ |
|||||
const path = require('path'); |
const path = require('path'); |
||||
const fs = require('fs-extra'); |
const fs = require('fs-extra'); |
||||
|
|
||||
const INSERT_IMPORT_PLUGINS_COMMENT = '\/\/ import plugins here'; |
const INSERT_IMPORT_PLUGINS_COMMENT = '// import plugins here'; |
||||
const INSERT_USE_PLUGINS_COMMENT = '\/\/ use plugins here'; |
const INSERT_USE_PLUGINS_COMMENT = '// use plugins here'; |
||||
|
|
||||
const setup = async (plugins = [], logicBasePath) => { |
const setup = async (plugins = [], logicBasePath) => { |
||||
const entryFilePath = path.join(logicBasePath, 'index.js'); |
const entryFilePath = path.join(logicBasePath, 'index.js'); |
||||
const codes = await fs.readFile(entryFilePath, 'utf8'); |
const codes = await fs.readFile(entryFilePath, 'utf8'); |
||||
const modifiedContent = codes |
const modifiedContent = codes |
||||
.replace(new RegExp(INSERT_IMPORT_PLUGINS_COMMENT), () => { |
.replace(new RegExp(INSERT_IMPORT_PLUGINS_COMMENT), () => { |
||||
return plugins |
return plugins.map((plugin, index) => `import plugin${index} from '${plugin}';`).join('\n'); |
||||
.map((plugin, index) => `import plugin${index} from '${plugin}';`) |
|
||||
.join('\n'); |
|
||||
}) |
}) |
||||
.replace(new RegExp(INSERT_USE_PLUGINS_COMMENT), () => { |
.replace(new RegExp(INSERT_USE_PLUGINS_COMMENT), () => { |
||||
return plugins |
return plugins.map((_, index) => `logic.use(plugin${index});`).join('\n'); |
||||
.map((_, index) => `logic.use(plugin${index});`) |
|
||||
.join('\n'); |
|
||||
}); |
}); |
||||
await fs.outputFile(entryFilePath, modifiedContent); |
await fs.outputFile(entryFilePath, modifiedContent); |
||||
}; |
}; |
||||
|
|
||||
module.exports = setup; |
module.exports = setup; |
||||
|
@ -1,3 +1,3 @@ |
|||||
export const MIN_ZOOM = 0.5; |
export const MIN_ZOOM = 0.5; |
||||
export const MAX_ZOOM = 1.5; |
export const MAX_ZOOM = 1.5; |
||||
export const ZOOM_STEP = 0.1; |
export const ZOOM_STEP = 0.1; |
||||
|
@ -1,32 +1,32 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import {safeGet} from '../../../utils'; |
import { safeGet } from '../../../utils'; |
||||
import {BoldOutlined} from '@ant-design/icons'; |
import { BoldOutlined } from '@ant-design/icons'; |
||||
import shortcuts from '../../../common/shortcuts'; |
import shortcuts from '../../../common/shortcuts'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const Bold: React.FC<IProps> = makeBtnWidget({ |
const Bold: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '加粗', |
tooltip: '加粗', |
||||
handler: shortcuts['bold'].handler, |
handler: shortcuts.bold.handler, |
||||
getIcon() { |
getIcon() { |
||||
return <BoldOutlined/>; |
return <BoldOutlined />; |
||||
}, |
}, |
||||
disabled(flowChart: Graph) { |
disabled(flowChart: Graph) { |
||||
return flowChart.getSelectedCellCount() === 0; |
return flowChart.getSelectedCellCount() === 0; |
||||
}, |
}, |
||||
selected(flowChart: Graph) { |
selected(flowChart: Graph) { |
||||
const cells = flowChart.getSelectedCells(); |
const cells = flowChart.getSelectedCells(); |
||||
if(cells.length > 0) { |
if (cells.length > 0) { |
||||
return safeGet(cells, '0.attrs.label.fontWeight', 'normal') === 'bold'; |
return safeGet(cells, '0.attrs.label.fontWeight', 'normal') === 'bold'; |
||||
} else { |
} else { |
||||
return false; |
return false; |
||||
} |
} |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default Bold; |
export default Bold; |
||||
|
@ -1,25 +1,25 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import XIcon from '../../../components/xIcon'; |
import XIcon from '../../../components/xIcon'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
import {getSelectedNodes, hasNodeSelected} from '../../../utils/flowChartUtils'; |
import { getSelectedNodes, hasNodeSelected } from '../../../utils/flowChartUtils'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const BringToBack: React.FC<IProps> = makeBtnWidget({ |
const BringToBack: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '置于底层', |
tooltip: '置于底层', |
||||
getIcon() { |
getIcon() { |
||||
return <XIcon type={'icon-bringtobottom'}/>; |
return <XIcon type={'icon-bringtobottom'} />; |
||||
}, |
}, |
||||
handler(flowChart: Graph) { |
handler(flowChart: Graph) { |
||||
getSelectedNodes(flowChart).forEach(node => node.toBack()); |
getSelectedNodes(flowChart).forEach((node) => node.toBack()); |
||||
}, |
}, |
||||
disabled(flowChart: Graph) { |
disabled(flowChart: Graph) { |
||||
return !hasNodeSelected(flowChart); |
return !hasNodeSelected(flowChart); |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default BringToBack; |
export default BringToBack; |
||||
|
@ -1,26 +1,26 @@ |
|||||
//at.alicdn.com/t/font_2024452_s39le1337k9.js
|
// at.alicdn.com/t/font_2024452_s39le1337k9.js
|
||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import XIcon from '../../../components/xIcon'; |
import XIcon from '../../../components/xIcon'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
import {getSelectedNodes, hasNodeSelected} from '../../../utils/flowChartUtils'; |
import { getSelectedNodes, hasNodeSelected } from '../../../utils/flowChartUtils'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const BringToTop: React.FC<IProps> = makeBtnWidget({ |
const BringToTop: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '置于顶层', |
tooltip: '置于顶层', |
||||
getIcon() { |
getIcon() { |
||||
return <XIcon type={'icon-bringtotop'}/>; |
return <XIcon type={'icon-bringtotop'} />; |
||||
}, |
}, |
||||
handler(flowChart: Graph) { |
handler(flowChart: Graph) { |
||||
getSelectedNodes(flowChart).forEach(node => node.toFront()); |
getSelectedNodes(flowChart).forEach((node) => node.toFront()); |
||||
}, |
}, |
||||
disabled(flowChart: Graph) { |
disabled(flowChart: Graph) { |
||||
return !hasNodeSelected(flowChart); |
return !hasNodeSelected(flowChart); |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default BringToTop; |
export default BringToTop; |
||||
|
@ -1,21 +1,21 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
import {FullscreenExitOutlined} from '@ant-design/icons'; |
import { FullscreenExitOutlined } from '@ant-design/icons'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const FitWindow: React.FC<IProps> = makeBtnWidget({ |
const FitWindow: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '适配窗口', |
tooltip: '适配窗口', |
||||
getIcon() { |
getIcon() { |
||||
return <FullscreenExitOutlined/>; |
return <FullscreenExitOutlined />; |
||||
}, |
}, |
||||
handler(flowChart: Graph) { |
handler(flowChart: Graph) { |
||||
flowChart.zoomToFit({minScale: 0.5, maxScale: 1}); |
flowChart.zoomToFit({ minScale: 0.5, maxScale: 1 }); |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default FitWindow; |
export default FitWindow; |
||||
|
@ -1,32 +1,32 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import {safeGet} from '../../../utils'; |
import { safeGet } from '../../../utils'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
import {ItalicOutlined} from '@ant-design/icons'; |
import { ItalicOutlined } from '@ant-design/icons'; |
||||
import shortcuts from '../../../common/shortcuts'; |
import shortcuts from '../../../common/shortcuts'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const Italic: React.FC<IProps> = makeBtnWidget({ |
const Italic: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '斜体', |
tooltip: '斜体', |
||||
handler: shortcuts['italic'].handler, |
handler: shortcuts.italic.handler, |
||||
getIcon() { |
getIcon() { |
||||
return <ItalicOutlined/>; |
return <ItalicOutlined />; |
||||
}, |
}, |
||||
disabled(flowChart: Graph) { |
disabled(flowChart: Graph) { |
||||
return flowChart.getSelectedCellCount() === 0; |
return flowChart.getSelectedCellCount() === 0; |
||||
}, |
}, |
||||
selected(flowChart: Graph) { |
selected(flowChart: Graph) { |
||||
const cells = flowChart.getSelectedCells(); |
const cells = flowChart.getSelectedCells(); |
||||
if(cells.length > 0) { |
if (cells.length > 0) { |
||||
return safeGet(cells, '0.attrs.label.fontStyle', 'normal') === 'italic'; |
return safeGet(cells, '0.attrs.label.fontStyle', 'normal') === 'italic'; |
||||
} else { |
} else { |
||||
return false; |
return false; |
||||
} |
} |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default Italic; |
export default Italic; |
||||
|
@ -1,23 +1,23 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import {RedoOutlined} from '@ant-design/icons'; |
import { RedoOutlined } from '@ant-design/icons'; |
||||
import shortcuts from '../../../common/shortcuts'; |
import shortcuts from '../../../common/shortcuts'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const Save: React.FC<IProps> = makeBtnWidget({ |
const Save: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '重做', |
tooltip: '重做', |
||||
handler: shortcuts['redo'].handler, |
handler: shortcuts.redo.handler, |
||||
getIcon() { |
getIcon() { |
||||
return <RedoOutlined/>; |
return <RedoOutlined />; |
||||
}, |
}, |
||||
disabled(flowChart: Graph) { |
disabled(flowChart: Graph) { |
||||
return !flowChart.canRedo(); |
return !flowChart.canRedo(); |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default Save; |
export default Save; |
||||
|
@ -1,20 +1,20 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import {SaveOutlined} from '@ant-design/icons'; |
import { SaveOutlined } from '@ant-design/icons'; |
||||
import shortcuts from '../../../common/shortcuts'; |
import shortcuts from '../../../common/shortcuts'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const Save: React.FC<IProps> = makeBtnWidget({ |
const Save: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '保存', |
tooltip: '保存', |
||||
handler: shortcuts['save'].handler, |
handler: shortcuts.save.handler, |
||||
getIcon() { |
getIcon() { |
||||
return <SaveOutlined/>; |
return <SaveOutlined />; |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default Save; |
export default Save; |
||||
|
@ -1,32 +1,32 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import {safeGet} from '../../../utils'; |
import { safeGet } from '../../../utils'; |
||||
import shortcuts from '../../../common/shortcuts'; |
import shortcuts from '../../../common/shortcuts'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
import {UnderlineOutlined} from '@ant-design/icons'; |
import { UnderlineOutlined } from '@ant-design/icons'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const Underline: React.FC<IProps> = makeBtnWidget({ |
const Underline: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '下划线', |
tooltip: '下划线', |
||||
handler: shortcuts['underline'].handler, |
handler: shortcuts.underline.handler, |
||||
getIcon() { |
getIcon() { |
||||
return <UnderlineOutlined/>; |
return <UnderlineOutlined />; |
||||
}, |
}, |
||||
disabled(flowChart: Graph) { |
disabled(flowChart: Graph) { |
||||
return flowChart.getSelectedCellCount() === 0; |
return flowChart.getSelectedCellCount() === 0; |
||||
}, |
}, |
||||
selected(flowChart: Graph) { |
selected(flowChart: Graph) { |
||||
const cells = flowChart.getSelectedCells(); |
const cells = flowChart.getSelectedCells(); |
||||
if(cells.length > 0) { |
if (cells.length > 0) { |
||||
return safeGet(cells, '0.attrs.label.textDecoration', 'none') === 'underline'; |
return safeGet(cells, '0.attrs.label.textDecoration', 'none') === 'underline'; |
||||
} else { |
} else { |
||||
return false; |
return false; |
||||
} |
} |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default Underline; |
export default Underline; |
||||
|
@ -1,23 +1,23 @@ |
|||||
import React from 'react'; |
import React from 'react'; |
||||
|
|
||||
import {Graph} from '@antv/x6'; |
import { Graph } from '@antv/x6'; |
||||
import {UndoOutlined} from '@ant-design/icons'; |
import { UndoOutlined } from '@ant-design/icons'; |
||||
import shortcuts from '../../../common/shortcuts'; |
import shortcuts from '../../../common/shortcuts'; |
||||
import makeBtnWidget from './common/makeBtnWidget'; |
import makeBtnWidget from './common/makeBtnWidget'; |
||||
|
|
||||
interface IProps { |
interface IProps { |
||||
flowChart: Graph |
flowChart: Graph; |
||||
} |
} |
||||
|
|
||||
const Save: React.FC<IProps> = makeBtnWidget({ |
const Save: React.FC<IProps> = makeBtnWidget({ |
||||
tooltip: '撤销', |
tooltip: '撤销', |
||||
handler: shortcuts['undo'].handler, |
handler: shortcuts.undo.handler, |
||||
getIcon() { |
getIcon() { |
||||
return <UndoOutlined/>; |
return <UndoOutlined />; |
||||
}, |
}, |
||||
disabled(flowChart: Graph) { |
disabled(flowChart: Graph) { |
||||
return !flowChart.canUndo(); |
return !flowChart.canUndo(); |
||||
} |
}, |
||||
}); |
}); |
||||
|
|
||||
export default Save; |
export default Save; |
||||
|
@ -1,9 +1,9 @@ |
|||||
declare module '*.module.css' { |
declare module '*.module.css' { |
||||
const classes: {[key: string]: string}; |
const classes: { [key: string]: string }; |
||||
export default classes; |
export default classes; |
||||
} |
} |
||||
|
|
||||
declare module '*.less' { |
declare module '*.less' { |
||||
const classes: {[key: string]: string}; |
const classes: { [key: string]: string }; |
||||
export default classes; |
export default classes; |
||||
} |
} |
||||
|
Loading…
Reference in new issue