From 1f4480f1c977413e78d9a832eff120ccce9fc1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Wed, 22 May 2019 20:19:42 +0800 Subject: [PATCH] use ts --- .../common/IconFont/{index.js => index.ts} | 0 ...FlowContextMenu.js => FlowContextMenu.tsx} | 0 ...KoniContextMenu.js => KoniContextMenu.tsx} | 0 .../components/EditorContextMenu/MenuItem.tsx | 12 +++++-- ...MindContextMenu.js => MindContextMenu.tsx} | 0 .../EditorContextMenu/{index.js => index.tsx} | 0 .../{DetailForm.js => DetailForm.tsx} | 17 +++++++--- ...FlowDetailPanel.js => FlowDetailPanel.tsx} | 0 ...KoniDetailPanel.js => KoniDetailPanel.tsx} | 0 ...MindDetailPanel.js => MindDetailPanel.tsx} | 0 .../EditorDetailPanel/{index.js => index.tsx} | 0 .../{FlowItemPanel.js => FlowItemPanel.tsx} | 0 .../{KoniItemPanel.js => KoniItemPanel.tsx} | 0 .../EditorItemPanel/{index.js => index.tsx} | 0 .../EditorMinimap/{index.js => index.tsx} | 0 .../{FlowToolbar.js => FlowToolbar.tsx} | 0 .../{KoniToolbar.js => KoniToolbar.tsx} | 0 .../{MindToolbar.js => MindToolbar.tsx} | 0 .../EditorToolbar/ToolbarButton.tsx | 12 +++++-- .../EditorToolbar/{index.js => index.tsx} | 0 .../common/IconFont/{index.js => index.ts} | 0 ...FlowContextMenu.js => FlowContextMenu.tsx} | 0 ...KoniContextMenu.js => KoniContextMenu.tsx} | 0 .../components/EditorContextMenu/MenuItem.tsx | 12 +++++-- ...MindContextMenu.js => MindContextMenu.tsx} | 0 .../EditorContextMenu/{index.js => index.tsx} | 0 .../{DetailForm.js => DetailForm.tsx} | 17 +++++++--- ...FlowDetailPanel.js => FlowDetailPanel.tsx} | 0 ...KoniDetailPanel.js => KoniDetailPanel.tsx} | 0 ...MindDetailPanel.js => MindDetailPanel.tsx} | 0 .../EditorDetailPanel/{index.js => index.tsx} | 0 .../{FlowItemPanel.js => FlowItemPanel.tsx} | 0 .../{KoniItemPanel.js => KoniItemPanel.tsx} | 0 .../EditorItemPanel/{index.js => index.tsx} | 0 .../EditorMinimap/{index.js => index.tsx} | 0 .../{FlowToolbar.js => FlowToolbar.tsx} | 0 .../{KoniToolbar.js => KoniToolbar.tsx} | 0 .../{MindToolbar.js => MindToolbar.tsx} | 0 .../{ToolbarButton.js => ToolbarButton.tsx} | 12 +++++-- .../EditorToolbar/{index.js => index.tsx} | 0 .../components/PageHeaderWrapper/index.tsx | 3 +- .../components/shape/nodes/KoniCustomNode.js | 33 ------------------- EditorKoni/src/index.tsx | 2 -- .../common/IconFont/{index.js => index.ts} | 0 ...FlowContextMenu.js => FlowContextMenu.tsx} | 0 ...KoniContextMenu.js => KoniContextMenu.tsx} | 0 .../components/EditorContextMenu/MenuItem.tsx | 12 +++++-- ...MindContextMenu.js => MindContextMenu.tsx} | 0 .../EditorContextMenu/{index.js => index.tsx} | 0 .../{DetailForm.js => DetailForm.tsx} | 17 +++++++--- ...FlowDetailPanel.js => FlowDetailPanel.tsx} | 0 ...KoniDetailPanel.js => KoniDetailPanel.tsx} | 0 ...MindDetailPanel.js => MindDetailPanel.tsx} | 0 .../EditorDetailPanel/{index.js => index.tsx} | 0 .../{FlowItemPanel.js => FlowItemPanel.tsx} | 0 .../{KoniItemPanel.js => KoniItemPanel.tsx} | 0 .../EditorItemPanel/{index.js => index.tsx} | 0 .../EditorMinimap/{index.js => index.tsx} | 0 .../{FlowToolbar.js => FlowToolbar.tsx} | 0 .../{KoniToolbar.js => KoniToolbar.tsx} | 0 .../{MindToolbar.js => MindToolbar.tsx} | 0 .../EditorToolbar/ToolbarButton.tsx | 12 +++++-- .../EditorToolbar/{index.js => index.tsx} | 0 .../components/PageHeaderWrapper/index.tsx | 3 +- 64 files changed, 101 insertions(+), 63 deletions(-) rename EditorFlow/src/common/IconFont/{index.js => index.ts} (100%) rename EditorFlow/src/components/EditorContextMenu/{FlowContextMenu.js => FlowContextMenu.tsx} (100%) rename EditorFlow/src/components/EditorContextMenu/{KoniContextMenu.js => KoniContextMenu.tsx} (100%) rename EditorKoni/src/components/EditorContextMenu/MenuItem.js => EditorFlow/src/components/EditorContextMenu/MenuItem.tsx (62%) rename EditorFlow/src/components/EditorContextMenu/{MindContextMenu.js => MindContextMenu.tsx} (100%) rename EditorFlow/src/components/EditorContextMenu/{index.js => index.tsx} (100%) rename EditorFlow/src/components/EditorDetailPanel/{DetailForm.js => DetailForm.tsx} (86%) rename EditorFlow/src/components/EditorDetailPanel/{FlowDetailPanel.js => FlowDetailPanel.tsx} (100%) rename EditorFlow/src/components/EditorDetailPanel/{KoniDetailPanel.js => KoniDetailPanel.tsx} (100%) rename EditorFlow/src/components/EditorDetailPanel/{MindDetailPanel.js => MindDetailPanel.tsx} (100%) rename EditorFlow/src/components/EditorDetailPanel/{index.js => index.tsx} (100%) rename EditorFlow/src/components/EditorItemPanel/{FlowItemPanel.js => FlowItemPanel.tsx} (100%) rename EditorFlow/src/components/EditorItemPanel/{KoniItemPanel.js => KoniItemPanel.tsx} (100%) rename EditorFlow/src/components/EditorItemPanel/{index.js => index.tsx} (100%) rename EditorFlow/src/components/EditorMinimap/{index.js => index.tsx} (100%) rename EditorFlow/src/components/EditorToolbar/{FlowToolbar.js => FlowToolbar.tsx} (100%) rename EditorFlow/src/components/EditorToolbar/{KoniToolbar.js => KoniToolbar.tsx} (100%) rename EditorFlow/src/components/EditorToolbar/{MindToolbar.js => MindToolbar.tsx} (100%) rename EditorMind/src/components/EditorToolbar/ToolbarButton.js => EditorFlow/src/components/EditorToolbar/ToolbarButton.tsx (65%) rename EditorFlow/src/components/EditorToolbar/{index.js => index.tsx} (100%) rename EditorKoni/src/common/IconFont/{index.js => index.ts} (100%) rename EditorKoni/src/components/EditorContextMenu/{FlowContextMenu.js => FlowContextMenu.tsx} (100%) rename EditorKoni/src/components/EditorContextMenu/{KoniContextMenu.js => KoniContextMenu.tsx} (100%) rename EditorMind/src/components/EditorContextMenu/MenuItem.js => EditorKoni/src/components/EditorContextMenu/MenuItem.tsx (62%) rename EditorKoni/src/components/EditorContextMenu/{MindContextMenu.js => MindContextMenu.tsx} (100%) rename EditorKoni/src/components/EditorContextMenu/{index.js => index.tsx} (100%) rename EditorKoni/src/components/EditorDetailPanel/{DetailForm.js => DetailForm.tsx} (86%) rename EditorKoni/src/components/EditorDetailPanel/{FlowDetailPanel.js => FlowDetailPanel.tsx} (100%) rename EditorKoni/src/components/EditorDetailPanel/{KoniDetailPanel.js => KoniDetailPanel.tsx} (100%) rename EditorKoni/src/components/EditorDetailPanel/{MindDetailPanel.js => MindDetailPanel.tsx} (100%) rename EditorKoni/src/components/EditorDetailPanel/{index.js => index.tsx} (100%) rename EditorKoni/src/components/EditorItemPanel/{FlowItemPanel.js => FlowItemPanel.tsx} (100%) rename EditorKoni/src/components/EditorItemPanel/{KoniItemPanel.js => KoniItemPanel.tsx} (100%) rename EditorKoni/src/components/EditorItemPanel/{index.js => index.tsx} (100%) rename EditorKoni/src/components/EditorMinimap/{index.js => index.tsx} (100%) rename EditorKoni/src/components/EditorToolbar/{FlowToolbar.js => FlowToolbar.tsx} (100%) rename EditorKoni/src/components/EditorToolbar/{KoniToolbar.js => KoniToolbar.tsx} (100%) rename EditorKoni/src/components/EditorToolbar/{MindToolbar.js => MindToolbar.tsx} (100%) rename EditorKoni/src/components/EditorToolbar/{ToolbarButton.js => ToolbarButton.tsx} (65%) rename EditorKoni/src/components/EditorToolbar/{index.js => index.tsx} (100%) delete mode 100644 EditorKoni/src/components/shape/nodes/KoniCustomNode.js rename EditorMind/src/common/IconFont/{index.js => index.ts} (100%) rename EditorMind/src/components/EditorContextMenu/{FlowContextMenu.js => FlowContextMenu.tsx} (100%) rename EditorMind/src/components/EditorContextMenu/{KoniContextMenu.js => KoniContextMenu.tsx} (100%) rename EditorFlow/src/components/EditorContextMenu/MenuItem.js => EditorMind/src/components/EditorContextMenu/MenuItem.tsx (62%) rename EditorMind/src/components/EditorContextMenu/{MindContextMenu.js => MindContextMenu.tsx} (100%) rename EditorMind/src/components/EditorContextMenu/{index.js => index.tsx} (100%) rename EditorMind/src/components/EditorDetailPanel/{DetailForm.js => DetailForm.tsx} (86%) rename EditorMind/src/components/EditorDetailPanel/{FlowDetailPanel.js => FlowDetailPanel.tsx} (100%) rename EditorMind/src/components/EditorDetailPanel/{KoniDetailPanel.js => KoniDetailPanel.tsx} (100%) rename EditorMind/src/components/EditorDetailPanel/{MindDetailPanel.js => MindDetailPanel.tsx} (100%) rename EditorMind/src/components/EditorDetailPanel/{index.js => index.tsx} (100%) rename EditorMind/src/components/EditorItemPanel/{FlowItemPanel.js => FlowItemPanel.tsx} (100%) rename EditorMind/src/components/EditorItemPanel/{KoniItemPanel.js => KoniItemPanel.tsx} (100%) rename EditorMind/src/components/EditorItemPanel/{index.js => index.tsx} (100%) rename EditorMind/src/components/EditorMinimap/{index.js => index.tsx} (100%) rename EditorMind/src/components/EditorToolbar/{FlowToolbar.js => FlowToolbar.tsx} (100%) rename EditorMind/src/components/EditorToolbar/{KoniToolbar.js => KoniToolbar.tsx} (100%) rename EditorMind/src/components/EditorToolbar/{MindToolbar.js => MindToolbar.tsx} (100%) rename EditorFlow/src/components/EditorToolbar/ToolbarButton.js => EditorMind/src/components/EditorToolbar/ToolbarButton.tsx (65%) rename EditorMind/src/components/EditorToolbar/{index.js => index.tsx} (100%) diff --git a/EditorFlow/src/common/IconFont/index.js b/EditorFlow/src/common/IconFont/index.ts similarity index 100% rename from EditorFlow/src/common/IconFont/index.js rename to EditorFlow/src/common/IconFont/index.ts diff --git a/EditorFlow/src/components/EditorContextMenu/FlowContextMenu.js b/EditorFlow/src/components/EditorContextMenu/FlowContextMenu.tsx similarity index 100% rename from EditorFlow/src/components/EditorContextMenu/FlowContextMenu.js rename to EditorFlow/src/components/EditorContextMenu/FlowContextMenu.tsx diff --git a/EditorFlow/src/components/EditorContextMenu/KoniContextMenu.js b/EditorFlow/src/components/EditorContextMenu/KoniContextMenu.tsx similarity index 100% rename from EditorFlow/src/components/EditorContextMenu/KoniContextMenu.js rename to EditorFlow/src/components/EditorContextMenu/KoniContextMenu.tsx diff --git a/EditorKoni/src/components/EditorContextMenu/MenuItem.js b/EditorFlow/src/components/EditorContextMenu/MenuItem.tsx similarity index 62% rename from EditorKoni/src/components/EditorContextMenu/MenuItem.js rename to EditorFlow/src/components/EditorContextMenu/MenuItem.tsx index 4cbde89e..afbefe31 100644 --- a/EditorKoni/src/components/EditorContextMenu/MenuItem.js +++ b/EditorFlow/src/components/EditorContextMenu/MenuItem.tsx @@ -1,10 +1,18 @@ import React from 'react'; import { Command } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; import IconFont from '../../common/IconFont'; import styles from './index.less'; -const MenuItem = props => { +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; + +interface MenuItemProps { + command: string; + icon?: string; + text?: string; +} +const MenuItem: React.SFC = props => { const { command, icon, text } = props; return ( diff --git a/EditorFlow/src/components/EditorContextMenu/MindContextMenu.js b/EditorFlow/src/components/EditorContextMenu/MindContextMenu.tsx similarity index 100% rename from EditorFlow/src/components/EditorContextMenu/MindContextMenu.js rename to EditorFlow/src/components/EditorContextMenu/MindContextMenu.tsx diff --git a/EditorFlow/src/components/EditorContextMenu/index.js b/EditorFlow/src/components/EditorContextMenu/index.tsx similarity index 100% rename from EditorFlow/src/components/EditorContextMenu/index.js rename to EditorFlow/src/components/EditorContextMenu/index.tsx diff --git a/EditorFlow/src/components/EditorDetailPanel/DetailForm.js b/EditorFlow/src/components/EditorDetailPanel/DetailForm.tsx similarity index 86% rename from EditorFlow/src/components/EditorDetailPanel/DetailForm.js rename to EditorFlow/src/components/EditorDetailPanel/DetailForm.tsx index 3d680115..4d442af4 100644 --- a/EditorFlow/src/components/EditorDetailPanel/DetailForm.js +++ b/EditorFlow/src/components/EditorDetailPanel/DetailForm.tsx @@ -1,7 +1,11 @@ import React, { Fragment } from 'react'; import { Card, Form, Input, Select } from 'antd'; import { withPropsAPI } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; +import { FormComponentProps } from 'antd/lib/form'; + +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; const { Item } = Form; const { Option } = Select; @@ -15,14 +19,19 @@ const inlineFormItemLayout = { }, }; -class DetailForm extends React.Component { +interface DetailFormProps extends FormComponentProps { + type: string; + propsAPI?: any; +} + +class DetailForm extends React.Component { get item() { const { propsAPI } = this.props; return propsAPI.getSelected()[0]; } - handleSubmit = e => { + handleSubmit = (e: React.FormEvent) => { if (e && e.preventDefault) { e.preventDefault(); } @@ -126,4 +135,4 @@ class DetailForm extends React.Component { } } -export default Form.create()(withPropsAPI(DetailForm)); +export default Form.create()(withPropsAPI(DetailForm as any)); diff --git a/EditorFlow/src/components/EditorDetailPanel/FlowDetailPanel.js b/EditorFlow/src/components/EditorDetailPanel/FlowDetailPanel.tsx similarity index 100% rename from EditorFlow/src/components/EditorDetailPanel/FlowDetailPanel.js rename to EditorFlow/src/components/EditorDetailPanel/FlowDetailPanel.tsx diff --git a/EditorFlow/src/components/EditorDetailPanel/KoniDetailPanel.js b/EditorFlow/src/components/EditorDetailPanel/KoniDetailPanel.tsx similarity index 100% rename from EditorFlow/src/components/EditorDetailPanel/KoniDetailPanel.js rename to EditorFlow/src/components/EditorDetailPanel/KoniDetailPanel.tsx diff --git a/EditorFlow/src/components/EditorDetailPanel/MindDetailPanel.js b/EditorFlow/src/components/EditorDetailPanel/MindDetailPanel.tsx similarity index 100% rename from EditorFlow/src/components/EditorDetailPanel/MindDetailPanel.js rename to EditorFlow/src/components/EditorDetailPanel/MindDetailPanel.tsx diff --git a/EditorFlow/src/components/EditorDetailPanel/index.js b/EditorFlow/src/components/EditorDetailPanel/index.tsx similarity index 100% rename from EditorFlow/src/components/EditorDetailPanel/index.js rename to EditorFlow/src/components/EditorDetailPanel/index.tsx diff --git a/EditorFlow/src/components/EditorItemPanel/FlowItemPanel.js b/EditorFlow/src/components/EditorItemPanel/FlowItemPanel.tsx similarity index 100% rename from EditorFlow/src/components/EditorItemPanel/FlowItemPanel.js rename to EditorFlow/src/components/EditorItemPanel/FlowItemPanel.tsx diff --git a/EditorFlow/src/components/EditorItemPanel/KoniItemPanel.js b/EditorFlow/src/components/EditorItemPanel/KoniItemPanel.tsx similarity index 100% rename from EditorFlow/src/components/EditorItemPanel/KoniItemPanel.js rename to EditorFlow/src/components/EditorItemPanel/KoniItemPanel.tsx diff --git a/EditorFlow/src/components/EditorItemPanel/index.js b/EditorFlow/src/components/EditorItemPanel/index.tsx similarity index 100% rename from EditorFlow/src/components/EditorItemPanel/index.js rename to EditorFlow/src/components/EditorItemPanel/index.tsx diff --git a/EditorFlow/src/components/EditorMinimap/index.js b/EditorFlow/src/components/EditorMinimap/index.tsx similarity index 100% rename from EditorFlow/src/components/EditorMinimap/index.js rename to EditorFlow/src/components/EditorMinimap/index.tsx diff --git a/EditorFlow/src/components/EditorToolbar/FlowToolbar.js b/EditorFlow/src/components/EditorToolbar/FlowToolbar.tsx similarity index 100% rename from EditorFlow/src/components/EditorToolbar/FlowToolbar.js rename to EditorFlow/src/components/EditorToolbar/FlowToolbar.tsx diff --git a/EditorFlow/src/components/EditorToolbar/KoniToolbar.js b/EditorFlow/src/components/EditorToolbar/KoniToolbar.tsx similarity index 100% rename from EditorFlow/src/components/EditorToolbar/KoniToolbar.js rename to EditorFlow/src/components/EditorToolbar/KoniToolbar.tsx diff --git a/EditorFlow/src/components/EditorToolbar/MindToolbar.js b/EditorFlow/src/components/EditorToolbar/MindToolbar.tsx similarity index 100% rename from EditorFlow/src/components/EditorToolbar/MindToolbar.js rename to EditorFlow/src/components/EditorToolbar/MindToolbar.tsx diff --git a/EditorMind/src/components/EditorToolbar/ToolbarButton.js b/EditorFlow/src/components/EditorToolbar/ToolbarButton.tsx similarity index 65% rename from EditorMind/src/components/EditorToolbar/ToolbarButton.js rename to EditorFlow/src/components/EditorToolbar/ToolbarButton.tsx index eb5b4ffa..30958f0e 100644 --- a/EditorMind/src/components/EditorToolbar/ToolbarButton.js +++ b/EditorFlow/src/components/EditorToolbar/ToolbarButton.tsx @@ -1,11 +1,19 @@ import React from 'react'; import { Tooltip } from 'antd'; import { Command } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; import IconFont from '../../common/IconFont'; import styles from './index.less'; -const ToolbarButton = props => { +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; + +interface ToolbarButtonProps { + command: string; + icon?: string; + text?: string; +} +const ToolbarButton: React.SFC = props => { const { command, icon, text } = props; return ( diff --git a/EditorFlow/src/components/EditorToolbar/index.js b/EditorFlow/src/components/EditorToolbar/index.tsx similarity index 100% rename from EditorFlow/src/components/EditorToolbar/index.js rename to EditorFlow/src/components/EditorToolbar/index.tsx diff --git a/EditorKoni/src/common/IconFont/index.js b/EditorKoni/src/common/IconFont/index.ts similarity index 100% rename from EditorKoni/src/common/IconFont/index.js rename to EditorKoni/src/common/IconFont/index.ts diff --git a/EditorKoni/src/components/EditorContextMenu/FlowContextMenu.js b/EditorKoni/src/components/EditorContextMenu/FlowContextMenu.tsx similarity index 100% rename from EditorKoni/src/components/EditorContextMenu/FlowContextMenu.js rename to EditorKoni/src/components/EditorContextMenu/FlowContextMenu.tsx diff --git a/EditorKoni/src/components/EditorContextMenu/KoniContextMenu.js b/EditorKoni/src/components/EditorContextMenu/KoniContextMenu.tsx similarity index 100% rename from EditorKoni/src/components/EditorContextMenu/KoniContextMenu.js rename to EditorKoni/src/components/EditorContextMenu/KoniContextMenu.tsx diff --git a/EditorMind/src/components/EditorContextMenu/MenuItem.js b/EditorKoni/src/components/EditorContextMenu/MenuItem.tsx similarity index 62% rename from EditorMind/src/components/EditorContextMenu/MenuItem.js rename to EditorKoni/src/components/EditorContextMenu/MenuItem.tsx index 4cbde89e..afbefe31 100644 --- a/EditorMind/src/components/EditorContextMenu/MenuItem.js +++ b/EditorKoni/src/components/EditorContextMenu/MenuItem.tsx @@ -1,10 +1,18 @@ import React from 'react'; import { Command } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; import IconFont from '../../common/IconFont'; import styles from './index.less'; -const MenuItem = props => { +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; + +interface MenuItemProps { + command: string; + icon?: string; + text?: string; +} +const MenuItem: React.SFC = props => { const { command, icon, text } = props; return ( diff --git a/EditorKoni/src/components/EditorContextMenu/MindContextMenu.js b/EditorKoni/src/components/EditorContextMenu/MindContextMenu.tsx similarity index 100% rename from EditorKoni/src/components/EditorContextMenu/MindContextMenu.js rename to EditorKoni/src/components/EditorContextMenu/MindContextMenu.tsx diff --git a/EditorKoni/src/components/EditorContextMenu/index.js b/EditorKoni/src/components/EditorContextMenu/index.tsx similarity index 100% rename from EditorKoni/src/components/EditorContextMenu/index.js rename to EditorKoni/src/components/EditorContextMenu/index.tsx diff --git a/EditorKoni/src/components/EditorDetailPanel/DetailForm.js b/EditorKoni/src/components/EditorDetailPanel/DetailForm.tsx similarity index 86% rename from EditorKoni/src/components/EditorDetailPanel/DetailForm.js rename to EditorKoni/src/components/EditorDetailPanel/DetailForm.tsx index 3d680115..4d442af4 100644 --- a/EditorKoni/src/components/EditorDetailPanel/DetailForm.js +++ b/EditorKoni/src/components/EditorDetailPanel/DetailForm.tsx @@ -1,7 +1,11 @@ import React, { Fragment } from 'react'; import { Card, Form, Input, Select } from 'antd'; import { withPropsAPI } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; +import { FormComponentProps } from 'antd/lib/form'; + +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; const { Item } = Form; const { Option } = Select; @@ -15,14 +19,19 @@ const inlineFormItemLayout = { }, }; -class DetailForm extends React.Component { +interface DetailFormProps extends FormComponentProps { + type: string; + propsAPI?: any; +} + +class DetailForm extends React.Component { get item() { const { propsAPI } = this.props; return propsAPI.getSelected()[0]; } - handleSubmit = e => { + handleSubmit = (e: React.FormEvent) => { if (e && e.preventDefault) { e.preventDefault(); } @@ -126,4 +135,4 @@ class DetailForm extends React.Component { } } -export default Form.create()(withPropsAPI(DetailForm)); +export default Form.create()(withPropsAPI(DetailForm as any)); diff --git a/EditorKoni/src/components/EditorDetailPanel/FlowDetailPanel.js b/EditorKoni/src/components/EditorDetailPanel/FlowDetailPanel.tsx similarity index 100% rename from EditorKoni/src/components/EditorDetailPanel/FlowDetailPanel.js rename to EditorKoni/src/components/EditorDetailPanel/FlowDetailPanel.tsx diff --git a/EditorKoni/src/components/EditorDetailPanel/KoniDetailPanel.js b/EditorKoni/src/components/EditorDetailPanel/KoniDetailPanel.tsx similarity index 100% rename from EditorKoni/src/components/EditorDetailPanel/KoniDetailPanel.js rename to EditorKoni/src/components/EditorDetailPanel/KoniDetailPanel.tsx diff --git a/EditorKoni/src/components/EditorDetailPanel/MindDetailPanel.js b/EditorKoni/src/components/EditorDetailPanel/MindDetailPanel.tsx similarity index 100% rename from EditorKoni/src/components/EditorDetailPanel/MindDetailPanel.js rename to EditorKoni/src/components/EditorDetailPanel/MindDetailPanel.tsx diff --git a/EditorKoni/src/components/EditorDetailPanel/index.js b/EditorKoni/src/components/EditorDetailPanel/index.tsx similarity index 100% rename from EditorKoni/src/components/EditorDetailPanel/index.js rename to EditorKoni/src/components/EditorDetailPanel/index.tsx diff --git a/EditorKoni/src/components/EditorItemPanel/FlowItemPanel.js b/EditorKoni/src/components/EditorItemPanel/FlowItemPanel.tsx similarity index 100% rename from EditorKoni/src/components/EditorItemPanel/FlowItemPanel.js rename to EditorKoni/src/components/EditorItemPanel/FlowItemPanel.tsx diff --git a/EditorKoni/src/components/EditorItemPanel/KoniItemPanel.js b/EditorKoni/src/components/EditorItemPanel/KoniItemPanel.tsx similarity index 100% rename from EditorKoni/src/components/EditorItemPanel/KoniItemPanel.js rename to EditorKoni/src/components/EditorItemPanel/KoniItemPanel.tsx diff --git a/EditorKoni/src/components/EditorItemPanel/index.js b/EditorKoni/src/components/EditorItemPanel/index.tsx similarity index 100% rename from EditorKoni/src/components/EditorItemPanel/index.js rename to EditorKoni/src/components/EditorItemPanel/index.tsx diff --git a/EditorKoni/src/components/EditorMinimap/index.js b/EditorKoni/src/components/EditorMinimap/index.tsx similarity index 100% rename from EditorKoni/src/components/EditorMinimap/index.js rename to EditorKoni/src/components/EditorMinimap/index.tsx diff --git a/EditorKoni/src/components/EditorToolbar/FlowToolbar.js b/EditorKoni/src/components/EditorToolbar/FlowToolbar.tsx similarity index 100% rename from EditorKoni/src/components/EditorToolbar/FlowToolbar.js rename to EditorKoni/src/components/EditorToolbar/FlowToolbar.tsx diff --git a/EditorKoni/src/components/EditorToolbar/KoniToolbar.js b/EditorKoni/src/components/EditorToolbar/KoniToolbar.tsx similarity index 100% rename from EditorKoni/src/components/EditorToolbar/KoniToolbar.js rename to EditorKoni/src/components/EditorToolbar/KoniToolbar.tsx diff --git a/EditorKoni/src/components/EditorToolbar/MindToolbar.js b/EditorKoni/src/components/EditorToolbar/MindToolbar.tsx similarity index 100% rename from EditorKoni/src/components/EditorToolbar/MindToolbar.js rename to EditorKoni/src/components/EditorToolbar/MindToolbar.tsx diff --git a/EditorKoni/src/components/EditorToolbar/ToolbarButton.js b/EditorKoni/src/components/EditorToolbar/ToolbarButton.tsx similarity index 65% rename from EditorKoni/src/components/EditorToolbar/ToolbarButton.js rename to EditorKoni/src/components/EditorToolbar/ToolbarButton.tsx index eb5b4ffa..30958f0e 100644 --- a/EditorKoni/src/components/EditorToolbar/ToolbarButton.js +++ b/EditorKoni/src/components/EditorToolbar/ToolbarButton.tsx @@ -1,11 +1,19 @@ import React from 'react'; import { Tooltip } from 'antd'; import { Command } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; import IconFont from '../../common/IconFont'; import styles from './index.less'; -const ToolbarButton = props => { +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; + +interface ToolbarButtonProps { + command: string; + icon?: string; + text?: string; +} +const ToolbarButton: React.SFC = props => { const { command, icon, text } = props; return ( diff --git a/EditorKoni/src/components/EditorToolbar/index.js b/EditorKoni/src/components/EditorToolbar/index.tsx similarity index 100% rename from EditorKoni/src/components/EditorToolbar/index.js rename to EditorKoni/src/components/EditorToolbar/index.tsx diff --git a/EditorKoni/src/components/PageHeaderWrapper/index.tsx b/EditorKoni/src/components/PageHeaderWrapper/index.tsx index bb565a04..18525c4b 100644 --- a/EditorKoni/src/components/PageHeaderWrapper/index.tsx +++ b/EditorKoni/src/components/PageHeaderWrapper/index.tsx @@ -1,8 +1,7 @@ import React from 'react'; -import { RouteContext } from '@ant-design/pro-layout'; +import { RouteContext, GridContent } from '@ant-design/pro-layout'; import { PageHeader, Tabs, Typography } from 'antd'; import styles from './index.less'; -import { GridContent } from '@ant-design/pro-layout'; import { TabsProps } from 'antd/lib/tabs'; interface IPageHeaderTabConfig { tabList?: Array<{ diff --git a/EditorKoni/src/components/shape/nodes/KoniCustomNode.js b/EditorKoni/src/components/shape/nodes/KoniCustomNode.js deleted file mode 100644 index 4c13bb4f..00000000 --- a/EditorKoni/src/components/shape/nodes/KoniCustomNode.js +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import { RegisterNode } from 'gg-editor'; - -class KoniCustomNode extends React.Component { - render() { - const config = { - draw(item) { - const keyShape = this.drawKeyShape(item); - - // draw label - this.drawLabel(item); - - // draw image - const group = item.getGraphicGroup(); - const model = item.getModel(); - - group.addShape('image', { - attrs: { - x: -7, - y: -7, - img: model.icon, - }, - }); - - return keyShape; - }, - }; - - return ; - } -} - -export default KoniCustomNode; diff --git a/EditorKoni/src/index.tsx b/EditorKoni/src/index.tsx index f2ee717c..e8e1f77d 100644 --- a/EditorKoni/src/index.tsx +++ b/EditorKoni/src/index.tsx @@ -6,7 +6,6 @@ import { KoniContextMenu } from './components/EditorContextMenu'; import { KoniToolbar } from './components/EditorToolbar'; import { KoniItemPanel } from './components/EditorItemPanel'; import { KoniDetailPanel } from './components/EditorDetailPanel'; -import KoniCustomNode from './components/shape/nodes/KoniCustomNode'; import styles from './index.less'; import PageHeaderWrapper from './components/PageHeaderWrapper'; @@ -36,7 +35,6 @@ export default () => { - diff --git a/EditorMind/src/common/IconFont/index.js b/EditorMind/src/common/IconFont/index.ts similarity index 100% rename from EditorMind/src/common/IconFont/index.js rename to EditorMind/src/common/IconFont/index.ts diff --git a/EditorMind/src/components/EditorContextMenu/FlowContextMenu.js b/EditorMind/src/components/EditorContextMenu/FlowContextMenu.tsx similarity index 100% rename from EditorMind/src/components/EditorContextMenu/FlowContextMenu.js rename to EditorMind/src/components/EditorContextMenu/FlowContextMenu.tsx diff --git a/EditorMind/src/components/EditorContextMenu/KoniContextMenu.js b/EditorMind/src/components/EditorContextMenu/KoniContextMenu.tsx similarity index 100% rename from EditorMind/src/components/EditorContextMenu/KoniContextMenu.js rename to EditorMind/src/components/EditorContextMenu/KoniContextMenu.tsx diff --git a/EditorFlow/src/components/EditorContextMenu/MenuItem.js b/EditorMind/src/components/EditorContextMenu/MenuItem.tsx similarity index 62% rename from EditorFlow/src/components/EditorContextMenu/MenuItem.js rename to EditorMind/src/components/EditorContextMenu/MenuItem.tsx index 4cbde89e..afbefe31 100644 --- a/EditorFlow/src/components/EditorContextMenu/MenuItem.js +++ b/EditorMind/src/components/EditorContextMenu/MenuItem.tsx @@ -1,10 +1,18 @@ import React from 'react'; import { Command } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; import IconFont from '../../common/IconFont'; import styles from './index.less'; -const MenuItem = props => { +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; + +interface MenuItemProps { + command: string; + icon?: string; + text?: string; +} +const MenuItem: React.SFC = props => { const { command, icon, text } = props; return ( diff --git a/EditorMind/src/components/EditorContextMenu/MindContextMenu.js b/EditorMind/src/components/EditorContextMenu/MindContextMenu.tsx similarity index 100% rename from EditorMind/src/components/EditorContextMenu/MindContextMenu.js rename to EditorMind/src/components/EditorContextMenu/MindContextMenu.tsx diff --git a/EditorMind/src/components/EditorContextMenu/index.js b/EditorMind/src/components/EditorContextMenu/index.tsx similarity index 100% rename from EditorMind/src/components/EditorContextMenu/index.js rename to EditorMind/src/components/EditorContextMenu/index.tsx diff --git a/EditorMind/src/components/EditorDetailPanel/DetailForm.js b/EditorMind/src/components/EditorDetailPanel/DetailForm.tsx similarity index 86% rename from EditorMind/src/components/EditorDetailPanel/DetailForm.js rename to EditorMind/src/components/EditorDetailPanel/DetailForm.tsx index 3d680115..4d442af4 100644 --- a/EditorMind/src/components/EditorDetailPanel/DetailForm.js +++ b/EditorMind/src/components/EditorDetailPanel/DetailForm.tsx @@ -1,7 +1,11 @@ import React, { Fragment } from 'react'; import { Card, Form, Input, Select } from 'antd'; import { withPropsAPI } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; +import { FormComponentProps } from 'antd/lib/form'; + +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; const { Item } = Form; const { Option } = Select; @@ -15,14 +19,19 @@ const inlineFormItemLayout = { }, }; -class DetailForm extends React.Component { +interface DetailFormProps extends FormComponentProps { + type: string; + propsAPI?: any; +} + +class DetailForm extends React.Component { get item() { const { propsAPI } = this.props; return propsAPI.getSelected()[0]; } - handleSubmit = e => { + handleSubmit = (e: React.FormEvent) => { if (e && e.preventDefault) { e.preventDefault(); } @@ -126,4 +135,4 @@ class DetailForm extends React.Component { } } -export default Form.create()(withPropsAPI(DetailForm)); +export default Form.create()(withPropsAPI(DetailForm as any)); diff --git a/EditorMind/src/components/EditorDetailPanel/FlowDetailPanel.js b/EditorMind/src/components/EditorDetailPanel/FlowDetailPanel.tsx similarity index 100% rename from EditorMind/src/components/EditorDetailPanel/FlowDetailPanel.js rename to EditorMind/src/components/EditorDetailPanel/FlowDetailPanel.tsx diff --git a/EditorMind/src/components/EditorDetailPanel/KoniDetailPanel.js b/EditorMind/src/components/EditorDetailPanel/KoniDetailPanel.tsx similarity index 100% rename from EditorMind/src/components/EditorDetailPanel/KoniDetailPanel.js rename to EditorMind/src/components/EditorDetailPanel/KoniDetailPanel.tsx diff --git a/EditorMind/src/components/EditorDetailPanel/MindDetailPanel.js b/EditorMind/src/components/EditorDetailPanel/MindDetailPanel.tsx similarity index 100% rename from EditorMind/src/components/EditorDetailPanel/MindDetailPanel.js rename to EditorMind/src/components/EditorDetailPanel/MindDetailPanel.tsx diff --git a/EditorMind/src/components/EditorDetailPanel/index.js b/EditorMind/src/components/EditorDetailPanel/index.tsx similarity index 100% rename from EditorMind/src/components/EditorDetailPanel/index.js rename to EditorMind/src/components/EditorDetailPanel/index.tsx diff --git a/EditorMind/src/components/EditorItemPanel/FlowItemPanel.js b/EditorMind/src/components/EditorItemPanel/FlowItemPanel.tsx similarity index 100% rename from EditorMind/src/components/EditorItemPanel/FlowItemPanel.js rename to EditorMind/src/components/EditorItemPanel/FlowItemPanel.tsx diff --git a/EditorMind/src/components/EditorItemPanel/KoniItemPanel.js b/EditorMind/src/components/EditorItemPanel/KoniItemPanel.tsx similarity index 100% rename from EditorMind/src/components/EditorItemPanel/KoniItemPanel.js rename to EditorMind/src/components/EditorItemPanel/KoniItemPanel.tsx diff --git a/EditorMind/src/components/EditorItemPanel/index.js b/EditorMind/src/components/EditorItemPanel/index.tsx similarity index 100% rename from EditorMind/src/components/EditorItemPanel/index.js rename to EditorMind/src/components/EditorItemPanel/index.tsx diff --git a/EditorMind/src/components/EditorMinimap/index.js b/EditorMind/src/components/EditorMinimap/index.tsx similarity index 100% rename from EditorMind/src/components/EditorMinimap/index.js rename to EditorMind/src/components/EditorMinimap/index.tsx diff --git a/EditorMind/src/components/EditorToolbar/FlowToolbar.js b/EditorMind/src/components/EditorToolbar/FlowToolbar.tsx similarity index 100% rename from EditorMind/src/components/EditorToolbar/FlowToolbar.js rename to EditorMind/src/components/EditorToolbar/FlowToolbar.tsx diff --git a/EditorMind/src/components/EditorToolbar/KoniToolbar.js b/EditorMind/src/components/EditorToolbar/KoniToolbar.tsx similarity index 100% rename from EditorMind/src/components/EditorToolbar/KoniToolbar.js rename to EditorMind/src/components/EditorToolbar/KoniToolbar.tsx diff --git a/EditorMind/src/components/EditorToolbar/MindToolbar.js b/EditorMind/src/components/EditorToolbar/MindToolbar.tsx similarity index 100% rename from EditorMind/src/components/EditorToolbar/MindToolbar.js rename to EditorMind/src/components/EditorToolbar/MindToolbar.tsx diff --git a/EditorFlow/src/components/EditorToolbar/ToolbarButton.js b/EditorMind/src/components/EditorToolbar/ToolbarButton.tsx similarity index 65% rename from EditorFlow/src/components/EditorToolbar/ToolbarButton.js rename to EditorMind/src/components/EditorToolbar/ToolbarButton.tsx index eb5b4ffa..30958f0e 100644 --- a/EditorFlow/src/components/EditorToolbar/ToolbarButton.js +++ b/EditorMind/src/components/EditorToolbar/ToolbarButton.tsx @@ -1,11 +1,19 @@ import React from 'react'; import { Tooltip } from 'antd'; import { Command } from 'gg-editor'; -import upperFirst from 'lodash/upperFirst'; import IconFont from '../../common/IconFont'; import styles from './index.less'; -const ToolbarButton = props => { +const upperFirst = (str: string) => { + return str.toLowerCase().replace(/( |^)[a-z]/g, (l: string) => l.toUpperCase()); +}; + +interface ToolbarButtonProps { + command: string; + icon?: string; + text?: string; +} +const ToolbarButton: React.SFC = props => { const { command, icon, text } = props; return ( diff --git a/EditorMind/src/components/EditorToolbar/index.js b/EditorMind/src/components/EditorToolbar/index.tsx similarity index 100% rename from EditorMind/src/components/EditorToolbar/index.js rename to EditorMind/src/components/EditorToolbar/index.tsx diff --git a/EditorMind/src/components/PageHeaderWrapper/index.tsx b/EditorMind/src/components/PageHeaderWrapper/index.tsx index bb565a04..18525c4b 100644 --- a/EditorMind/src/components/PageHeaderWrapper/index.tsx +++ b/EditorMind/src/components/PageHeaderWrapper/index.tsx @@ -1,8 +1,7 @@ import React from 'react'; -import { RouteContext } from '@ant-design/pro-layout'; +import { RouteContext, GridContent } from '@ant-design/pro-layout'; import { PageHeader, Tabs, Typography } from 'antd'; import styles from './index.less'; -import { GridContent } from '@ant-design/pro-layout'; import { TabsProps } from 'antd/lib/tabs'; interface IPageHeaderTabConfig { tabList?: Array<{ -- GitLab