Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
renardeinside committed Nov 24, 2024
1 parent 1b6b102 commit c5b2aad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
26 changes: 15 additions & 11 deletions src/components/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EditorContent, Editor as TiptapEditor } from "@tiptap/react";
import { lazy, Suspense, useEffect } from "react";
import { lazy, Suspense, useEffect, useMemo } from "react";
import { loadExtensions } from "@/lib/extensions";
import { LoaderCircle } from "lucide-react";
import { useDoc } from "@/hooks/use-doc";
Expand All @@ -17,19 +17,23 @@ const Loading = () => {
};

const EditorView = ({ doc }: { doc: Y.Doc }) => {
const editor = new TiptapEditor({
extensions: [...loadExtensions(doc)],
editorProps: {
attributes: {
class:
"!w-full prose !max-w-none dark:prose-invert prose-md leading-tight focus:outline-none min-h-[90vh]",
},
},
});
const editor = useMemo(
() =>
new TiptapEditor({
extensions: [...loadExtensions(doc)],
editorProps: {
attributes: {
class:
"!w-full prose !max-w-none dark:prose-invert prose-md leading-tight focus:outline-none min-h-[90vh]",
},
},
}),
[doc]
);

useEffect(() => {
if (!editor.isFocused) {
editor.commands.focus('end');
editor.commands.focus("end");
}
}, [editor]);

Expand Down
7 changes: 0 additions & 7 deletions src/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@

/* Basic editor styles */
.tiptap {
p.is-editor-empty:first-child::before {
@apply text-foreground/50;
content: attr(data-placeholder);
float: left;
height: 0;
pointer-events: none;
}

/* disable margin-bottom for paragraph elements under li */
li > p {
Expand Down

0 comments on commit c5b2aad

Please sign in to comment.