Discontiguous selection is not supported

被刻印的时光 ゝ 提交于 2019-12-23 21:44:05

问题


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?


回答1:


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




回答2:


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:

  • https://github.com/timdown/rangy/issues/247
  • 'Range.detach' is now a no-op, as per DOM


来源:https://stackoverflow.com/questions/28513869/discontiguous-selection-is-not-supported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!