Using Tailwind
Extensions
Using Tailwind
Extensions
Styled and configured Tiptap extensions for your editor
You can use any Tiptap extensions or create your own.
Default Extensions
extensions.ts
import {
TiptapImage,
TiptapLink,
UpdatedImage,
TaskList,
TaskItem,
HorizontalRule,
StarterKit,
Placeholder,
} from "novel/extensions";
import { cx } from "class-variance-authority";
// TODO I am using cx here to get tailwind autocomplete working, idk if someone else can write a regex to just capture the class key in objects
// You can overwrite the placeholder with your own configuration
const placeholder = Placeholder;
const tiptapLink = TiptapLink.configure({
HTMLAttributes: {
class: cx(
"text-muted-foreground underline underline-offset-[3px] hover:text-primary transition-colors cursor-pointer",
),
},
});
const taskList = TaskList.configure({
HTMLAttributes: {
class: cx("not-prose pl-2"),
},
});
const taskItem = TaskItem.configure({
HTMLAttributes: {
class: cx("flex items-start my-4"),
},
nested: true,
});
const horizontalRule = HorizontalRule.configure({
HTMLAttributes: {
class: cx("mt-4 mb-6 border-t border-muted-foreground"),
},
});
const starterKit = StarterKit.configure({
bulletList: {
HTMLAttributes: {
class: cx("list-disc list-outside leading-3 -mt-2"),
},
},
orderedList: {
HTMLAttributes: {
class: cx("list-decimal list-outside leading-3 -mt-2"),
},
},
listItem: {
HTMLAttributes: {
class: cx("leading-normal -mb-2"),
},
},
blockquote: {
HTMLAttributes: {
class: cx("border-l-4 border-primary"),
},
},
codeBlock: {
HTMLAttributes: {
class: cx("rounded-sm bg-muted border p-5 font-mono font-medium"),
},
},
code: {
HTMLAttributes: {
class: cx("rounded-md bg-muted px-1.5 py-1 font-mono font-medium"),
spellcheck: "false",
},
},
horizontalRule: false,
dropcursor: {
color: "#DBEAFE",
width: 4,
},
gapcursor: false,
});
export const defaultExtensions = [
starterKit,
placeholder,
TiptapLink,
TiptapImage,
UpdatedImage,
taskList,
taskItem,
horizontalRule,
];
For intellisense in your VS Code editor you can also add this regex to the settings.json
"tailwindCSS.experimental.classRegex":[["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]],
Custom Extension
Coming soon
On this page