Voog / wysihtml

Open source rich text editor for the modern web

Home Page:http://wysihtml.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blur event firing on toolbar click. Bookmark not maintained.

Dayjo opened this issue · comments

commented

Hello! Not sure this is exactly a bug as it's just started occurring when I moved my toolbar element.

I'm having a bit of an issue with the blur event firing when I click on a toolbar item. This doesn't always happen which is odd. On normal command buttons it mostly works fine (though sometimes i'll click bold, it'll make the text bold, and THEN blur).

I have some custom 'dialogs' for font family and font size, they're still within the specified toolbar element but when I click them, the editor blurs before I can actually run a command to format the text. Normally this should be ok as the bookmark is saved for when the commands are run, however sometimes (and not always) it doesn't remember the bookmark, so when I run the command, it just inserts at the start of the editor,

Is there a set of specific classes that are sought after to not blur? Happy to look at the code specifically that stops toolbar from causing the blur and debug it, but wasn't sure where to start.

I'm not sure if it's related but I sometimes get this error when it blurs on the 'bold' command button in the toolbar;

image

Any suggestions / similar issues welcome!

commented

Still haven't been able to resolve this issue.

If there's some more information I can provide, I'm happy to do so.

commented

I seem to have resolved this issue (mostly - still think there's a couple of minor issues).

After heavily trawling through the examples and trying to replicate it, I had to add the following mousedown event listener function to anything that is in any of the toolbar elements;

function( event ) {
    event.preventDefault();
    var b = editor.composer.selection.getBookmark();
    setTimeout(function() {
          editor.composer.selection.setBookmark(b);
    }, 0);
};

This may already be documented somewhere (as it is in the example code), but if not, would be good to put something in about building custom toolbars that this may be necessary.