3

I am trying bootstrap-wysihtml5-rails, I am using twitter bootstrap 2

but when I get this result as in the image, and the error:

Discontiguous selection is not supported.

I tried to window['rangy'].initialized = false; like this:

<script type="text/javascript">
    $(document).ready(function(){


        window['rangy'].initialized = false;

        $('.wysihtml5').each(function(i, elem) {
            $(elem).wysihtml5();
        });
    })
</script>

But I still get the same error, I could live with it, but it seems that it breaks the buttons of the editor as in the image, any one can help?

enter image description here

simo
  • 23,342
  • 38
  • 121
  • 218
  • The bug might be fixed, as of 20Feb - https://bugs.chromium.org/p/chromium/issues/detail?id=353069#c4 – Dropout Mar 10 '17 at 13:48

2 Answers2

6

Just add window.getSelection().removeAllRanges(); after your code, this will do the magic.

Zeeshan Ali
  • 343
  • 5
  • 6
1

That message is just a warning that doesn't throw an actual error so shouldn't affect anything. The warning was added to Chrome a few versions ago and is triggered by Rangy's initialization code. More recent versions of Rangy have a workaround but I assume bootstrap-wysihtml5-rails has an older version.

I'm pretty sure that it can't be causing the issue with the buttons and that you have another issue, but it's possible Chrome's behaviour has changed.

Some background:

Community
  • 1
  • 1
Tim Down
  • 318,141
  • 75
  • 454
  • 536
  • I've switched to tinymc editor, works very good without. errors – simo Feb 14 '15 at 19:18
  • @simo: Fair enough. I would tend to trust the more established and well-supported editors such as TinyMCE and CKEditor too. – Tim Down Feb 15 '15 at 11:26