Skip to content

Conversation

aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Aug 7, 2025

Description

This PR refactors the editor core without props by-

  1. Renaming core without props to parser kit.
  2. Combining core without props and document without props.
  3. Combining editor based(separate for document and rich text) utility functions into one.
  4. Making function signatures consistent.

Type of Change

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

Summary by CodeRabbit

  • Refactor

    • Unified and simplified document conversion so all content formats are handled by a single parser.
    • Streamlined editor extension setup by removing some deprecated extension integrations.
  • Bug Fixes

    • More reliable and consistent conversions between HTML, binary, and JSON document formats.
  • Chores

    • Removed deprecated/unused conversion helpers and extension code for a leaner codebase.

Copy link
Contributor

coderabbitai bot commented Aug 7, 2025

Walkthrough

Removed variant-specific document conversion helpers and work-item embed extensions; consolidated document conversion into a single parser-kit/schema and switched callers to externalized conversion helpers. Updated imports and function signatures across server, web, and editor packages; deleted several extension files and simplified editor extension composition.

Changes

Cohort / File(s) Change Summary
Deleted local conversion helpers
apps/live/src/core/helpers/convert-document.ts, apps/live/src/core/helpers/page.ts
Removed local helpers that converted HTML ↔ Yjs/ProseMirror/encoded formats.
Server & caller updates
apps/live/src/server.ts, apps/live/src/core/lib/page.ts, apps/web/core/hooks/use-page-fallback.ts, packages/editor/src/core/helpers/parser.ts
Replaced local conversion calls with external @plane/editor/lib helpers; updated argument shapes (use { descriptionHTML } / { descriptionBinary }) and removed variant handling.
Yjs / conversion utilities refactor
packages/editor/src/core/helpers/yjs-utils.ts
Consolidated rich/document variant logic into unified parser-kit/schema; changed function signatures to object params and removed variant-based functions.
Editor extensions removed / renamed
packages/editor/src/core/extensions/work-item-embed/* (deleted), packages/editor/src/ce/extensions/core/without-props.ts (deleted), packages/editor/src/ce/extensions/parser-kit.ts (added), packages/editor/src/core/extensions/parser-kit.ts (renamed/updated), packages/editor/src/core/extensions/index.ts, packages/editor/src/lib.ts
Deleted work-item-embed extension and related exports; introduced PARSER_KIT_ADDITIONAL_EXTENSIONS; renamed CoreEditorExtensionsWithoutPropsPARSER_KIT; removed exports referencing core-without-props.
Editor components simplified
packages/editor/src/core/components/editors/document/collaborative-editor.tsx, packages/editor/src/core/components/editors/document/editor.tsx
Removed memoized augmentation of extensions and conditional injection of WorkItemEmbedExtension; now use provided extensions directly.
Minor typing change
packages/editor/src/core/helpers/editor-commands.ts
Replaced numeric literal union with imported Level type for toggleHeading.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant EditorLib

    Client->>Server: POST /convert-document { description_html }
    Server->>EditorLib: getAllDocumentFormatsFromHTMLString({ descriptionHTML })
    EditorLib-->>Server: { description, description_binary, description_html? }
    Server-->>Client: JSON response with description and description_binary
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

🌐frontend

Suggested reviewers

  • VipinDevelops
  • prateekshourya29

Poem

A rabbit hopped through lines of code,
Merged parsers on a winding road.
Old embeds cleared, helpers made one,
Now conversions run with less undone.
🐇✨

✨ 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/core-without-props

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

Copy link

makeplane bot commented Aug 7, 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: 0

🧹 Nitpick comments (1)
apps/live/src/server.ts (1)

67-74: Consider removing unused variant parameter.

The variant parameter is still being destructured and validated but is no longer used in the conversion function call. Consider removing this parameter from the request validation to avoid confusion.

-    const { description_html, variant } = req.body as TConvertDocumentRequestBody;
+    const { description_html } = req.body as TConvertDocumentRequestBody;
     try {
-      if (description_html === undefined || variant === undefined) {
+      if (description_html === undefined) {
         res.status(400).send({
           message: "Missing required fields",
         });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9de5b1a and a89bee8.

📒 Files selected for processing (18)
  • apps/live/src/core/helpers/convert-document.ts (0 hunks)
  • apps/live/src/core/helpers/page.ts (0 hunks)
  • apps/live/src/core/lib/page.ts (3 hunks)
  • apps/live/src/server.ts (2 hunks)
  • apps/web/core/hooks/use-page-fallback.ts (2 hunks)
  • packages/editor/src/ce/extensions/core/without-props.ts (0 hunks)
  • packages/editor/src/ce/extensions/parser-kit.ts (1 hunks)
  • packages/editor/src/core/components/editors/document/collaborative-editor.tsx (2 hunks)
  • packages/editor/src/core/components/editors/document/editor.tsx (1 hunks)
  • packages/editor/src/core/extensions/index.ts (0 hunks)
  • packages/editor/src/core/extensions/parser-kit.ts (3 hunks)
  • packages/editor/src/core/extensions/work-item-embed/extension-config.ts (0 hunks)
  • packages/editor/src/core/extensions/work-item-embed/extension.tsx (0 hunks)
  • packages/editor/src/core/extensions/work-item-embed/index.ts (0 hunks)
  • packages/editor/src/core/helpers/editor-commands.ts (2 hunks)
  • packages/editor/src/core/helpers/parser.ts (3 hunks)
  • packages/editor/src/core/helpers/yjs-utils.ts (3 hunks)
  • packages/editor/src/lib.ts (0 hunks)
💤 Files with no reviewable changes (8)
  • packages/editor/src/lib.ts
  • packages/editor/src/core/extensions/work-item-embed/index.ts
  • apps/live/src/core/helpers/convert-document.ts
  • packages/editor/src/core/extensions/work-item-embed/extension-config.ts
  • packages/editor/src/core/extensions/index.ts
  • apps/live/src/core/helpers/page.ts
  • packages/editor/src/ce/extensions/core/without-props.ts
  • packages/editor/src/core/extensions/work-item-embed/extension.tsx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: in the plane project codebase, the path alias `@/plane-web` resolves to the `ce` directory, making i...
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/`.

Applied to files:

  • apps/web/core/hooks/use-page-fallback.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). (5)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Build and lint web apps
🔇 Additional comments (11)
packages/editor/src/core/helpers/editor-commands.ts (1)

2-2: LGTM! Improved type consistency with tiptap ecosystem.

Using the official Level type from @tiptap/extension-heading instead of manually defining the union type (1 | 2 | 3 | 4 | 5 | 6) improves maintainability and ensures consistency with the tiptap extension ecosystem.

Also applies to: 16-16

packages/editor/src/ce/extensions/parser-kit.ts (1)

1-4: LGTM! Good foundation for the unified parser kit approach.

This establishes the base for consolidating editor extensions into a single parser kit, replacing the previous variant-specific approach. The empty array serves as an extensible foundation.

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

10-10: LGTM! Clean removal of WorkItemEmbedExtension.

The removal is consistent with the broader cleanup of the WorkItemEmbedExtension across the codebase. The extensions array construction is simplified while still passing embedConfig to DocumentEditorAdditionalExtensions, suggesting embed functionality may be handled elsewhere.

Also applies to: 40-62

apps/web/core/hooks/use-page-fallback.ts (1)

3-3: LGTM! Improved function signature alignment with unified approach.

The change from getBinaryDataFromDocumentEditorHTMLString to getBinaryDataFromHTMLString with a structured object parameter aligns with the broader refactoring to consolidate variant-specific functions. The new signature is more extensible and consistent.

Also applies to: 30-32

apps/live/src/server.ts (1)

12-12: LGTM! Good consolidation of conversion logic.

The change to use getAllDocumentFormatsFromHTMLString from the external package consolidates the document conversion logic effectively. The structured parameter approach is more maintainable.

Also applies to: 75-77

packages/editor/src/core/components/editors/document/collaborative-editor.tsx (1)

21-21: No changes needed for undefined extensions

The useCollaborativeEditor hook already assigns a default value (extensions = []) when destructuring its props, so passing undefined won’t cause runtime errors.

packages/editor/src/core/extensions/parser-kit.ts (1)

9-9: LGTM! Clean refactoring to parser kit naming

The renaming from CoreEditorExtensionsWithoutProps to PARSER_KIT and the corresponding import updates align well with the PR objective of consolidating the editor core under a unified parser kit approach.

Also applies to: 25-25, 101-101

apps/live/src/core/lib/page.ts (1)

22-24: Good refactoring to use named parameters

The migration to object parameters with named properties improves code readability and maintainability. The changes from positional arguments to { descriptionBinary } and { descriptionHTML } make the API more explicit.

Note that getBinaryDataFromHTMLString now returns the binary data directly rather than wrapped in an object, which is a cleaner API design.

Also applies to: 49-51

packages/editor/src/core/helpers/parser.ts (1)

9-9: Clean removal of variant-based logic

The refactoring successfully removes the variant parameter and consolidates the conversion logic under getAllDocumentFormatsFromHTMLString. This simplification aligns with the PR objective of unifying editor utilities.

Also applies to: 67-67, 88-90

packages/editor/src/core/helpers/yjs-utils.ts (2)

7-10: Excellent consolidation to single parser schema

The unification to a single PARSER_KIT and parserSchema eliminates code duplication and simplifies the codebase. This is a significant improvement over the previous variant-based approach.


45-56: Well-structured API with consistent object parameters

The refactoring of all conversion functions to use object parameters with descriptive property names (descriptionHTML, descriptionBinary) creates a consistent and maintainable API. The return types are also properly aligned with TDocumentPayload.

Also applies to: 62-86, 92-109

@Copilot Copilot AI review requested due to automatic review settings September 1, 2025 15:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/live/src/server.ts (1)

66-77: Remove unused variant validation in /convert-document handler
In apps/live/src/server.ts (lines 66–77), variant is destructured and required by the request body type but never used in getAllDocumentFormatsFromHTMLString, causing valid requests without it to return 400. Update the handler to only extract and validate description_html, for example:

- this.router.post("/convert-document", (req: Request, res: Response) => {
-   const { description_html, variant } = req.body as TConvertDocumentRequestBody;
+ this.router.post("/convert-document", (req: Request, res: Response) => {
+   const { description_html } = req.body as Partial<TConvertDocumentRequestBody>;
    try {
-     if (description_html === undefined || variant === undefined) {
-       res.status(400).send({ message: "Missing required fields" });
+     if (typeof description_html !== "string" || description_html.trim() === "") {
+       res.status(400).send({ message: "description_html is required" });
      return;
    }
🧹 Nitpick comments (1)
apps/live/src/server.ts (1)

12-12: Fix import order to satisfy linter (external before alias/internal)

Move @plane/editor/lib above @/core/... imports.

 import helmet from "helmet";
+import { getAllDocumentFormatsFromHTMLString } from "@plane/editor/lib";
 // hocuspocus server
 // helpers
 import { logger, manualLogger } from "@/core/helpers/logger.js";
 import { getHocusPocusServer } from "@/core/hocuspocus-server.js";
-// types
-import { TConvertDocumentRequestBody } from "@/core/types/common.js";
-import { getAllDocumentFormatsFromHTMLString } from "@plane/editor/lib";
+// types
+import { TConvertDocumentRequestBody } from "@/core/types/common.js";
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a89bee8 and a71ff8f.

📒 Files selected for processing (1)
  • apps/live/src/server.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/live/src/server.ts (1)
packages/editor/src/core/helpers/yjs-utils.ts (1)
  • getAllDocumentFormatsFromHTMLString (92-109)
🪛 GitHub Check: Build and lint web apps
apps/live/src/server.ts

[warning] 12-12:
@plane/editor/lib import should occur before import of @/core/helpers/logger.js

⏰ 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 (1)
apps/live/src/server.ts (1)

75-77: Helper switch LGTM

Using getAllDocumentFormatsFromHTMLString({ descriptionHTML }) matches the new parser-kit API; returned fields align with response.

@aaryan610 aaryan610 marked this pull request as draft September 1, 2025 16:52
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.

2 participants