San*_*eep 24 wysiwyg google-chrome text-editor angularjs redactor.js
我们使用的是Redactor(https://imperavi.com/redactor/)版本10.1.1,由于对项目的依赖性很大,我们没有迁移到Redactor II.
最近我们在Chrome 58版本面临一个非常奇怪的问题.问题是:
- 无法为所选文本格式化粗体,斜体,下划线,sup,sub等
请告诉我们是否有任何解决方法.任何形式的帮助将不胜感激.
根据公认的解决方案更新:
// Provided solution is tested for Redactor version 10.1.1
createMarkers: function()
{
this.selection.get();
var node1 = this.selection.getMarker(1);
this.selection.setMarker(this.range, node1, true);
if (this.range.collapsed === false) {
var node2 = this.selection.getMarker(2);
this.selection.setMarker(this.range, node2, false);
// Fix for Chrome58 Issues
if (this.utils.browser('chrome')) {
this.caret.set(node1, 0, node2, 0);
}
// End Chrome58 Issues
}
this.savedSel = this.$editor.html();
},
Run Code Online (Sandbox Code Playgroud)
Mic*_*ati 24
我想我可能已经找到了解决办法:看来Chrome 58(有时)会在我们打电话时重置选择Range.insertNode.
我建议的解决方案是在Redactor添加选择标记时恢复选择:在createMarkers函数中,设置node2标记后,您可以添加此函数调用:
this.caret.set(node1, 0, node2, 0);
这是应该为Concrete5修复Redactor的解决方案(但它也适用于其他项目).