Skip to content

[WIKI-537] [WIKI-539] refactor: document editor#7384

Merged
sriramveeraghanta merged 11 commits intopreviewfrom
refactor/document-editor
Jul 25, 2025
Merged

[WIKI-537] [WIKI-539] refactor: document editor#7384
sriramveeraghanta merged 11 commits intopreviewfrom
refactor/document-editor

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Jul 10, 2025

Description

This PR refactors the document editor and its implementation in the web app in following ways-

  1. Replaced the document read only editor with a new document editor which can be toggled using the editor prop.
  2. Document editor can now accept the initialValue in any ProseMirror acceptable content format.
  3. Created a common document editor component which holds all the common logic and needs only a few props to initialize.
  4. For all document editors, JSON content is now the source of truth.
  5. Removed all unnecessary exports from the editor package.

Type of Change

  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring

Summary by CodeRabbit

  • New Features

    • Introduced a new, extensible Document Editor component with support for embedding, mentions, file uploads, and configurable extensions.
    • Exposed a ref API for advanced editor control.
  • Refactor

    • Simplified and unified editor exports and import paths for easier integration.
    • Replaced and removed legacy read-only editor components in favor of the new Document Editor.
    • Updated type definitions for editor content and props to improve consistency and flexibility.
    • Refined version editor to use the new Document Editor with simplified rendering and data handling.
  • Chores

    • Improved internal code organization and cleaned up obsolete files and exports.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 10, 2025

Walkthrough

This change unifies the document editor components by introducing a new DocumentEditor React component with both editable and read-only modes, removes separate read-only editor variants, and updates export paths and types accordingly. It also restructures related modules, types, and hooks to support the new architecture.

Changes

Files/Paths Change Summary
apps/web/core/components/editor/document/editor.tsx, packages/editor/src/core/components/editors/document/editor.tsx Added new DocumentEditor React component with editable and read-only support, integrating multiple hooks and handlers, and exposing a ref API.
apps/web/core/components/editor/index.ts, apps/web/core/components/editor/lite-text/index.ts, apps/web/core/components/editor/rich-text/index.ts Updated export paths for lite and rich text editors; added new index files for re-exports.
apps/web/core/components/editor/lite-text-editor/index.ts, apps/web/core/components/editor/rich-text-editor/index.ts Deleted old index files for lite and rich text editors, removing aggregation layers.
apps/web/core/components/inbox/modals/create-modal/issue-description.tsx Updated import path for RichTextEditor to new location.
apps/web/core/components/pages/version/editor.tsx Refactored to use the new DocumentEditor for rendering, removing old hooks and handlers, and simplifying logic.
packages/editor/src/ce/extensions/document-extensions.ts Extended TDocumentEditorAdditionalExtensionsProps type with isEditable property.
packages/editor/src/core/components/editors/document/index.ts Switched export from read-only-editor to new editor module.
packages/editor/src/core/components/editors/document/read-only-editor.tsx Deleted old read-only editor component and its forwardRef wrapper.
packages/editor/src/core/helpers/scroll-to-node.ts Disabled ESLint no-undef rule for a function, no logic changes.
packages/editor/src/core/hooks/use-editor.ts Changed editor content initialization to directly use initialValue without fallback.
packages/editor/src/core/types/editor.ts Updated types: added IDocumentEditorProps, removed IDocumentReadOnlyEditorProps, adjusted imports, and added ESLint comment.
packages/editor/src/core/types/hook.ts Changed initialValue type in TEditorHookProps from string to Content.
packages/editor/src/index.ts Changed export from DocumentReadOnlyEditorWithRef to DocumentEditorWithRef. Removed several unused exports related to read-only editor and editor commands.
packages/editor/src/core/hooks/use-editor-markings.ts(x) Deleted hook managing editor heading markings and related type IMarking.
packages/editor/src/core/types/config.ts Added new type IMarking representing heading markings.

Sequence Diagram(s)

