Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core.js: An exception occurred while resetting the "Range" object. #525

Closed
BrianJVarley opened this issue Oct 19, 2020 · 6 comments
Closed

Comments

@BrianJVarley
Copy link

BrianJVarley commented Oct 19, 2020

Hi @JiHong88 ,

I'm using the following function to clear the editor body text. The function use's commandHandler to selectAll content and remove the node. But after calling this function I'm getting a warning emitted from core.js lib about resetting RANGE object.

Is it possible to expose a public property on SunEditor to clear the body text? Or would you suggest a different approach to my function below?

 @Input() set clearText(clearText: boolean) {
    if (clearText && this.editorInstance) {
      this.editorInstance.core.commandHandler(null, 'selectAll');
      this.editorInstance.core.removeNode();
    }
  }

Console Error:
core.js?4e0d:1630 [SUNEDITOR.core.removeNode.exception] An exception occurred while resetting the "Range" object.

Complete Stack Trace:

image

@JiHong88
Copy link
Owner

JiHong88 commented Oct 23, 2020

Thanks for reporting.

Resets the "Range" object when deleting, inserting, or modifying a node.
This warning is displayed when the cannot be set appropriate text node to the "container" when run removeNode method.
But in most cases, the code runs fine.

I put a warning because it occurs in certain situations.
Can you show the HTML of the editor when outputting the warning?

@BrianJVarley
Copy link
Author

BrianJVarley commented Nov 3, 2020

Hi @JiHong88 ,

I've recently updated to new "suneditor": "2.34.0" package. But I noticed that our function to delete editor contents has stopped working. The function calls commandHandler and removeNode but the editor contents isn't deleted. I've attached a GIF below.

      this.editorInstance.core.commandHandler(null, 'selectAll');
      this.editorInstance.core.removeNode();

Did you make any changes to SunEditor.Core API to how you can access and delete the editor content / node?

email-editor-delete-node-bug

@BrianJVarley
Copy link
Author

I was planning to use the editor.setContents('') but it actually adds a <p><p> tag to the editor body when you try to set contents to an empty string. In our use case this makes the cursor jump to a new line which isn't correct.

@JiHong88 JiHong88 added this to the 2.35.0 milestone Nov 5, 2020
JiHong88 added a commit that referenced this issue Nov 5, 2020
@JiHong88 JiHong88 closed this as completed Nov 5, 2020
@BrianJVarley
Copy link
Author

👍

@JiHong88
Copy link
Owner

The 2.34.2 version has been updated.
If this issue has not been resolved, please reopen this issue.
Thank you.

@ColmShannon
Copy link

ColmShannon commented Nov 16, 2020

Hi @JiHong88, thank you. That seems to have resolved our issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants