From 9042da011f6a45d8cd0f24e0707f66addf560f79 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Mon, 25 Apr 2022 09:56:20 +0800 Subject: [PATCH] fix: fix comment extensions --- packages/client/src/styles/globals.scss | 2 +- .../src/tiptap/extensions/placeholder.ts | 13 +------------ packages/client/src/tiptap/menubar.tsx | 1 - packages/client/src/tiptap/start-kit.tsx | 19 +++++++++++++++++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/client/src/styles/globals.scss b/packages/client/src/styles/globals.scss index 08554c4d..5d10e4d5 100644 --- a/packages/client/src/styles/globals.scss +++ b/packages/client/src/styles/globals.scss @@ -27,7 +27,7 @@ .Resizer { z-index: 1; - opacity: 0.2; + opacity: .2; box-sizing: border-box; background-clip: padding; } diff --git a/packages/client/src/tiptap/extensions/placeholder.ts b/packages/client/src/tiptap/extensions/placeholder.ts index f2b86fe0..a60a49f5 100644 --- a/packages/client/src/tiptap/extensions/placeholder.ts +++ b/packages/client/src/tiptap/extensions/placeholder.ts @@ -1,14 +1,3 @@ import BuiltInPlaceholder from '@tiptap/extension-placeholder'; -export const Placeholder = BuiltInPlaceholder.configure({ - placeholder: ({ node, editor }) => { - if (!editor.isEditable) return; - - if (node.type.name === 'title') { - return '请输入标题'; - } - return '输入 / 唤起更多'; - }, - showOnlyCurrent: false, - showOnlyWhenEditable: true, -}); +export const Placeholder = BuiltInPlaceholder; diff --git a/packages/client/src/tiptap/menubar.tsx b/packages/client/src/tiptap/menubar.tsx index 505b848b..32ae1f95 100644 --- a/packages/client/src/tiptap/menubar.tsx +++ b/packages/client/src/tiptap/menubar.tsx @@ -112,7 +112,6 @@ export const CommentMenuBar: React.FC<{ editor: any }> = ({ editor }) => { - diff --git a/packages/client/src/tiptap/start-kit.tsx b/packages/client/src/tiptap/start-kit.tsx index 57141630..3e36653b 100644 --- a/packages/client/src/tiptap/start-kit.tsx +++ b/packages/client/src/tiptap/start-kit.tsx @@ -89,7 +89,18 @@ export const BaseKit = [ Mind, OrderedList, Paragraph, - Placeholder, + Placeholder.configure({ + placeholder: ({ node, editor }) => { + if (!editor.isEditable) return; + + if (node.type.name === 'title') { + return '请输入标题'; + } + return '输入 / 唤起更多'; + }, + showOnlyCurrent: false, + showOnlyWhenEditable: true, + }), QuickInsert, SearchNReplace, SelectionExtension, @@ -122,6 +133,7 @@ export const CommentKit = [ Color, ColorHighlighter, Dropcursor, + Emoji, Focus, FontSize, Gapcursor, @@ -137,7 +149,10 @@ export const CommentKit = [ Mention, OrderedList, Paragraph, - Placeholder, + Placeholder.configure({ + placeholder: '请输入内容', + showOnlyWhenEditable: true, + }), Strike, Subscript, Superscript,