From 3b68238249b072c2ee2029c0ed56f9a33d9d6624 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 19 Aug 2022 17:38:51 +0800 Subject: [PATCH] tiptap: improve mind toolbar --- .../kityminder/kity-core/module/priority.js | 2 +- .../src/tiptap/core/menus/mind/constant.ts | 33 ++ .../src/tiptap/core/menus/mind/modal.tsx | 7 + .../core/menus/mind/toolbar/bgcolor.tsx | 39 ++ .../core/menus/mind/toolbar/font-color.tsx | 39 ++ .../tiptap/core/menus/mind/toolbar/help.tsx | 33 ++ .../tiptap/core/menus/mind/toolbar/image.tsx | 4 +- .../tiptap/core/menus/mind/toolbar/index.tsx | 387 +++++++++--------- .../core/menus/mind/toolbar/priority.tsx | 29 ++ .../core/menus/mind/toolbar/progress.tsx | 29 ++ .../core/menus/mind/toolbar/template.tsx | 41 ++ .../tiptap/core/menus/mind/toolbar/theme.tsx | 42 ++ 12 files changed, 481 insertions(+), 204 deletions(-) create mode 100644 packages/client/src/tiptap/core/menus/mind/toolbar/bgcolor.tsx create mode 100644 packages/client/src/tiptap/core/menus/mind/toolbar/font-color.tsx create mode 100644 packages/client/src/tiptap/core/menus/mind/toolbar/help.tsx create mode 100644 packages/client/src/tiptap/core/menus/mind/toolbar/priority.tsx create mode 100644 packages/client/src/tiptap/core/menus/mind/toolbar/progress.tsx create mode 100644 packages/client/src/tiptap/core/menus/mind/toolbar/template.tsx create mode 100644 packages/client/src/tiptap/core/menus/mind/toolbar/theme.tsx diff --git a/packages/client/src/thirtypart/kityminder/kity-core/module/priority.js b/packages/client/src/thirtypart/kityminder/kity-core/module/priority.js index 7facd62..21e44fe 100644 --- a/packages/client/src/thirtypart/kityminder/kity-core/module/priority.js +++ b/packages/client/src/thirtypart/kityminder/kity-core/module/priority.js @@ -82,7 +82,7 @@ define(function (require, exports, module) { mask.fill(color[0]); } - number.setContent(value); + number.setContent('P' + value); }, }); diff --git a/packages/client/src/tiptap/core/menus/mind/constant.ts b/packages/client/src/tiptap/core/menus/mind/constant.ts index 9d8fbda..25e3367 100644 --- a/packages/client/src/tiptap/core/menus/mind/constant.ts +++ b/packages/client/src/tiptap/core/menus/mind/constant.ts @@ -1,3 +1,36 @@ +const getProgressTitle = (index) => { + switch (index) { + case 0: + return '移除进度'; + case 1: + return '未开始'; + case 9: + return '全部完成'; + default: + return '完成' + (index - 1) + '/8'; + } +}; + +export const PROGRESSES = Array.from({ length: 10 }, (_, i) => { + return { + text: getProgressTitle(i), + value: i, + }; +}); + +export const PRIORITIES = [ + { + text: '移除优先级', + value: 0, + }, + ...Array.from({ length: 9 }, (_, i) => { + return { + text: `P${i + 1}`, + value: i + 1, + }; + }), +]; + export const TEMPLATES = [ { label: '经典', diff --git a/packages/client/src/tiptap/core/menus/mind/modal.tsx b/packages/client/src/tiptap/core/menus/mind/modal.tsx index d8ecf19..f9518dc 100644 --- a/packages/client/src/tiptap/core/menus/mind/modal.tsx +++ b/packages/client/src/tiptap/core/menus/mind/modal.tsx @@ -65,6 +65,12 @@ export const MindSettingModal: React.FC = ({ editor }) => { }; }, [editor, toggleVisible]); + useEffect(() => { + if (!visible && mind) { + mind.destroy(); + } + }, [visible, mind]); + return ( = ({ editor }) => { onOk={save} okText="保存" cancelText="退出" + motion={false} >
{ + return ( + { + setBackgroundColor(color); + }} + > + +
+ } + /> + + + ); +}; diff --git a/packages/client/src/tiptap/core/menus/mind/toolbar/font-color.tsx b/packages/client/src/tiptap/core/menus/mind/toolbar/font-color.tsx new file mode 100644 index 0000000..f3b3894 --- /dev/null +++ b/packages/client/src/tiptap/core/menus/mind/toolbar/font-color.tsx @@ -0,0 +1,39 @@ +import { IconFont } from '@douyinfe/semi-icons'; +import { Button, Tooltip } from '@douyinfe/semi-ui'; +import { ColorPicker } from 'components/color-picker'; + +export const FontColor = ({ selectedNode, setFontColor, textColor }) => { + return ( + { + setFontColor(color); + }} + > + +