sequenceDiagram
    participant ParentComponent
    participant DocumentEditor
    participant Hooks
    participant EditorInstance
    participant PageRenderer

    ParentComponent->>DocumentEditor: Render with props (editable/read-only)
    DocumentEditor->>Hooks: Fetch user, config, handlers, flags
    DocumentEditor->>EditorInstance: Initialize with extensions, handlers, value
    EditorInstance-->>DocumentEditor: Return editor instance
    DocumentEditor->>PageRenderer: Render with editor instance and config
Loading

Possibly related PRs

  • makeplane/plane#7241: Refactors to unify editable and read-only editors under a single component.
  • makeplane/plane#7158: Expands and refactors document editor extension types, closely related to the new editor's extension system.
  • makeplane/plane#7233: Refactors editor prop types and extension props, aligning with changes in this PR.

Suggested labels

ready to merge

Suggested reviewers

  • Palanikannan1437
  • prateekshourya29

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

Hopping through the code so bright,
Editors unified, what a sight!
Old read-only ways now gone,
One true editor hops along.
Types and hooks in tidy rows—
In this garden, progress grows!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c323104 and cf55131.

📒 Files selected for processing (1)
  • packages/editor/src/core/hooks/use-editor.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/editor/src/core/hooks/use-editor.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build-and-lint
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/document-editor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@makeplane
Copy link

makeplane bot commented Jul 10, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
packages/editor/src/core/helpers/scroll-to-node.ts (1)

35-35: Consider adding proper type imports instead of disabling ESLint.

The no-undef ESLint rule is being disabled, likely due to the ScrollBehavior type not being recognized. Consider importing the type explicitly or ensuring proper TypeScript DOM types are available.

