"use client"; import { BubbleMenu, EditorContent, EditorProvider, FloatingMenu, useEditor, } from "@tiptap/react"; import StarterKit from "@tiptap/starter-kit"; import React, { useRef } from "react"; import { TextMenu } from "./menus/TextMenu"; import { cn } from "@usesend/ui/lib/utils"; import { extensions } from "./extensions"; import LinkMenu from "./menus/LinkMenu"; import { Content, Editor as TipTapEditor } from "@tiptap/core"; import { UploadFn } from "./extensions/ImageExtension"; const content = `

Hello World!

useSend is the best open source resend alternative.

Use markdown (# , ## , ### , \`\`, * *, ** **) to write your email.

You can Bold text. You can Italic text. You can Underline text. You can Delete text. You can Code text. you can change color of text. Add link to text


You can create ordered list
  1. Ordered list item
  2. Ordered list item
  3. Ordered list item

You can create unordered list

Add code by typing \`\`\` and enter


const usesend = new UseSend("us_12345");

// const usesend = new UseSend("us_12345", "https://app.usesend.com");

usesend.emails.send({
  to: "john@doe.com",
  from: "john@doe.com",
  subject: "Hello World!",
  html: "

Hello World!

", text: "Hello World!", });
`; export type EditorProps = { onUpdate?: (content: TipTapEditor) => void; initialContent?: Content; variables?: Array; uploadImage?: UploadFn; }; export const Editor: React.FC = ({ onUpdate, initialContent, variables, uploadImage, }) => { const menuContainerRef = useRef(null); const editor = useEditor({ editorProps: { attributes: { class: cn("unsend-prose w-full"), }, handleDOMEvents: { keydown: (_view, event) => { // prevent default event listeners from firing when slash command is active if (["ArrowUp", "ArrowDown", "Enter"].includes(event.key)) { const slashCommand = document.querySelector("#slash-command"); if (slashCommand) { return true; } } }, }, }, extensions: extensions({ variables, uploadImage }), onUpdate: ({ editor }) => { onUpdate?.(editor); }, content: initialContent, }); return (
{editor ? : null} {editor ? : null}
); };