Skip to content

mrsamvu/tiptap-nextjs

Repository files navigation

Tiptap Editor - Next.js + Supabase

A Rich Text Editor application built with Next.js and Tiptap, integrated with Supabase for content and image storage.

🔗 Demo: https://tiptap-nextjs.vercel.app/

Note: Since only one record is used to store content on Supabase, if multiple people test and save simultaneously, the content on the /posts page may become inconsistent. It's best to clone the code and run it locally with your own Supabase instance.

✨ Features

  • 📝 Rich text editor with essential features
  • 🖼️ Upload and store images via Supabase Storage
  • 💾 Store article content in Supabase Database
  • ⌨️ Support for multiple keyboard shortcuts and markdown shortcuts

🚀 Installation

1. Clone repository

git clone <repository-url>
cd <project-folder>

2. Install dependencies

yarn install

3. Configure Supabase

Create documents table to store content

Access Supabase Dashboard > SQL Editor and run the following script:

CREATE TABLE public.documents (
  id bigint GENERATED ALWAYS AS IDENTITY NOT NULL,
  created_at timestamp with time zone NOT NULL DEFAULT now(),
  content json,
  CONSTRAINT documents_pkey PRIMARY KEY (id)
);

ALTER TABLE documents
ALTER COLUMN id
SET GENERATED BY DEFAULT;

Note: Enable Row Level Security (RLS) policies for the documents table to allow data storage.

Create Storage bucket to store images

  1. Access Supabase Dashboard > Storage
  2. Create a new bucket named uploads
  3. Run the following script in SQL Editor to configure policies:
-- Allow upload to 'uploads' bucket
CREATE POLICY "Public can upload to uploads"
ON storage.objects
FOR INSERT
TO public
WITH CHECK (bucket_id = 'uploads');

-- Allow reading files in 'uploads' bucket
CREATE POLICY "Public can read uploads"
ON storage.objects
FOR SELECT
TO public
USING (bucket_id = 'uploads');

-- Allow updating files
CREATE POLICY "Public can update uploads"
ON storage.objects
FOR UPDATE
TO public
USING (bucket_id = 'uploads')
WITH CHECK (bucket_id = 'uploads');

4. Configure environment variables

Copy the .env.example file to .env:

cp .env.example .env

Update the values in the .env file:

NEXT_PUBLIC_SUPABASE_URL=your-supabase-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key

Get the information from: Supabase Dashboard > Project Settings > API

🏃‍♂️ Running the application

Development mode

yarn dev

The application will run at: http://localhost:3000

Production mode

yarn build
yarn start

⌨️ Keyboard Shortcuts and Markdown Shortcuts

Code Block

  • Keyboard shortcut: Ctrl + Alt + C
  • Markdown: Type ```<language-name> in the editor
    • Example: ```javascript

Text Formatting

  • Bold: Ctrl + B
  • Italic: Ctrl + I
  • Underline: Ctrl + U
  • Strike: Ctrl + Shift + X

Lists

  • Bullet List:

    • Ctrl + Shift + 8
    • Or type * + space
    • Or type - + space
  • Numbered List: Type 1. + space (or any number)

  • Task List:

    • Type [x] + space (checked)
    • Type [ ] + space (unchecked)

Headings

Type # + space for heading levels:

  • # + space → Heading 1
  • ## + space → Heading 2
  • ### + space → Heading 3
  • #### + space → Heading 4
  • ##### + space → Heading 5
  • ###### + space → Heading 6

Block Quote

Type > + space

Move item

Hold Alt + up / down

Embed Media

Supports embedding from platforms:

  • YouTube
  • Vimeo
  • SoundCloud
  • Spotify

Usage: Copy the link from the platforms above and paste directly into the editor

🛠️ Technologies used

  • Next.js - React framework
  • Tiptap - Rich text editor framework
  • Supabase - Backend as a Service (Database + Storage)
  • TypeScript - Type safety
  • Tailwind CSS - Styling

📝 Notes

  • Image uploads are automatically saved to Supabase Storage bucket uploads
  • Article content is stored as JSON in the documents table

🤝 Contributing

All contributions are welcome! Please create an issue or pull request.

📄 License

MIT License

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published