From c1295d8b6c7bafef3cd3bcb47e5a8f6a06c22279 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Sat, 26 Mar 2022 13:50:29 +0800 Subject: [PATCH 1/3] feat: improve style --- .../src/components/tiptap/extensions/emoji.ts | 50 +- .../tiptap/extensions/evokeMenu.tsx | 69 ++- .../tiptap/extensions/tableCell.tsx | 2 +- .../tiptap/extensions/tableHeader.tsx | 2 +- .../src/components/tiptap/menus/table.tsx | 2 +- .../wrappers/attachment/index.module.scss | 1 - .../tiptap/wrappers/banner/index.module.scss | 1 - .../documentChildren/index.module.scss | 10 +- .../wrappers/documentChildren/index.tsx | 2 - .../documentReference/index.module.scss | 14 +- .../wrappers/documentReference/index.tsx | 2 +- .../tiptap/wrappers/iframe/index.module.scss | 1 - .../tiptap/wrappers/image/index.module.scss | 1 - .../tiptap/wrappers/katex/index.module.scss | 3 +- .../tiptap/wrappers/katex/index.tsx | 3 +- .../tiptap/wrappers/mind/index.module.scss | 1 - .../tiptap/wrappers/status/index.tsx | 3 +- packages/client/src/styles/editor/base.scss | 53 ++ packages/client/src/styles/editor/code.scss | 277 ++++++++++ .../src/styles/editor/collaboration.scss | 24 + packages/client/src/styles/editor/color.scss | 16 + .../client/src/styles/editor/heading.scss | 40 ++ packages/client/src/styles/editor/index.scss | 13 + .../client/src/styles/{ => editor}/katex.scss | 15 +- packages/client/src/styles/editor/list.scss | 106 ++++ packages/client/src/styles/editor/menu.scss | 23 + .../styles/{jsmind.scss => editor/mind.scss} | 91 ---- .../client/src/styles/editor/placeholder.scss | 19 + .../client/src/styles/editor/selection.scss | 91 ++++ packages/client/src/styles/editor/table.scss | 108 ++++ packages/client/src/styles/editor/title.scss | 17 + packages/client/src/styles/github-dark.scss | 131 ----- packages/client/src/styles/github.scss | 125 ----- packages/client/src/styles/globals.scss | 103 +--- packages/client/src/styles/prosemirror.scss | 483 ------------------ packages/client/src/styles/reset.scss | 94 ++++ packages/client/src/styles/var.scss | 4 + 37 files changed, 962 insertions(+), 1038 deletions(-) create mode 100644 packages/client/src/styles/editor/base.scss create mode 100644 packages/client/src/styles/editor/code.scss create mode 100644 packages/client/src/styles/editor/collaboration.scss create mode 100644 packages/client/src/styles/editor/color.scss create mode 100644 packages/client/src/styles/editor/heading.scss create mode 100644 packages/client/src/styles/editor/index.scss rename packages/client/src/styles/{ => editor}/katex.scss (98%) create mode 100644 packages/client/src/styles/editor/list.scss create mode 100644 packages/client/src/styles/editor/menu.scss rename packages/client/src/styles/{jsmind.scss => editor/mind.scss} (75%) create mode 100644 packages/client/src/styles/editor/placeholder.scss create mode 100644 packages/client/src/styles/editor/selection.scss create mode 100644 packages/client/src/styles/editor/table.scss create mode 100644 packages/client/src/styles/editor/title.scss delete mode 100644 packages/client/src/styles/github-dark.scss delete mode 100644 packages/client/src/styles/github.scss delete mode 100644 packages/client/src/styles/prosemirror.scss create mode 100644 packages/client/src/styles/reset.scss diff --git a/packages/client/src/components/tiptap/extensions/emoji.ts b/packages/client/src/components/tiptap/extensions/emoji.ts index 59c09133..260e168e 100644 --- a/packages/client/src/components/tiptap/extensions/emoji.ts +++ b/packages/client/src/components/tiptap/extensions/emoji.ts @@ -60,33 +60,29 @@ export const Emoji = Node.create({ new Plugin({ key: new PluginKey('emojiPlaceholder'), props: { - decorations: (state) => { - if (!editor.isEditable) return; - - const parent = findParentNode((node) => node.type.name === 'paragraph')(state.selection); - if (!parent) { - return; - } - - const decorations: Decoration[] = []; - const isEmpty = parent && parent.node.content.size === 0; - const isSlash = parent && parent.node.textContent === ':'; - const isTopLevel = state.selection.$from.depth === 1; - - if (isTopLevel) { - if (isSlash) { - decorations.push( - Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { - 'class': 'placeholder', - 'data-placeholder': ` 继续输入进行过滤`, - }) - ); - } - - return DecorationSet.create(state.doc, decorations); - } - return null; - }, + // decorations: (state) => { + // if (!editor.isEditable) return; + // const parent = findParentNode((node) => node.type.name === 'paragraph')(state.selection); + // if (!parent) { + // return; + // } + // const decorations: Decoration[] = []; + // const isEmpty = parent && parent.node.content.size === 0; + // const isSlash = parent && parent.node.textContent === ':'; + // const isTopLevel = state.selection.$from.depth === 1; + // if (isTopLevel) { + // if (isSlash) { + // decorations.push( + // Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { + // 'class': 'placeholder', + // 'data-placeholder': ` 继续输入进行过滤`, + // }) + // ); + // } + // return DecorationSet.create(state.doc, decorations); + // } + // return null; + // }, }, }), ]; diff --git a/packages/client/src/components/tiptap/extensions/evokeMenu.tsx b/packages/client/src/components/tiptap/extensions/evokeMenu.tsx index d9e397e3..976b50f5 100644 --- a/packages/client/src/components/tiptap/extensions/evokeMenu.tsx +++ b/packages/client/src/components/tiptap/extensions/evokeMenu.tsx @@ -42,43 +42,38 @@ export const EvokeMenu = Node.create({ new Plugin({ key: new PluginKey('evokeMenuPlaceholder'), props: { - decorations: (state) => { - if (!editor.isEditable) return; - - const parent = findParentNode((node) => node.type.name === 'paragraph')(state.selection); - if (!parent) { - return; - } - - const decorations: Decoration[] = []; - const isEmpty = parent && parent.node.content.size === 0; - const isSlash = parent && parent.node.textContent === '/'; - const isTopLevel = state.selection.$from.depth === 1; - const hasOtherChildren = parent && parent.node.content.childCount > 1; - - if (isTopLevel) { - if (isEmpty) { - decorations.push( - Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { - 'class': 'is-empty', - 'data-placeholder': '输入 / 唤起更多', - }) - ); - } - - if (isSlash && !hasOtherChildren) { - decorations.push( - Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { - 'class': 'is-empty', - 'data-placeholder': ` 继续输入进行过滤`, - }) - ); - } - - return DecorationSet.create(state.doc, decorations); - } - return null; - }, + // decorations: (state) => { + // if (!editor.isEditable) return; + // const parent = findParentNode((node) => node.type.name === 'paragraph')(state.selection); + // if (!parent) { + // return; + // } + // const decorations: Decoration[] = []; + // const isEmpty = parent && parent.node.content.size === 0; + // const isSlash = parent && parent.node.textContent === '/'; + // const isTopLevel = state.selection.$from.depth === 1; + // const hasOtherChildren = parent && parent.node.content.childCount > 1; + // if (isTopLevel) { + // if (isEmpty) { + // decorations.push( + // Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { + // 'class': 'is-empty', + // 'data-placeholder': '输入 / 唤起更多', + // }) + // ); + // } + // if (isSlash && !hasOtherChildren) { + // decorations.push( + // Decoration.node(parent.pos, parent.pos + parent.node.nodeSize, { + // 'class': 'is-empty', + // 'data-placeholder': ` 继续输入进行过滤`, + // }) + // ); + // } + // return DecorationSet.create(state.doc, decorations); + // } + // return null; + // }, }, }), ]; diff --git a/packages/client/src/components/tiptap/extensions/tableCell.tsx b/packages/client/src/components/tiptap/extensions/tableCell.tsx index f3f80654..d6816567 100644 --- a/packages/client/src/components/tiptap/extensions/tableCell.tsx +++ b/packages/client/src/components/tiptap/extensions/tableCell.tsx @@ -105,7 +105,7 @@ export const TableCell = BuiltInTableCell.extend({ return !!cells?.some((cell, index) => isRowSelected(index)(editor.state.selection)); }, init: (dom, editor) => { - dom.classList.add('table-controller-wrapper'); + dom.classList.add('bubble-memu-table-cell'); dom.classList.add('row'); ReactDOM.render( <> diff --git a/packages/client/src/components/tiptap/extensions/tableHeader.tsx b/packages/client/src/components/tiptap/extensions/tableHeader.tsx index acd512c5..52c939ae 100644 --- a/packages/client/src/components/tiptap/extensions/tableHeader.tsx +++ b/packages/client/src/components/tiptap/extensions/tableHeader.tsx @@ -94,7 +94,7 @@ export const TableHeader = BuiltInTableHeader.extend({ return !!cells?.some((cell, index) => isColumnSelected(index)(selection)); }, init: (dom, editor) => { - dom.classList.add('table-controller-wrapper'); + dom.classList.add('bubble-memu-table-cell'); ReactDOM.render( diff --git a/packages/client/src/components/tiptap/menus/table.tsx b/packages/client/src/components/tiptap/menus/table.tsx index be0f0889..a6ab412a 100644 --- a/packages/client/src/components/tiptap/menus/table.tsx +++ b/packages/client/src/components/tiptap/menus/table.tsx @@ -21,7 +21,7 @@ import { Table } from '../extensions/table'; export const TableBubbleMenu = ({ editor }) => { return ( editor.isActive(Table.name)} diff --git a/packages/client/src/components/tiptap/wrappers/attachment/index.module.scss b/packages/client/src/components/tiptap/wrappers/attachment/index.module.scss index 977f95be..b2527f9c 100644 --- a/packages/client/src/components/tiptap/wrappers/attachment/index.module.scss +++ b/packages/client/src/components/tiptap/wrappers/attachment/index.module.scss @@ -2,7 +2,6 @@ display: flex; justify-content: space-between; align-items: center; - margin: 10px 0; padding: 8px 16px; border: 1px solid var(--semi-color-border); border-radius: var(--border-radius); diff --git a/packages/client/src/components/tiptap/wrappers/banner/index.module.scss b/packages/client/src/components/tiptap/wrappers/banner/index.module.scss index 6f0fb556..cb67a8a3 100644 --- a/packages/client/src/components/tiptap/wrappers/banner/index.module.scss +++ b/packages/client/src/components/tiptap/wrappers/banner/index.module.scss @@ -1,5 +1,4 @@ .wrap { - margin: 12px 0; line-height: 0; border-radius: var(--border-radius); border: 1px solid var(--semi-color-border); diff --git a/packages/client/src/components/tiptap/wrappers/documentChildren/index.module.scss b/packages/client/src/components/tiptap/wrappers/documentChildren/index.module.scss index 60706301..b2ca9a63 100644 --- a/packages/client/src/components/tiptap/wrappers/documentChildren/index.module.scss +++ b/packages/client/src/components/tiptap/wrappers/documentChildren/index.module.scss @@ -1,15 +1,10 @@ .wrap { - margin-top: 12px; + margin-top: 0.75em; padding: 12px; border: 1px solid var(--semi-color-border); + border-radius: var(--border-radius); &.isEditable { - background-color: var(--semi-color-fill-0); - - &:hover { - background-color: var(--semi-color-fill-1); - } - .itemWrap { pointer-events: none; @@ -24,6 +19,7 @@ display: flex; align-items: center; margin-top: 12px; + padding: 6px; text-decoration: none; color: var(--semi-color-text-1); border-radius: var(--border-radius); diff --git a/packages/client/src/components/tiptap/wrappers/documentChildren/index.tsx b/packages/client/src/components/tiptap/wrappers/documentChildren/index.tsx index 05864b5e..eab2942c 100644 --- a/packages/client/src/components/tiptap/wrappers/documentChildren/index.tsx +++ b/packages/client/src/components/tiptap/wrappers/documentChildren/index.tsx @@ -76,8 +76,6 @@ export const DocumentChildrenWrapper = ({ editor, node, updateAttributes }) => { 当前页面无法使用子文档 )} - - ); }; diff --git a/packages/client/src/components/tiptap/wrappers/documentReference/index.module.scss b/packages/client/src/components/tiptap/wrappers/documentReference/index.module.scss index 1ce1e9fb..3c902e5a 100644 --- a/packages/client/src/components/tiptap/wrappers/documentReference/index.module.scss +++ b/packages/client/src/components/tiptap/wrappers/documentReference/index.module.scss @@ -1,23 +1,13 @@ .wrap { - margin-top: 12px; + margin-top: 0.75em; + border-radius: var(--border-radius); &.isEditable { - border-color: transparent !important; padding: 12px; - background-color: var(--semi-color-fill-0); - - &:hover { - background-color: var(--semi-color-fill-1); - } .itemWrap { pointer-events: none; margin-top: 12px; - - &:hover { - color: var(--semi-color-text-1); - border-color: var(--semi-color-border); - } } .empty { diff --git a/packages/client/src/components/tiptap/wrappers/documentReference/index.tsx b/packages/client/src/components/tiptap/wrappers/documentReference/index.tsx index 9e993030..6d72abc5 100644 --- a/packages/client/src/components/tiptap/wrappers/documentReference/index.tsx +++ b/packages/client/src/components/tiptap/wrappers/documentReference/index.tsx @@ -35,6 +35,7 @@ export const DocumentReferenceWrapper = ({ editor, node, updateAttributes }) =>