mindmup / bootstrap-wysiwyg

Tiny bootstrap-compatible WISWYG rich text editor
MIT License
5.56k stars 841 forks source link

Typing in the hyperlink input box sets focus to the main editor on keydown #187

Open ayyobro opened 9 years ago

ayyobro commented 9 years ago

I added this to my toolbar:

    <div class="btn-group open">
        <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" title="" data-original-title="Hyperlink"><i class="fa fa-link"></i></a>
        <div class="dropdown-menu input-append">
            <input class="span2" placeholder="URL" type="text" data-edit="createLink">
            <button class="btn" type="button">Add</button>
        </div>
        <a class="btn btn-default" data-edit="unlink" title="" data-original-title="Remove Hyperlink"><i class="fa fa-cut"></i></a>
    </div>

but whenever I open up the hyperlink create, click the input, and hit any key it targets the main editor and starts typing in there.

aditya-jois commented 9 years ago

I have the same problem. But after going through their example at - http://mindmup.github.io/bootstrap-wysiwyg/ and looking at the JavaScript source, added the following snippet to my code.

$('.dropdown-menu input').click(function() {return false;}) .change(function () {$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');}) .keydown('esc', function () {this.value='';$(this).change();});

This is being called in the initToolbarBootstrapBindings() function.

It now works for me. Tried on Chrome Version 41.0.2272.101 m

Coffeecream commented 9 years ago

Thank you :)

paulc1983 commented 9 years ago

I have the same problem. i added the whole of initToolbarBootstrapBindings into my code. now the dropdown stays open so that i can type into the input, but the selection is lost in the editor. can anybody help with this?

aditya-jois commented 9 years ago

I am not sure why that is happening. Can you please provide more details of your code / browser details? Also, this has now moved to https://github.com/steveathon/bootstrap-wysiwyg. Please try the new binaries under that repository. There seem to be significant amount of changes / fixes done.