+/// <reference lib="dom" />
+
-// eslint-disable-next-line no-undef
export function scrollToNodeViaDOMCoordinates(editor: Editor, pos: number, behavior?: ScrollBehavior): void {

Alternatively, if the type is still not recognized, you can define it explicitly:

+type ScrollBehavior = "auto" | "smooth" | "instant";
+
-// eslint-disable-next-line no-undef
export function scrollToNodeViaDOMCoordinates(editor: Editor, pos: number, behavior?: ScrollBehavior): void {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e75ff7 and cee28b1.

📒 Files selected for processing (17)
  • apps/web/core/components/editor/document/editor.tsx (1 hunks)
  • apps/web/core/components/editor/index.ts (1 hunks)
  • apps/web/core/components/editor/lite-text-editor/index.ts (0 hunks)
  • apps/web/core/components/editor/lite-text/index.ts (1 hunks)
  • apps/web/core/components/editor/rich-text-editor/index.ts (0 hunks)
  • apps/web/core/components/editor/rich-text/index.ts (1 hunks)
  • apps/web/core/components/inbox/modals/create-modal/issue-description.tsx (1 hunks)
  • apps/web/core/components/pages/version/editor.tsx (2 hunks)
  • packages/editor/src/ce/extensions/document-extensions.tsx (1 hunks)
  • packages/editor/src/core/components/editors/document/editor.tsx (1 hunks)
  • packages/editor/src/core/components/editors/document/index.ts (1 hunks)
  • packages/editor/src/core/components/editors/document/read-only-editor.tsx (0 hunks)
  • packages/editor/src/core/helpers/scroll-to-node.ts (1 hunks)
  • packages/editor/src/core/hooks/use-editor.ts (1 hunks)
  • packages/editor/src/core/types/editor.ts (3 hunks)
  • packages/editor/src/core/types/hook.ts (2 hunks)
  • packages/editor/src/index.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • apps/web/core/components/editor/lite-text-editor/index.ts
  • apps/web/core/components/editor/rich-text-editor/index.ts
  • packages/editor/src/core/components/editors/document/read-only-editor.tsx
🧰 Additional context used
🧠 Learnings (3)
apps/web/core/components/inbox/modals/create-modal/issue-description.tsx (3)
Learnt from: mathalav55
PR: makeplane/plane#6107
File: web/ce/components/workspace-notifications/sidebar/notification-card/options/archive.tsx:11-14
Timestamp: 2024-11-28T07:02:54.664Z
Learning: When components are still located in `core`, it's appropriate for files to import them using `@/components/...`, and the migration to the new import paths is not necessary in such cases.
Learnt from: mathalav55
PR: makeplane/plane#6107
File: web/ce/components/workspace-notifications/sidebar/notification-card/options/read.tsx:11-12
Timestamp: 2024-11-28T07:02:15.514Z
Learning: Some components are still in core and have not been moved yet, so their import paths remain the same.
Learnt from: vamsikrishnamathala
PR: makeplane/plane#7061
File: web/core/components/workspace-notifications/root.tsx:18-18
Timestamp: 2025-05-14T13:16:23.323Z
Learning: In the Plane project codebase, the path alias `@/plane-web` resolves to the `ce` directory, making imports like `@/plane-web/hooks/use-notification-preview` correctly resolve to files in `web/ce/hooks/`.
apps/web/core/components/editor/index.ts (2)
Learnt from: mathalav55
PR: makeplane/plane#6107
File: web/ce/components/workspace-notifications/sidebar/notification-card/options/read.tsx:11-12
Timestamp: 2024-11-28T07:02:15.514Z
Learning: Some components are still in core and have not been moved yet, so their import paths remain the same.
Learnt from: mathalav55
PR: makeplane/plane#6107
File: web/ce/components/workspace-notifications/sidebar/notification-card/options/archive.tsx:11-14
Timestamp: 2024-11-28T07:02:54.664Z
Learning: When components are still located in `core`, it's appropriate for files to import them using `@/components/...`, and the migration to the new import paths is not necessary in such cases.
apps/web/core/components/pages/version/editor.tsx (1)
Learnt from: vamsikrishnamathala
PR: makeplane/plane#7061
File: web/core/components/workspace-notifications/root.tsx:18-18
Timestamp: 2025-05-14T13:16:23.323Z
Learning: In the Plane project codebase, the path alias `@/plane-web` resolves to the `ce` directory, making imports like `@/plane-web/hooks/use-notification-preview` correctly resolve to files in `web/ce/hooks/`.
🧬 Code Graph Analysis (3)
apps/web/core/components/pages/version/editor.tsx (1)
apps/web/core/components/editor/document/editor.tsx (1)
  • DocumentEditor (34-90)
packages/editor/src/core/types/editor.ts (2)
packages/editor/src/core/types/ai.ts (1)
  • TAIHandler (6-8)
packages/editor/src/core/types/config.ts (1)
  • TUserDetails (38-43)
apps/web/core/components/editor/document/editor.tsx (3)
packages/editor/src/core/types/editor.ts (2)
  • IDocumentEditorProps (163-169)
  • EditorRefApi (101-119)
packages/editor/src/core/types/config.ts (1)
  • TFileHandler (11-23)
packages/utils/src/common.ts (1)
  • cn (8-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (21)
apps/web/core/components/editor/lite-text/index.ts (1)

1-3: LGTM! Clean aggregator pattern.

The re-export structure follows good practices for creating a single entry point for the lite-text editor components.

apps/web/core/components/inbox/modals/create-modal/issue-description.tsx (1)

13-13: Import path validated

The import "@/components/editor/rich-text/editor" correctly resolves to apps/web/core/components/editor/rich-text/editor.tsx, which exports RichTextEditor. No further changes are needed.

apps/web/core/components/editor/rich-text/index.ts (1)

1-1: LGTM! Simple and clean export aggregator.

The export structure is clean and follows the refactoring pattern described in the PR objectives.

packages/editor/src/ce/extensions/document-extensions.tsx (1)

14-14: Good addition to support unified editor approach.

The isEditable property addition aligns well with the refactoring to use a single DocumentEditor component that supports both editable and read-only modes via props.

packages/editor/src/core/components/editors/document/index.ts (1)

2-2: DocumentEditor export verified

The editor.tsx file defines DocumentEditorWithRef and exports it as a named export. The index.ts file’s export * from "./editor" now correctly re-exports this component.

No further changes required.

packages/editor/src/core/types/hook.ts (1)

2-2: Good import addition for Content type.

The import of Content type from @tiptap/core is appropriate for the type system updates.

packages/editor/src/core/hooks/use-editor.ts (1)

73-73: TipTap handles undefined initialValue safely by default

We’ve confirmed that when content is undefined, TipTap initializes as an empty document without throwing errors. Removing the old fallback logic in packages/editor/src/core/hooks/use-editor.ts (line 73) is safe under the default configuration.

• No changes required in use-editor.ts for handling undefined
• If you need strict schema validation, consider enabling enableContentCheck and handling the contentError event in your Editor config

apps/web/core/components/editor/index.ts (1)

2-2: Confirmed export paths and contents
Both lite-text and rich-text directories exist under apps/web/core/components/editor/ and their index.ts files correctly re-export the expected modules:

  • apps/web/core/components/editor/lite-text/index.ts exports:
    • ./editor
    • ./read-only-editor
    • ./toolbar
  • apps/web/core/components/editor/rich-text/index.ts exports:
    • ./editor

No further changes are needed.

packages/editor/src/core/types/editor.ts (2)

1-2: Good optimization with type-only imports.

Converting to import type for Extensions, JSONContent, and Selection is a good practice that can help with bundle optimization by ensuring these imports are only used for type checking and not included in the runtime bundle.


163-169: Well-designed interface for the new unified document editor.

The IDocumentEditorProps interface is well-structured, extending from IEditorProps while omitting properties that are not needed (initialValue, onEnterKeyPress) and adding new capabilities (aiHandler, embedHandler, user). The required editable prop enables the unified editor to work in both read-only and editable modes.

The change from string to Content type for the value prop aligns with TipTap's type system and should provide better type safety.

apps/web/core/components/pages/version/editor.tsx (4)

4-4: Import optimization aligns with type changes.

Good change to only import TDisplayConfig from @plane/editor since the component no longer needs direct access to the editor implementation types.


8-8: Correct import path for the new document editor.

The import path change to use the local wrapper component is correct and follows the refactoring pattern where complex editor logic is encapsulated in the wrapper.


81-92: Proper component usage with simplified props.

The refactoring correctly:

  • Uses DocumentEditor instead of DocumentReadOnlyEditorWithRef
  • Sets editable={false} for read-only mode
  • Passes value as JSON content instead of HTML
  • Includes key prop for proper re-rendering when version changes
  • Maintains essential props like displayConfig and styling

The simplified prop structure delegates complex configuration to the wrapper component, which is a good separation of concerns.


77-78: Verify description_json handling and structure

The TPageVersion.description_json field is typed as object | null | undefined, so the check

const description = versionDetails?.description_json;
if (!description) return null;

correctly guards against missing or null content. Please verify that the JSON payload conforms to the expected schema—consider defining a more specific TypeScript interface or adding runtime validation to enforce its structure.

– packages/types/src/page/core.ts (TPageVersion description_json?: object)
– apps/web/core/components/pages/version/editor.tsx (null check at lines 77–78)

packages/editor/src/core/components/editors/document/editor.tsx (2)

70-84: Proper editor initialization with updated hook usage.

The useEditor hook is called with appropriate parameters, including the new Content type for initialValue. The parameter mapping is correct and maintains backward compatibility.


103-105: Correct forwardRef implementation.

The forwardRef wrapper properly forwards the ref to the internal component while maintaining type safety with EditorRefApi.

apps/web/core/components/editor/document/editor.tsx (5)

15-32: Excellent type design with discriminated union.

The DocumentEditorWrapperProps type is well-designed using a discriminated union to ensure that editable editors require searchMentionCallback and uploadFile props, while read-only editors don't. This provides compile-time safety and prevents runtime errors.


50-52: Proper conditional logic for mention search.

The conditional setup for searchEntity correctly handles both editable and read-only modes, providing an empty object for read-only mode and the actual search callback for editable mode.


67-72: Good conditional file handler configuration.

The file handler setup properly handles the editable vs read-only distinction by providing either the actual upload function or an empty async function. This prevents errors while maintaining the expected interface.


74-77: Appropriate error handling for mention search.

The error handling in the mention search callback is good - it throws an error when fetchMentions fails, which will be caught by the editor's error boundary or handled appropriately by the consuming code.


82-84: Proper embed handler merging.

The embed handler configuration correctly merges the issue embed props with any additional embed handlers passed via props, providing a flexible extension mechanism.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e75ff7 and cee28b1.

📒 Files selected for processing (17)
  • apps/web/core/components/editor/document/editor.tsx (1 hunks)
  • apps/web/core/components/editor/index.ts (1 hunks)
  • apps/web/core/components/editor/lite-text-editor/index.ts (0 hunks)
  • apps/web/core/components/editor/lite-text/index.ts (1 hunks)
  • apps/web/core/components/editor/rich-text-editor/index.ts (0 hunks)
  • apps/web/core/components/editor/rich-text/index.ts (1 hunks)
  • apps/web/core/components/inbox/modals/create-modal/issue-description.tsx (1 hunks)
  • apps/web/core/components/pages/version/editor.tsx (2 hunks)
  • packages/editor/src/ce/extensions/document-extensions.tsx (1 hunks)
  • packages/editor/src/core/components/editors/document/editor.tsx (1 hunks)
  • packages/editor/src/core/components/editors/document/index.ts (1 hunks)
  • packages/editor/src/core/components/editors/document/read-only-editor.tsx (0 hunks)
  • packages/editor/src/core/helpers/scroll-to-node.ts (1 hunks)
  • packages/editor/src/core/hooks/use-editor.ts (1 hunks)
  • packages/editor/src/core/types/editor.ts (3 hunks)
  • packages/editor/src/core/types/hook.ts (2 hunks)
  • packages/editor/src/index.ts (1 hunks)
💤 Files with no reviewable changes (3)
  • apps/web/core/components/editor/rich-text-editor/index.ts
  • apps/web/core/components/editor/lite-text-editor/index.ts
  • packages/editor/src/core/components/editors/document/read-only-editor.tsx
🧰 Additional context used
🧠 Learnings (3)
apps/web/core/components/inbox/modals/create-modal/issue-description.tsx (3)
Learnt from: mathalav55
PR: makeplane/plane#6107
File: web/ce/components/workspace-notifications/sidebar/notification-card/options/archive.tsx:11-14
Timestamp: 2024-11-28T07:02:54.664Z
Learning: When components are still located in `core`, it's appropriate for files to import them using `@/components/...`, and the migration to the new import paths is not necessary in such cases.
Learnt from: mathalav55
PR: makeplane/plane#6107
File: web/ce/components/workspace-notifications/sidebar/notification-card/options/read.tsx:11-12
Timestamp: 2024-11-28T07:02:15.514Z
Learning: Some components are still in core and have not been moved yet, so their import paths remain the same.
Learnt from: vamsikrishnamathala
PR: makeplane/plane#7061
File: web/core/components/workspace-notifications/root.tsx:18-18
Timestamp: 2025-05-14T13:16:23.323Z
Learning: In the Plane project codebase, the path alias `@/plane-web` resolves to the `ce` directory, making imports like `@/plane-web/hooks/use-notification-preview` correctly resolve to files in `web/ce/hooks/`.
apps/web/core/components/editor/index.ts (3)
Learnt from: mathalav55
PR: makeplane/plane#6107
File: web/ce/components/workspace-notifications/sidebar/notification-card/options/read.tsx:11-12
Timestamp: 2024-11-28T07:02:15.514Z
Learning: Some components are still in core and have not been moved yet, so their import paths remain the same.
Learnt from: mathalav55
PR: makeplane/plane#6107
File: web/ce/components/workspace-notifications/sidebar/notification-card/options/archive.tsx:11-14
Timestamp: 2024-11-28T07:02:54.664Z
Learning: When components are still located in `core`, it's appropriate for files to import them using `@/components/...`, and the migration to the new import paths is not necessary in such cases.
Learnt from: lifeiscontent
PR: makeplane/plane#7164
File: packages/ui/.storybook/main.ts:24-47
Timestamp: 2025-06-04T16:22:44.344Z
Learning: In packages/ui/.storybook/main.ts, the webpackFinal function intentionally overrides the CSS loader strategy by finding and replacing existing CSS rules. This is a temporary workaround for a known upstream issue in Storybook's CSS handling that has been communicated to the Storybook maintainers. The current implementation should not be changed until the upstream issue is resolved.
apps/web/core/components/pages/version/editor.tsx (1)
Learnt from: vamsikrishnamathala
PR: makeplane/plane#7061
File: web/core/components/workspace-notifications/root.tsx:18-18
Timestamp: 2025-05-14T13:16:23.323Z
Learning: In the Plane project codebase, the path alias `@/plane-web` resolves to the `ce` directory, making imports like `@/plane-web/hooks/use-notification-preview` correctly resolve to files in `web/ce/hooks/`.
🧬 Code Graph Analysis (3)
apps/web/core/components/editor/document/editor.tsx (3)
packages/editor/src/core/types/editor.ts (2)
  • IDocumentEditorProps (163-169)
  • EditorRefApi (101-119)
packages/editor/src/core/types/config.ts (1)
  • TFileHandler (11-23)
packages/utils/src/common.ts (1)
  • cn (8-8)
packages/editor/src/core/components/editors/document/editor.tsx (10)
apps/web/core/components/editor/document/editor.tsx (1)
  • DocumentEditor (34-90)
packages/editor/src/core/types/editor.ts (2)
  • IDocumentEditorProps (163-169)
  • EditorRefApi (101-119)
packages/editor/src/core/constants/config.ts (1)
  • DEFAULT_DISPLAY_CONFIG (4-9)
packages/editor/src/core/extensions/work-item-embed/extension.tsx (1)
  • WorkItemEmbedExtension (17-30)
packages/editor/src/core/extensions/side-menu.ts (1)
  • SideMenuExtension (34-52)
packages/editor/src/ce/extensions/document-extensions.tsx (1)
  • DocumentEditorAdditionalExtensions (32-40)
packages/editor/src/core/hooks/use-editor.ts (1)
  • useEditor (22-282)
packages/editor/src/core/helpers/common.ts (1)
  • getEditorClassNames (13-21)
packages/editor/src/core/components/editors/document/page-renderer.tsx (1)
  • PageRenderer (21-52)
packages/utils/src/common.ts (1)
  • cn (8-8)
packages/editor/src/core/types/editor.ts (2)
packages/editor/src/core/types/ai.ts (1)
  • TAIHandler (6-8)
packages/editor/src/core/types/config.ts (1)
  • TUserDetails (38-43)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (19)
apps/web/core/components/inbox/modals/create-modal/issue-description.tsx (1)

13-13: LGTM: Import path correctly updated.

The import path change from rich-text-editor/rich-text-editor to rich-text/editor aligns with the document editor refactoring objectives and maintains the same functionality.

apps/web/core/components/editor/rich-text/index.ts (1)

1-1: LGTM: Clean aggregation module.

The re-export pattern creates a clean entry point for the rich-text editor module, supporting the refactoring objectives to simplify the module structure.

packages/editor/src/core/helpers/scroll-to-node.ts (1)

35-35: LGTM: Appropriate ESLint suppression.

The ESLint disable comment is necessary to suppress warnings about the ScrollBehavior type, which is a valid DOM API type that ESLint may not recognize.

packages/editor/src/index.ts (1)

12-12: ✅ No remaining references to DocumentReadOnlyEditorWithRef; all imports now use DocumentEditorWithRef

Verified that the old DocumentReadOnlyEditorWithRef is entirely gone and replaced by DocumentEditorWithRef in all usage sites:

  • packages/editor/src/index.ts
  • packages/editor/src/core/components/editors/document/editor.tsx
  • apps/web/core/components/editor/document/editor.tsx
  • apps/web/core/components/pages/editor/editor-body.tsx

All looks good to merge.

apps/web/core/components/editor/lite-text/index.ts (1)

1-3: LGTM: Well-structured module aggregation.

The re-export pattern creates a clean entry point for the lite-text editor modules, maintaining separation between editor and read-only variants while simplifying the overall module structure.

packages/editor/src/core/types/hook.ts (2)

2-2: Import addition for Content type is appropriate.

Adding the Content type import from @tiptap/core supports the more structured content handling approach.


31-31: No external consumers of TEditorHookProps—change is safe to merge

A search for TEditorHookProps only returned its import in packages/editor/src/core/hooks/use-editor.ts, and there are no other direct imports of this type elsewhere in the repo. All calls to useEditor(…) live within the packages/editor package and already pass the updated Content-typed initialValue.

• packages/editor/src/core/hooks/use-editor.ts – only definition/import of TEditorHookProps
• Internal calls in packages/editor/src/core/components/editors/* all use the new initialValue?: Content shape

No further updates are required.

packages/editor/src/core/hooks/use-editor.ts (1)

73-73: All useEditor invocations supply initialValue—no undefined content risk

  • Ripgrep scan found every call to useEditor({ … }) includes an initialValue prop.
  • The read-only editor hook still guards against undefined/falsy values with its own fallback.

No further action required.

apps/web/core/components/pages/version/editor.tsx (3)

4-11: Good refactoring of imports!

The changes properly align with the new DocumentEditor architecture, moving editor-specific hooks into the component wrapper for better encapsulation.


77-78: Correct migration to JSON content format.

The change aligns with the PR objective of establishing JSON as the source of truth for document editors.


81-92: Proper implementation of the new DocumentEditor component.

The component is correctly configured for read-only mode with all necessary workspace and project identifiers.

packages/editor/src/core/types/editor.ts (3)

1-2: Good use of type-only imports.

Using import type for TypeScript types improves bundle size and prevents potential circular dependency issues.


114-115: ESLint disable comment is appropriate.

The ScrollBehavior type from the DOM API may not be recognized by ESLint in certain configurations, making this disable comment necessary.


163-169: Well-designed interface for the new DocumentEditor.

The interface properly extends IEditorProps while updating the value type to Content for ProseMirror compatibility, aligning with the PR objectives.

apps/web/core/components/editor/document/editor.tsx (3)

15-32: Excellent type-safe prop definitions.

The discriminated union pattern ensures that searchMentionCallback and uploadFile are only required when the editor is editable, providing strong type safety.


46-59: Well-organized hook integration.

The hooks are properly composed to gather all necessary editor configuration, with appropriate conditional logic for the editable state.


61-90: Clean and well-structured component implementation.

The component properly composes all hooks and handlers, with appropriate error handling for mention searches and conditional file upload based on editability.

packages/editor/src/core/components/editors/document/editor.tsx (2)

70-84: Proper editor initialization.

The editor is correctly initialized with all necessary configuration props.


86-109: Well-structured component with proper ref forwarding.

The component correctly handles the editor lifecycle with null checking and implements forwardRef pattern appropriately.

Comment on lines 89 to 91
projectId={projectId?.toString() ?? ""}
workspaceId={workspaceDetails?.id ?? ""}
workspaceSlug={workspaceSlug?.toString() ?? ""}
Copy link
Collaborator

Choose a reason for hiding this comment

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

just a preference, but personally, I think this reads better.

e.g. data -> transforms to a string.

Suggested change
projectId={projectId?.toString() ?? ""}
workspaceId={workspaceDetails?.id ?? ""}
workspaceSlug={workspaceSlug?.toString() ?? ""}
projectId={String(projectId ?? "")}
workspaceId={String(workspaceDetails ?? "")}
workspaceSlug={String(workspaceSlug ?? "")}

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer not using String() as it even converts values like null and undefined to "null" and "undefined" respectively.

@sriramveeraghanta sriramveeraghanta merged commit 27f7420 into preview Jul 25, 2025
5 of 7 checks passed
@sriramveeraghanta sriramveeraghanta deleted the refactor/document-editor branch July 25, 2025 08:27
@aaryan610 aaryan610 changed the title [WIKI-537] refactor: document editor [WIKI-537] [WIKI-539] refactor: document editor Jul 25, 2025
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* refactor: document editor

* chore: update user prop

* fix: type warning

* chore: update value prop name

* chore: remove unnecessary exports

* hore: update initialValue type

* chore: revert initialValue type

* refactor: unnecessary string handlers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants