From edd964ab5f4bfc76be743987d5d8cd7ef4a3ec20 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 25 Mar 2022 17:17:10 +0800 Subject: [PATCH] feat: improve editor --- packages/client/next.config.js | 3 +- .../src/components/document/reader/user.tsx | 6 +-- .../components/icons/IconTableHeaderCell.tsx | 17 +++++++ .../icons/IconTableHeaderColumn.tsx | 14 ++++++ .../components/icons/IconTableHeaderRow.tsx | 15 +++++++ .../client/src/components/icons/index.tsx | 3 ++ .../tiptap/extensions/attachment.ts | 2 +- .../components/tiptap/extensions/banner.ts | 1 + .../components/tiptap/extensions/status.ts | 1 + .../src/components/tiptap/extensions/table.ts | 2 +- .../src/components/tiptap/menus/table.tsx | 36 +++++++++++++++ .../src/components/tiptap/services/file.ts | 8 ---- .../tiptap/services/markdown/index.tsx | 4 +- .../tiptap/wrappers/banner/index.module.scss | 1 - .../documentChildren/index.module.scss | 3 -- .../documentReference/index.module.scss | 8 +++- .../wrappers/documentReference/index.tsx | 9 ++-- .../wrappers/emojiList/index.module.scss | 44 +++++++++--------- .../tiptap/wrappers/image/index.tsx | 2 +- .../wrappers/menuList/index.module.scss | 45 ++++++++++--------- .../tiptap/wrappers/mind/index.module.scss | 5 +-- .../components/tiptap/wrappers/mind/index.tsx | 26 ++++++----- packages/client/src/services/file.ts | 15 +++++-- packages/client/src/styles/extension.scss | 4 -- packages/client/src/styles/prosemirror.scss | 24 +++++----- packages/config/yaml/dev.yaml | 8 ++-- 26 files changed, 204 insertions(+), 102 deletions(-) create mode 100644 packages/client/src/components/icons/IconTableHeaderCell.tsx create mode 100644 packages/client/src/components/icons/IconTableHeaderColumn.tsx create mode 100644 packages/client/src/components/icons/IconTableHeaderRow.tsx diff --git a/packages/client/next.config.js b/packages/client/next.config.js index 6264311..b2307d3 100644 --- a/packages/client/next.config.js +++ b/packages/client/next.config.js @@ -5,12 +5,11 @@ const config = getConfig().client; /** @type {import('next').NextConfig} */ const nextConfig = semi({ - reactStrictMode: true, assetPrefix: config.assetPrefix, env: { SERVER_API_URL: config.apiUrl, COLLABORATION_API_URL: config.collaborationUrl, - ENABLE_ALIYUN_OSS: config?.oss?.aliyun?.accessKeyId, + ENABLE_ALIYUN_OSS: !!config?.oss?.aliyun?.accessKeyId, }, webpack: (config, { dev, isServer }) => { config.resolve.plugins.push(new TsconfigPathsPlugin()); diff --git a/packages/client/src/components/document/reader/user.tsx b/packages/client/src/components/document/reader/user.tsx index 53432c2..7afe4b4 100644 --- a/packages/client/src/components/document/reader/user.tsx +++ b/packages/client/src/components/document/reader/user.tsx @@ -22,15 +22,15 @@ export const CreateUser: React.FC<{ document: IDocument; container: () => HTMLEl }} > - +
-

+

创建者: {document.createUser && document.createUser.name}

-

+

最近更新日期: {' ⦁ '}阅读量: diff --git a/packages/client/src/components/icons/IconTableHeaderCell.tsx b/packages/client/src/components/icons/IconTableHeaderCell.tsx new file mode 100644 index 0000000..a0e7747 --- /dev/null +++ b/packages/client/src/components/icons/IconTableHeaderCell.tsx @@ -0,0 +1,17 @@ +import { Icon } from '@douyinfe/semi-ui'; + +export const IconTableHeaderCell: React.FC<{ style?: React.CSSProperties }> = ({ style = {} }) => { + return ( + + + + } + /> + ); +}; diff --git a/packages/client/src/components/icons/IconTableHeaderColumn.tsx b/packages/client/src/components/icons/IconTableHeaderColumn.tsx new file mode 100644 index 0000000..d478907 --- /dev/null +++ b/packages/client/src/components/icons/IconTableHeaderColumn.tsx @@ -0,0 +1,14 @@ +import { Icon } from '@douyinfe/semi-ui'; + +export const IconTableHeaderColumn: React.FC<{ style?: React.CSSProperties }> = ({ style = {} }) => { + return ( + + + + } + /> + ); +}; diff --git a/packages/client/src/components/icons/IconTableHeaderRow.tsx b/packages/client/src/components/icons/IconTableHeaderRow.tsx new file mode 100644 index 0000000..557ba60 --- /dev/null +++ b/packages/client/src/components/icons/IconTableHeaderRow.tsx @@ -0,0 +1,15 @@ +import { Icon } from '@douyinfe/semi-ui'; + +export const IconTableHeaderRow: React.FC<{ style?: React.CSSProperties }> = ({ style = {} }) => { + return ( + + + + + } + /> + ); +}; diff --git a/packages/client/src/components/icons/index.tsx b/packages/client/src/components/icons/index.tsx index 1d187fc..fb4feb8 100644 --- a/packages/client/src/components/icons/index.tsx +++ b/packages/client/src/components/icons/index.tsx @@ -42,3 +42,6 @@ export * from './IconList'; export * from './IconHeading1'; export * from './IconHeading2'; export * from './IconHeading3'; +export * from './IconTableHeaderRow'; +export * from './IconTableHeaderColumn'; +export * from './IconTableHeaderCell'; diff --git a/packages/client/src/components/tiptap/extensions/attachment.ts b/packages/client/src/components/tiptap/extensions/attachment.ts index 9dbc357..bccd2b9 100644 --- a/packages/client/src/components/tiptap/extensions/attachment.ts +++ b/packages/client/src/components/tiptap/extensions/attachment.ts @@ -16,7 +16,7 @@ export const Attachment = Node.create({ content: '', marks: '', group: 'block', - draggable: true, + selectable: true, atom: true, addOptions() { diff --git a/packages/client/src/components/tiptap/extensions/banner.ts b/packages/client/src/components/tiptap/extensions/banner.ts index 53135f0..d99141c 100644 --- a/packages/client/src/components/tiptap/extensions/banner.ts +++ b/packages/client/src/components/tiptap/extensions/banner.ts @@ -17,6 +17,7 @@ export const Banner = Node.create({ content: 'paragraph+', group: 'block', defining: true, + selectable: true, addAttributes() { return { diff --git a/packages/client/src/components/tiptap/extensions/status.ts b/packages/client/src/components/tiptap/extensions/status.ts index f027d41..d97a4a3 100644 --- a/packages/client/src/components/tiptap/extensions/status.ts +++ b/packages/client/src/components/tiptap/extensions/status.ts @@ -16,6 +16,7 @@ export const Status = Node.create({ group: 'inline', inline: true, atom: true, + selectable: true, addAttributes() { return { diff --git a/packages/client/src/components/tiptap/extensions/table.ts b/packages/client/src/components/tiptap/extensions/table.ts index 01d2c08..d9aa02b 100644 --- a/packages/client/src/components/tiptap/extensions/table.ts +++ b/packages/client/src/components/tiptap/extensions/table.ts @@ -47,7 +47,7 @@ export const Table = BuiltInTable.extend({ return [ 'div', - { class: 'tableWrapper adas' }, + { class: 'tableWrapper' }, ['table', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), ['tbody', 0]], ]; }, diff --git a/packages/client/src/components/tiptap/menus/table.tsx b/packages/client/src/components/tiptap/menus/table.tsx index b6580f2..be0f088 100644 --- a/packages/client/src/components/tiptap/menus/table.tsx +++ b/packages/client/src/components/tiptap/menus/table.tsx @@ -9,6 +9,9 @@ import { IconMergeCell, IconSplitCell, IconDeleteTable, + IconTableHeaderRow, + IconTableHeaderColumn, + IconTableHeaderCell, } from 'components/icons'; import { Tooltip } from 'components/tooltip'; import { Divider } from '../wrappers/divider'; @@ -24,6 +27,7 @@ export const TableBubbleMenu = ({ editor }) => { shouldShow={() => editor.isActive(Table.name)} tippyOptions={{ maxWidth: 456, + placement: 'bottom', }} matchRenderContainer={(node: HTMLElement) => node && node.classList && node.classList.contains('tableWrapper') && node.tagName === 'DIV' @@ -93,6 +97,38 @@ export const TableBubbleMenu = ({ editor }) => { + +