Skip to content

Epic/rich editor#939

Merged
codenem merged 69 commits intomainfrom
epic/rich-editor
Apr 1, 2026
Merged

Epic/rich editor#939
codenem merged 69 commits intomainfrom
epic/rich-editor

Conversation

@codenem
Copy link
Copy Markdown
Contributor

@codenem codenem commented Mar 26, 2026

Closes ENG-208

Summary by cubic

Adds a TipTap-based rich text editor and moves document content to ProseMirror JSON end‑to‑end, with autosave and PDF rendering. Adds a migration CLI and fixes dry‑run behavior.

  • New Features

    • New RichEditor in @probo/ui using @tiptap/react, @floating-ui/react, and @phosphor-icons/react: slash “/” menu; side block and options menus; link bubble with URL input and Cmd/Ctrl+click; full‑height layout with caret/scroll fixes and no focus outline; bubble menu improvements.
    • Advanced tables: row/column/cell menus with drag reorder, split/merge cells, header rows/cols, and a selection overlay.
    • Mermaid code blocks with preview.
    • Autosave/publish: 1s debounced autosave with first‑render fix and error toasts; editor is read‑only for non‑draft versions with placeholders hidden.
    • Console: description page now uses RichEditor; removed Update Version dialog; versions menu uses Relay connections; draft create/delete flow fixed.
    • Backend: content persisted as ProseMirror JSON with validation and sanitization on save; new updateDocumentVersionContent GraphQL mutation; pkg/prosemirror adds JSON→HTML and Markdown/HTML→ProseMirror (sanitized); docgen renders PDFs from sanitized ProseMirror HTML; migrate-document-versions-markdown CLI for data migration (dry‑run fixed).
  • Migration

    • GraphQL: use updateDocumentVersionContent(input) to save drafts. CreateDocumentInput.content is now optional; when provided, send ProseMirror JSON.
    • Data: migrate legacy Markdown to ProseMirror JSON with the migrate-document-versions-markdown command; supports dry‑run.

Written for commit 3008eec. Summary will update on new commits.

@codenem codenem force-pushed the epic/rich-editor branch 4 times, most recently from 50111df to b45d343 Compare April 1, 2026 06:30
codenem added 26 commits April 1, 2026 18:03
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
…ctrl or cmd

Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
codenem added 12 commits April 1, 2026 18:03
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
…rgets

Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
@codenem codenem force-pushed the epic/rich-editor branch from 71b3bc5 to a03a2de Compare April 1, 2026 14:03
codenem added 8 commits April 1, 2026 18:04
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
Signed-off-by: Émile Ré <emile@getprobo.com>
@codenem codenem marked this pull request as ready for review April 1, 2026 14:54
@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented Apr 1, 2026

@cubic-dev-ai pls review

@codenem I have started the AI code review. It will take a few minutes to complete.

Signed-off-by: Émile Ré <emile@getprobo.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

14 issues found across 84 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="pkg/prosemirror/markdown.go">

<violation number="1" location="pkg/prosemirror/markdown.go:63">
P2: Image alt text extraction ignores nested inline nodes, so formatted alt text is partially dropped.</violation>
</file>

<file name="packages/ui/src/RichEditor/RichEditor.tsx">

<violation number="1" location="packages/ui/src/RichEditor/RichEditor.tsx:100">
P2: `JSON.parse(content)` is unguarded and can crash the editor on invalid content. Parse defensively and fall back to empty content.</violation>
</file>

<file name="packages/ui/src/RichEditor/LinkExtension.ts">

<violation number="1" location="packages/ui/src/RichEditor/LinkExtension.ts:19">
P2: `pointer-on-hovered-link` can get stuck because cleanup only happens on editor `keyup`. Add blur cleanup so focus loss always removes the class.</violation>
</file>

<file name="packages/ui/src/RichEditor/TableRowMenu/TableRowMenuContent.tsx">

