Skip to content

Conversation

@AnishSarkar22
Copy link
Contributor

@AnishSarkar22 AnishSarkar22 commented Nov 23, 2025

Added BlockNote editor integration for document editing, enabling rich text editing with auto-save functionality. This PR introduces a new editor interface that allows users to edit documents directly in the browser using BlockNote's block-based editor, with support for dark/light themes and automatic saving every 30 seconds.

Description

This PR adds a complete BlockNote editor integration to SurfSense:

Frontend Changes:

  • Created BlockNoteEditor component using @blocknote/react and @blocknote/mantine with theme support
  • Implemented DynamicBlockNoteEditor wrapper for proper SSR handling
  • Updated editor page (/dashboard/[search_space_id]/editor/[documentId]) with:
    • BlockNote editor interface
    • Auto-save functionality (every 30 seconds)
    • Manual save & exit functionality
    • Unsaved changes tracking
    • Error handling for documents without BlockNote content

Backend Changes:

  • Added new API endpoints:
    • GET /api/v1/documents/{document_id}/editor-content - Fetches document content for editing
    • PUT /api/v1/documents/{document_id}/blocknote-content - Updates BlockNote document content
  • Database migration to add blocknote_document JSONB field to documents table
  • Updated all document processors to store BlockNote JSON when processing documents
  • Added BlockNote converter utilities for markdown conversion

Features:

  • Rich block-based text editing with BlockNote
  • Dark/light theme support with custom dark mode styling
  • Auto-save with visual feedback
  • Unsaved changes warning on navigation
  • Error handling for legacy documents

Motivation and Context

This change enables users to edit documents directly within SurfSense, providing a modern rich text editing experience. Previously, documents could only be viewed or re-uploaded. The BlockNote editor offers:

  • Better user experience with a modern, intuitive editing interface
  • Block-based editing that preserves document structure
  • Seamless integration with the existing document management system
  • Support for various content types (headings, paragraphs, lists, etc.)

Screenshots

SCR-20251123-omah

SCR-20251123-onwb

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR introduces a rich text editing capability to SurfSense by integrating the BlockNote editor. Users can now edit documents directly in the browser with a modern block-based interface. The implementation includes database schema changes to store BlockNote JSON documents, new API endpoints for fetching and saving editor content, and automatic conversion of markdown to BlockNote format during document processing. The frontend features a complete editor page with auto-save functionality every 30 seconds, theme support (dark/light), and unsaved changes tracking. All document processors have been updated to generate BlockNote-compatible content on upload, though legacy documents will require re-uploading to enable editing.

⏱️ Estimated Review Time: 3+ hours

💡 Review Order Suggestion
Order File Path
1 surfsense_backend/alembic/versions/38_add_blocknote_fields_to_documents.py
2 surfsense_backend/app/db.py
3 surfsense_backend/app/utils/blocknote_converter.py
4 surfsense_backend/app/routes/editor_routes.py
5 surfsense_backend/app/routes/__init__.py
6 surfsense_backend/app/tasks/document_processors/extension_processor.py
7 surfsense_backend/app/tasks/document_processors/file_processors.py
8 surfsense_backend/app/tasks/document_processors/markdown_processor.py
9 surfsense_backend/app/tasks/document_processors/url_crawler.py
10 surfsense_backend/app/tasks/document_processors/youtube_processor.py
11 surfsense_web/app/api/convert-to-blocknote/route.ts
12 surfsense_web/app/api/convert-to-markdown/route.ts
13 surfsense_web/components/BlockNoteEditor.tsx
14 surfsense_web/components/DynamicBlockNoteEditor.tsx
15 surfsense_web/app/dashboard/[search_space_id]/editor/[documentId]/page.tsx
16 surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/RowActions.tsx
17 surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsTableShell.tsx
18 surfsense_web/components/dashboard-breadcrumb.tsx
19 surfsense_web/messages/en.json
20 surfsense_web/messages/zh.json
21 surfsense_web/next.config.ts
22 surfsense_web/package.json
23 surfsense_web/pnpm-lock.yaml
⚠️ Inconsistent Changes Detected
File Path Warning
surfsense_web/next.config.ts Disabling React StrictMode (reactStrictMode: false) is a significant configuration change that affects the entire Next.js application beyond just the BlockNote editor feature. This could hide potential issues in other parts of the codebase and should be carefully considered.

Need help? Join our Discord

Analyze latest changes

@vercel
Copy link

vercel bot commented Nov 23, 2025

@AnishSarkar22 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@AnishSarkar22 AnishSarkar22 marked this pull request as ready for review November 23, 2025 11:03
Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 70f3381..abbaa84

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (23)

surfsense_backend/alembic/versions/38_add_blocknote_fields_to_documents.py
surfsense_backend/app/db.py
surfsense_backend/app/routes/__init__.py
surfsense_backend/app/routes/editor_routes.py
surfsense_backend/app/tasks/document_processors/extension_processor.py
surfsense_backend/app/tasks/document_processors/file_processors.py
surfsense_backend/app/tasks/document_processors/markdown_processor.py
surfsense_backend/app/tasks/document_processors/url_crawler.py
surfsense_backend/app/tasks/document_processors/youtube_processor.py
surfsense_backend/app/utils/blocknote_converter.py
surfsense_web/app/api/convert-to-blocknote/route.ts
surfsense_web/app/api/convert-to-markdown/route.ts
surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsTableShell.tsx
surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/RowActions.tsx
surfsense_web/app/dashboard/[search_space_id]/editor/[documentId]/page.tsx
surfsense_web/components/BlockNoteEditor.tsx
surfsense_web/components/DynamicBlockNoteEditor.tsx
surfsense_web/components/dashboard-breadcrumb.tsx
surfsense_web/messages/en.json
surfsense_web/messages/zh.json
surfsense_web/next.config.ts
surfsense_web/package.json
surfsense_web/pnpm-lock.yaml

@AnishSarkar22
Copy link
Contributor Author

@MODSetter I am unsure whether we should update documents with empty blocknote_content, e.g., for those documents which were uploaded before blocknote editor gets merged to the system. How should we handle them?

@AnishSarkar22 AnishSarkar22 changed the title Feature: BlockNote editor [Feature] Add BlockNote editor Nov 23, 2025
Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on abbaa84..289b4de

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (17)

surfsense_backend/alembic/versions/38_add_blocknote_fields_to_documents.py
surfsense_backend/app/db.py
surfsense_backend/app/routes/editor_routes.py
surfsense_backend/app/tasks/document_processors/extension_processor.py
surfsense_backend/app/tasks/document_processors/file_processors.py
surfsense_backend/app/tasks/document_processors/markdown_processor.py
surfsense_backend/app/tasks/document_processors/url_crawler.py
surfsense_backend/app/tasks/document_processors/youtube_processor.py
surfsense_backend/app/utils/blocknote_converter.py
surfsense_web/app/api/convert-to-blocknote/route.ts
surfsense_web/app/api/convert-to-markdown/route.ts
surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/RowActions.tsx
surfsense_web/app/dashboard/[search_space_id]/editor/[documentId]/page.tsx
surfsense_web/components/BlockNoteEditor.tsx
surfsense_web/components/DynamicBlockNoteEditor.tsx
surfsense_web/components/dashboard-breadcrumb.tsx
surfsense_web/next.config.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant