From 9b47b813740efd7a00c5203df522b86fd62c64d9 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Fri, 1 Apr 2022 19:36:26 +0800 Subject: [PATCH] fix: fix custom node wrapper select --- .../src/tiptap/extensions/attachment.ts | 1 + .../client/src/tiptap/styles/selection.scss | 2 ++ .../src/tiptap/wrappers/attachment/index.tsx | 28 ++++++++----------- .../wrappers/document-children/index.tsx | 2 +- .../wrappers/document-reference/index.tsx | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/packages/client/src/tiptap/extensions/attachment.ts b/packages/client/src/tiptap/extensions/attachment.ts index bccd2b90..8f60e424 100644 --- a/packages/client/src/tiptap/extensions/attachment.ts +++ b/packages/client/src/tiptap/extensions/attachment.ts @@ -18,6 +18,7 @@ export const Attachment = Node.create({ group: 'block', selectable: true, atom: true, + draggable: true, addOptions() { return { diff --git a/packages/client/src/tiptap/styles/selection.scss b/packages/client/src/tiptap/styles/selection.scss index 7868f3cd..e44a7f37 100644 --- a/packages/client/src/tiptap/styles/selection.scss +++ b/packages/client/src/tiptap/styles/selection.scss @@ -33,6 +33,8 @@ .node-katex, .node-documentChildren, .node-documentReference { + user-select: none; + .render-wrapper { border: 1px solid var(--node-border-color); } diff --git a/packages/client/src/tiptap/wrappers/attachment/index.tsx b/packages/client/src/tiptap/wrappers/attachment/index.tsx index 8d6a226f..83d25e7b 100644 --- a/packages/client/src/tiptap/wrappers/attachment/index.tsx +++ b/packages/client/src/tiptap/wrappers/attachment/index.tsx @@ -53,10 +53,15 @@ export const AttachmentWrapper = ({ editor, node, updateAttributes }) => { }, [url, hasTrigger]); const content = (() => { - if (error !== 'null') { + if (isEditable && !url) { return ( -
- {error} +
+ + + {loading ? '正在上传中' : '请选择文件'} + + +
); } @@ -102,23 +107,14 @@ export const AttachmentWrapper = ({ editor, node, updateAttributes }) => { ); } - if (isEditable && !url) { + if (error !== 'null') { return ( -
- - - {loading ? '正在上传中' : '请选择文件'} - - - +
+ {error}
); } })(); - return ( - - {content} - - ); + return {content}; }; diff --git a/packages/client/src/tiptap/wrappers/document-children/index.tsx b/packages/client/src/tiptap/wrappers/document-children/index.tsx index eab2942c..5da66111 100644 --- a/packages/client/src/tiptap/wrappers/document-children/index.tsx +++ b/packages/client/src/tiptap/wrappers/document-children/index.tsx @@ -1,4 +1,4 @@ -import { NodeViewWrapper, NodeViewContent } from '@tiptap/react'; +import { NodeViewWrapper } from '@tiptap/react'; import { useRouter } from 'next/router'; import Link from 'next/link'; import cls from 'classnames'; diff --git a/packages/client/src/tiptap/wrappers/document-reference/index.tsx b/packages/client/src/tiptap/wrappers/document-reference/index.tsx index 6d72abc5..e404810b 100644 --- a/packages/client/src/tiptap/wrappers/document-reference/index.tsx +++ b/packages/client/src/tiptap/wrappers/document-reference/index.tsx @@ -1,4 +1,4 @@ -import { NodeViewWrapper, NodeViewContent } from '@tiptap/react'; +import { NodeViewWrapper } from '@tiptap/react'; import { useRouter } from 'next/router'; import Link from 'next/link'; import cls from 'classnames';