You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have multiple redactor-editors on one page, and some (or all) of them are placed within a LI tag.
Whenever the user tries to add a table, the table is placed after the closing LI tag, and thus outside the editor.
The change makes the plugin check if the closest LI tag is within the editor.
If so, it places the table after it. If not, it places the table where the cursor is.
Using if ($(current).closest('li', this.core.editor()).length !== 0) instead is enough as it limits the search inside Redactor.
Your proposed change first searches the closest list item and then checks if it is contained within Redactor (hint: there is also this.utils.isRedactorParent() for this), which is essentially the same as above but in reverse.
Ah, your way is more efficient indeed! if ($(current).closest('li', this.core.editor()).length !== 0) does not work though, because this.core.editor() returns a set of elements.
I've changed it into if ($(current).closest('li', this.core.editor().get(0)).length !== 0) which does work.
My bad, it's been a while I used closest(), just did a quick check of the API docs and didn't notice it required a DOM element rather than a jQuery object; Your solution is correct.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have multiple redactor-editors on one page, and some (or all) of them are placed within a LI tag.
Whenever the user tries to add a table, the table is placed after the closing LI tag, and thus outside the editor.
The change makes the plugin check if the closest LI tag is within the editor.
If so, it places the table after it. If not, it places the table where the cursor is.