mirror of https://github.com/fantasticit/think.git
fix: fix custom node wrapper select
This commit is contained in:
parent
39cf943eaa
commit
9b47b81374
|
@ -18,6 +18,7 @@ export const Attachment = Node.create({
|
|||
group: 'block',
|
||||
selectable: true,
|
||||
atom: true,
|
||||
draggable: true,
|
||||
|
||||
addOptions() {
|
||||
return {
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
.node-katex,
|
||||
.node-documentChildren,
|
||||
.node-documentReference {
|
||||
user-select: none;
|
||||
|
||||
.render-wrapper {
|
||||
border: 1px solid var(--node-border-color);
|
||||
}
|
||||
|
|
|
@ -53,10 +53,15 @@ export const AttachmentWrapper = ({ editor, node, updateAttributes }) => {
|
|||
}, [url, hasTrigger]);
|
||||
|
||||
const content = (() => {
|
||||
if (error !== 'null') {
|
||||
if (isEditable && !url) {
|
||||
return (
|
||||
<div className={cls(styles.wrap, 'render-wrapper')} onClick={selectFile}>
|
||||
<Text>{error}</Text>
|
||||
<div className={cls(styles.wrap, 'render-wrapper')}>
|
||||
<Spin spinning={loading}>
|
||||
<Text style={{ cursor: 'pointer' }} onClick={selectFile}>
|
||||
{loading ? '正在上传中' : '请选择文件'}
|
||||
</Text>
|
||||
<input ref={$upload} type="file" hidden onChange={handleFile} />
|
||||
</Spin>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -102,23 +107,14 @@ export const AttachmentWrapper = ({ editor, node, updateAttributes }) => {
|
|||
);
|
||||
}
|
||||
|
||||
if (isEditable && !url) {
|
||||
if (error !== 'null') {
|
||||
return (
|
||||
<div className={cls(styles.wrap, 'render-wrapper')}>
|
||||
<Spin spinning={loading}>
|
||||
<Text style={{ cursor: 'pointer' }} onClick={selectFile}>
|
||||
{loading ? '正在上传中' : '请选择文件'}
|
||||
</Text>
|
||||
<input ref={$upload} type="file" hidden onChange={handleFile} />
|
||||
</Spin>
|
||||
<div className={cls(styles.wrap, 'render-wrapper')} onClick={selectFile}>
|
||||
<Text>{error}</Text>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
return (
|
||||
<NodeViewWrapper as="div">
|
||||
{content} <NodeViewContent />
|
||||
</NodeViewWrapper>
|
||||
);
|
||||
return <NodeViewWrapper as="div">{content}</NodeViewWrapper>;
|
||||
};
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in New Issue