问题描述
我们正在使用Redactor()10.1版本。 1,并且由于项目的依赖性很大而没有迁移到Redactor II。
最近我们遇到了Chrome 58版的一个非常奇怪的问题。问题是:
- 无法为所选文字设置粗体,斜体,下划线,sup,sub等格式
请让我们知道有没有解决这个问题。任何形式的帮助将不胜感激。
根据可接受的解决方案进行更新:
//提供的解决方案已针对Redactor版本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);
//修复Chrome58问题
if(this.utils.browser('chrome')){
this.caret.set(node1,0,node2,0) ;
}
//结束Chrome58发行
}
this.savedSel = this。$ editor.html();
},
找到了解决方案:当我们调用 Range.insertNode
时,似乎Chrome 58(有时)会重置选区。
我建议的解决方案是在Redactor添加选择标记时恢复选择:在 createMarkers
函数中,在设置 node2
marker,你可以添加这个函数调用:
this.caret.set(node1,0,node2,0);
应该修复混凝土的Redactor的解决方案5 (但它也应该适用于其他项目)。
We're using Redactor(https://imperavi.com/redactor/) version 10.1.1 and not migrated to Redactor II due to lot of dependencies on project.
Recently We're facing a very weird issue with Chrome version 58. Issues are:
-- Not able to format bold, italic, underline, sup, sub etc. for selected text
Kindly let us know is there any fix for this. Any kind of help would be greatly appreciated.
Update as per accepted work around solution:
// 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();
},
I think I may have found the solution: It seems that Chrome 58 (sometimes) resets the selection when we call Range.insertNode
.
The solution I suggest is to restore the selection when the Redactor adds the selection markers: In the createMarkers
function, right after setting the node2
marker, you can add this function call:this.caret.set(node1, 0, node2, 0);
Here's the solution that should fix Redactor for concrete5 (but it should also work for other projects too).
这篇关于Chrome版本58的编辑器编辑器文本格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!