wysiwyg-editor
wysiwyg-editor copied to clipboard
html.getSelected() is wrong for selection without markup
Expected behavior.
Selecting content without any html markup (plain text) in the froala editor and calling html.getSelected() will only return the selected part.
Actual behavior.
The complete html markup of the editor is returned
Steps to reproduce the problem.
- Type
This is some text before. Select this text. This is some text after. - Select
Select this text - Call
html.getSelected()
Versions.
Froala: 3.0.5 OS/Browser: Chrome, Firefox
Any news about this? It looks like it's working fine in Chrome and it breaks in Firefox and Safari..... (Froala 3.1.1)
I have experienced a similar issue to this, in that calling html.getSelected() does not return the selection, but rather the entire line of text of which the selection belongs. Thought I should add here as it seems very similar and do not want to create unnecessary issues.
The issue also only seems to repro in Firefox for me. Safari is all OK.
Version 3.1.0
observing same issue here, on version 3.1.1...
Hi there, this is a huge issue for us, as we want to implement a custom plugin and need a way to get the selected html. From what I have seen, the html.getSelection() method returns the whole parent element - in my test it is the paragraph, as I am selecting just text inside the paragraph, not event trying to mess around with selecting say parts of bold, underlined or italic contents.
In the ideal case, if the markup is something like ... some text <strong>some |other text</strong> yet an|other text... and the user selects everything between the two pipes (|), we need a way to get "other text</strong> yet an" as return value of some method.
In general I have the feeling that nothing big is happening for the froala editor lately, because the focus is obviously on bringing new products on the market. Prove me wrong, dear Froala staff :)
Version 3.1.1
This is still happening in version 3.2.5. This was working under Froala v2, so judging by the comments here it has been broken during all of Froala 3.
But I found a workaround that seems to work so far for my custom plugins. However I haven't tested too extensively since it started working, so I can't be sure...
Immediately before calling html.getSelection(), call selection.text()
function myFroalaSelection(editor) {
editor.selection.text();
return editor.html.getSelection();
}
It seems like sometimes the selection is not primed and html.getSelection doesn't or fails to prime it itself. Or at least that's the only explanation I can think of without seeing Froala's code unminified.