Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

The given range isn't in document

AustinS January 28, 2018

We're using TinyMCE in  AUI dialog2 in Confluence user plugin. When we removed the content from editor box (whenever cursor is not in editor box) and try to add content then it's showing errors:

1. The node to be replaced has been already deleted from the document

2. The given range isn't in document

Looks like when cursor focus not on the editor, it could not get the range from the editor。 My guess is that dialog is stealing the focus as this is a common behavior in dialogs created using HTML/CSS.  

Do anyone know how to disable its code that steals the focus. 

 Anyone has any idea about it, any help would be greatly appreciated.

1 answer

0 votes
Daz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 9, 2018

Hi @AustinS,

AUI's Dialog2 does not appear to allow disabling its auto-focussing behaviour. With that said, it only sets focus once the dialog2 element is shown. 

I am interested to know when this error is occurring, because I suspect it may not be a problem with AUI's components.

This sounds to me like a problem with TinyMCE and expectations. If the user's focus is not in the TinyMCE editor at the point when you execute your code, and your code is expecting there to be a range, there will be no range, since there will be no text selection, as that requires the user agent to be focussing the field.

At what point in time does this error occur? Does it happen the moment you open the dialog, or some time thereafter?

I don't think I have enough detail to understand the problem completely, but my thoughts would be: in order to replace content in the TinyMCE editor at any point in time, regardless of the user's focus, you probably want to be using TinyMCE's DOM operations -- https://www.tinymce.com/docs/api/tinymce.dom/tinymce.dom.domquery/ -- as opposed to text selection operations.

If I've misunderstood the problem, let me know. If you can provide more context, such as code, or a video demonstrating the problem, that may help further.

Finally, this seems like a plugin development related question. We have a dedicated community for developers at https://community.developer.atlassian.com/. In future, if you ask questions there, they will likely be answered faster, since there are more developers watching those forums.

Cheers,

Daz.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events