plane/apps/app/components/issues/tiptap.tsx

47 lines
1.3 KiB
TypeScript
Raw Normal View History

import Placeholder from '@tiptap/extension-placeholder';
import { useEditor, EditorContent } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import { EditorBubbleMenu } from './EditorBubbleMenu';
import { TiptapExtensions } from './extensions';
import { TiptapEditorProps } from "./props";
type TiptapProps = {
value: string;
noBorder?: boolean;
borderOnFocus?: boolean;
customClassName?: string;
}
const Tiptap = ({ value, noBorder, borderOnFocus, customClassName }: TiptapProps) => {
const editor = useEditor({
editorProps: TiptapEditorProps,
extensions: TiptapExtensions,
// extensions: [
// StarterKit,
// Placeholder.configure({
// placeholder: 'Description...',
// })
// ],
content: value,
});
const editorClassNames = `mt-2 p-3 relative focus:outline-none rounded-md focus:border-custom-border-200
${noBorder ? '' : 'border border-custom-border-200'
} ${borderOnFocus ? 'focus:border border-custom-border-200' : 'focus:border-0'
} ${customClassName}`;
return (
<div
onClick={() => {
editor?.chain().focus().run();
}}
className={`tiptap-editor-container relative min-h-[150px] ${editorClassNames}`}
>
{editor && <EditorBubbleMenu editor={editor} />}
<EditorContent editor={editor} />
</div>
);
};
export default Tiptap;