added migration support by updating to html

This commit is contained in:
Palanikannan1437 2023-08-07 21:02:39 +05:30
parent a6ae849a81
commit 63c7bc2d68
4 changed files with 13 additions and 9 deletions

View File

@ -82,7 +82,7 @@ export const CommandPalette: React.FC = () => {
!(e.target instanceof HTMLTextAreaElement) && !(e.target instanceof HTMLTextAreaElement) &&
!(e.target instanceof HTMLInputElement) && !(e.target instanceof HTMLInputElement) &&
// !(e.target as Element).classList?.contains("remirror-editor") && // !(e.target as Element).classList?.contains("remirror-editor") &&
!(e.target as Element).closest(".tiptap-editor-container") !(e.target as Element)?.closest(".tiptap-editor-container")
) { ) {
if ((ctrlKey || metaKey) && keyPressed === "k") { if ((ctrlKey || metaKey) && keyPressed === "k") {
e.preventDefault(); e.preventDefault();

View File

@ -111,7 +111,7 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
<span>{errors.name ? errors.name.message : null}</span> <span>{errors.name ? errors.name.message : null}</span>
<div className="relative"> <div className="relative">
<Controller <Controller
name="description" name="description_html"
control={control} control={control}
render={({ field: { value, onChange } }) => { render={({ field: { value, onChange } }) => {
if (!value && !watch("description_html")) return <></>; if (!value && !watch("description_html")) return <></>;
@ -125,8 +125,9 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
} }
setIsSubmitting={setIsSubmitting} setIsSubmitting={setIsSubmitting}
onChange={(description: Object, description_html: string) => { onChange={(description: Object, description_html: string) => {
onChange(description); onChange(description_html);
setValue("description_html", description_html); // setValue("description_html", description_html);
setValue("description", description);
handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting(false)); handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting(false));
}} }}
/> />

View File

@ -104,7 +104,7 @@ export const TiptapExtensions = [
return `Heading ${node.attrs.level}`; return `Heading ${node.attrs.level}`;
} }
return "Press '/' for commands, or 'Ctrl + Space' for AI autocomplete..."; return "Press '/' for commands...";
}, },
includeChildren: true, includeChildren: true,
}), }),
@ -127,7 +127,7 @@ export const TiptapExtensions = [
nested: true, nested: true,
}), }),
Markdown.configure({ Markdown.configure({
html: false, html: true,
transformCopiedText: true, transformCopiedText: true,
}), }),
]; ];

View File

@ -1,4 +1,5 @@
import { useEditor, EditorContent } from '@tiptap/react'; import { useEditor, EditorContent, generateText } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import { useDebouncedCallback } from 'use-debounce'; import { useDebouncedCallback } from 'use-debounce';
import { EditorBubbleMenu } from './EditorBubbleMenu'; import { EditorBubbleMenu } from './EditorBubbleMenu';
import { TiptapExtensions } from './extensions'; import { TiptapExtensions } from './extensions';
@ -10,7 +11,7 @@ type TiptapProps = {
borderOnFocus?: boolean; borderOnFocus?: boolean;
customClassName?: string; customClassName?: string;
onChange?: (json: any, html: string) => void; onChange?: (json: any, html: string) => void;
setIsSubmitting?: (isSubmitting: boolean) => void; setIsSubmitting: (isSubmitting: boolean) => void;
} }
const Tiptap = ({ onChange, setIsSubmitting, value, noBorder, borderOnFocus, customClassName }: TiptapProps) => { const Tiptap = ({ onChange, setIsSubmitting, value, noBorder, borderOnFocus, customClassName }: TiptapProps) => {
@ -45,7 +46,9 @@ const Tiptap = ({ onChange, setIsSubmitting, value, noBorder, borderOnFocus, cus
className={`tiptap-editor-container relative min-h-[150px] ${editorClassNames}`} className={`tiptap-editor-container relative min-h-[150px] ${editorClassNames}`}
> >
{editor && <EditorBubbleMenu editor={editor} />} {editor && <EditorBubbleMenu editor={editor} />}
<EditorContent editor={editor} /> <div className="pt-8">
<EditorContent editor={editor} />
</div>
</div> </div>
); );
}; };