Skip to content

[WIKI-481] refactor: editor parser#7261

Merged
pushya22 merged 1 commit intopreviewfrom
fix/editor-parser
Jun 27, 2025
Merged

[WIKI-481] refactor: editor parser#7261
pushya22 merged 1 commit intopreviewfrom
fix/editor-parser

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Jun 24, 2025

Description

This PR adds support for additional parsing of editor content.

Type of Change

  • Code refactoring

Summary by CodeRabbit

  • New Features

    • Expanded support to handle additional asset types in HTML content, beyond just images.
  • Refactor

    • Generalized asset extraction and replacement processes for improved consistency and future extensibility.
    • Renamed relevant functions to reflect broader asset handling.
  • Bug Fixes

    • Improved asset handling to ensure all asset types are correctly managed during content processing.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Walkthrough

The changes introduce a new helper module for parsing additional assets in HTML content and generalize existing asset extraction and replacement logic to support asset types beyond images. Functions are renamed and refactored to handle a broader range of assets, integrating new helper functions for extensibility.

Changes

File(s) Change Summary
packages/editor/src/ce/helpers/parser.ts New module added with two exported functions for extracting and replacing additional assets in HTML content.
packages/editor/src/core/helpers/parser.ts Refactored and generalized asset extraction and replacement functions; integrated new helper functions; renamed functions for broader asset support.

Poem

In the editor’s warren, new helpers appear,
To sniff out more assets, not just images here.
With functions renamed, and parsing anew,
The code now supports a much broader view.
🐇✨
Hopping through HTML, we gather and swap—
The rabbit’s new toolkit just won’t stop!

✨ Finishing Touches
  • 📝 Generate Docstrings

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 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.

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 (2)
packages/editor/src/ce/helpers/parser.ts (2)

6-6: Add TODO comments for stub implementation clarity.

The function currently returns an empty array, which appears to be intentional for future expansion. Consider adding a TODO comment to clarify the planned implementation.

-export const extractAdditionalAssetsFromHTMLContent = (_htmlContent: string): string[] => [];
+export const extractAdditionalAssetsFromHTMLContent = (_htmlContent: string): string[] => {
+  // TODO: Implement extraction of additional asset types beyond images
+  return [];
+};

13-19: Utilize the assetMap parameter or document the stub implementation.

The function extracts htmlContent from props but ignores the assetMap parameter, returning the original content unchanged. This suggests incomplete implementation.

 export const replaceAdditionalAssetsInHTMLContent = (props: {
   htmlContent: string;
   assetMap: Record<string, string>;
 }): string => {
-  const { htmlContent } = props;
+  const { htmlContent, assetMap } = props;
+  // TODO: Implement replacement of additional asset types using assetMap
   return htmlContent;
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 072f2e2 and 4e538df.

📒 Files selected for processing (2)
  • packages/editor/src/ce/helpers/parser.ts (1 hunks)
  • packages/editor/src/core/helpers/parser.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
packages/editor/src/core/helpers/parser.ts (4)

17-32: LGTM! Well-structured refactoring with proper integration.

The function has been successfully generalized from image-specific to multi-asset handling. The integration of extractAdditionalAssetsFromHTMLContent is clean and maintains the existing functionality while extending capabilities.


39-59: LGTM! Proper integration of additional asset replacement.

The refactored function correctly processes image components first, then delegates additional asset replacement to the helper function. The use of doc.body.innerHTML as input to the helper function is appropriate.


61-95: LGTM! Consistent function renaming and maintained functionality.

The function has been properly renamed from getEditorContentWithReplacedImageAssets to getEditorContentWithReplacedAssets, and all internal function calls have been updated to use the new generalized functions. The workflow remains intact while supporting expanded asset types.


4-8: Verify the import path for the new helper functions.

The import path @/plane-editor/helpers/parser should be verified to ensure it correctly resolves to packages/editor/src/ce/helpers/parser.ts. The path structure suggests it might be incorrect.

#!/bin/bash
# Verify the import path resolution
echo "Checking if the import path resolves correctly..."
fd -t f "parser.ts" --exec echo "Found: {}"

@Palanikannan1437 Palanikannan1437 changed the title [WEB-481] refactor: editor parser [WIKI-481] refactor: editor parser Jun 27, 2025
@makeplane
Copy link

makeplane bot commented Jun 27, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

1 similar comment
@makeplane
Copy link

makeplane bot commented Jun 27, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@pushya22 pushya22 merged commit e09aeab into preview Jun 27, 2025
5 of 6 checks passed
@pushya22 pushya22 deleted the fix/editor-parser branch June 27, 2025 10:35
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
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.

4 participants