<violation number="1" location="packages/ui/src/RichEditor/TableRowMenu/TableRowMenuContent.tsx:215">
P2: This dispatches two separate transactions (set selection, then delete), creating two undo-history entries for a single "clear contents" action. Use `editor.chain().focus().command(...)` to batch both into one transaction, consistent with the other handlers in this file.</violation>
</file>

<file name="pkg/validator/validator_prosemirror.go">

<violation number="1" location="pkg/validator/validator_prosemirror.go:28">
P2: Handle nil values before type assertion so optional fields don’t fail with an invalid-format error.</violation>
</file>

<file name="packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenu.tsx">

<violation number="1" location="packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenu.tsx:77">
P2: Validate `fromCol`/`toCol` bounds before splicing; otherwise an out-of-range index can insert `undefined` and crash table reconstruction.</violation>

<violation number="2" location="packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenu.tsx:77">
P1: Column reordering is index-based per row and does not account for merged cells, so moving columns can corrupt or misorder tables with colspan/rowspan.</violation>
</file>

<file name="apps/console/src/pages/organizations/documents/_components/CreateDocumentDialog.tsx">

<violation number="1" location="apps/console/src/pages/organizations/documents/_components/CreateDocumentDialog.tsx:69">
P1: `approverIds` is required in the new form schema, but this dialog has no `approverIds` input, so submit validation will fail and block document creation.</violation>
</file>

<file name="packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenuContent.tsx">

<violation number="1" location="packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenuContent.tsx:132">
P2: Merged/spanning cells are duplicated multiple times. `TableMap.map` reuses the same cell position for every row a merged cell spans, so iterating all rows inserts that cell once per spanned row. Track seen offsets to skip duplicates.</violation>

<violation number="2" location="packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenuContent.tsx:217">
P2: Two separate dispatches create two undo steps. Combine the selection-set and delete into a single transaction so Ctrl+Z undoes the clear in one step.</violation>
</file>

<file name="packages/ui/src/RichEditor/TableRowMenu/TableRowMenu.tsx">

<violation number="1" location="packages/ui/src/RichEditor/TableRowMenu/TableRowMenu.tsx:75">
P1: Validate `fromRow`/`toRow` before splicing to prevent inserting an undefined row and creating an invalid ProseMirror table.</violation>
</file>

<file name="pkg/prosemirror/html.go">

<violation number="1" location="pkg/prosemirror/html.go:103">
P1: Image `src` is emitted without URL-scheme sanitization, allowing untrusted document JSON to force external fetches during PDF rendering.</violation>

<violation number="2" location="pkg/prosemirror/html.go:282">
P2: `target="_blank"` links can still omit `noopener` when a custom `rel` is present, leaving opener protection bypassed.</violation>
</file>

<file name="pkg/probo/document_service.go">

<violation number="1" location="pkg/probo/document_service.go:156">
P2: `UpdateVersion` now enforces `content` as required, but GraphQL/MCP inputs still define it as optional, causing classification-only updates to fail with validation errors.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenu.tsx
Comment thread packages/ui/src/RichEditor/TableRowMenu/TableRowMenu.tsx
Comment thread pkg/prosemirror/html.go Outdated
Comment thread pkg/prosemirror/markdown.go
Comment thread packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenu.tsx
Comment thread packages/ui/src/RichEditor/TableColumnMenu/TableColumnMenuContent.tsx Outdated
Comment thread pkg/prosemirror/html.go
Comment thread pkg/probo/document_service.go Outdated
Signed-off-by: Émile Ré <emile@getprobo.com>
@codenem codenem force-pushed the epic/rich-editor branch from dfe034f to 821f66c Compare April 1, 2026 15:53
Signed-off-by: Émile Ré <emile@getprobo.com>
@codenem codenem merged commit 3008eec into main Apr 1, 2026
12 checks passed
@codenem codenem deleted the epic/rich-editor branch April 1, 2026 16:16
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