Skip to content

🐛 fix: Fix error temporary#10

Closed
canisminor1990 wants to merge 5 commits into
masterfrom
fix/import-error
Closed

🐛 fix: Fix error temporary#10
canisminor1990 wants to merge 5 commits into
masterfrom
fix/import-error

Conversation

@canisminor1990
Copy link
Copy Markdown
Member

@canisminor1990 canisminor1990 commented Aug 21, 2025

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

🔀 变更说明 | Description of Change

📝 补充信息 | Additional Information

Summary by Sourcery

Disable several editor-kernel utility functions and cleanup routines to resolve errors

Bug Fixes:

  • Comment out unused DOM-related utility functions in editor-kernel/utils.ts to prevent mapping errors
  • Disable Kernel.destroy cleanup operations in editor-kernel/kernel.ts to avoid runtime issues

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Aug 21, 2025

Reviewer's Guide

This PR addresses a runtime error by disabling the creation of an empty editor state and related DOM‐mapping utilities in utils.ts, and by commenting out the cleanup logic in Kernel.destroy to prevent erroneous state resets and plugin teardown.

Class diagram for Kernel class after destroy method changes

classDiagram
  class Kernel {
    +destroy()
    +getRootElement() HTMLElement | null
    ...
  }
  %% The destroy method's internal logic for resetting editor state and plugin teardown is now commented out.
Loading

File-Level Changes

Change Details Files
Comment out utility functions that generate or map editor state in utils.ts
  • Commented out createEmptyEditorState implementation
  • Commented out getNodeKeyFromDOMNode and $getNodeFromDOMNode
  • Commented out isDOMNode, isDocumentFragment, getParentElement, and $getNearestNodeFromDOMNode
src/editor-kernel/utils.ts
Disable cleanup actions in Kernel.destroy in kernel.ts
  • Commented out setEditorState(empty) call
  • Commented out dataTypeMap.clear()
  • Commented out plugin.destroy() iteration
  • Commented out resetting pluginsInstances array
src/editor-kernel/kernel.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@vercel
Copy link
Copy Markdown

vercel Bot commented Aug 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lobe-editor Ready Ready Preview Comment Aug 21, 2025 5:09am

@lobehubbot
Copy link
Copy Markdown
Member

👍 @canisminor1990


Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link
Copy Markdown

@sourcery-ai sourcery-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.

Hey there - I've reviewed your changes - here's some feedback:

  • Instead of commenting out large blocks of utility functions, consider removing them or marking them as deprecated to keep the codebase clean and maintainable.
  • Completely disabling the kernel.destroy cleanup risks memory leaks or stale state; refactor this method to preserve proper teardown logic or introduce a configuration toggle.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of commenting out large blocks of utility functions, consider removing them or marking them as deprecated to keep the codebase clean and maintainable.
- Completely disabling the kernel.destroy cleanup risks memory leaks or stale state; refactor this method to preserve proper teardown logic or introduce a configuration toggle.

## Individual Comments

### Comment 1
<location> `src/editor-kernel/kernel.ts:55` </location>
<code_context>
   }

   destroy() {
-    this.editor?.setEditorState(createEmptyEditorState());
-    this.dataTypeMap.clear();
-    this.pluginsInstances.forEach((plugin) => {
-      if (plugin.destroy) {
-        plugin.destroy();
-      }
-    });
-    this.pluginsInstances = [];
+    // this.editor?.setEditorState(createEmptyEditorState());
+    // this.dataTypeMap.clear();
</code_context>

<issue_to_address>
Destroy logic is now fully commented out, which may lead to resource leaks.

Commenting out all cleanup in destroy means state and plugin instances will remain, potentially causing memory leaks or issues if the kernel is reused. If this change is intentional, please document the new lifecycle or confirm cleanup is handled elsewhere.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines -55 to -62
this.editor?.setEditorState(createEmptyEditorState());
this.dataTypeMap.clear();
this.pluginsInstances.forEach((plugin) => {
if (plugin.destroy) {
plugin.destroy();
}
});
this.pluginsInstances = [];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Destroy logic is now fully commented out, which may lead to resource leaks.

Commenting out all cleanup in destroy means state and plugin instances will remain, potentially causing memory leaks or issues if the kernel is reused. If this change is intentional, please document the new lifecycle or confirm cleanup is handled elsewhere.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Aug 21, 2025

Open in StackBlitz

npm i https://pkg.pr.new/lobehub/lobe-editor/@lobehub/editor@10

commit: 647a62b

@canisminor1990 canisminor1990 changed the title 🐛 fix: Fix error 🐛 fix: Fix error temporary Aug 21, 2025
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.

2 participants