问题
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