【发布时间】:2017-04-28 07:24:56
【问题描述】:
我们使用的是 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();
},
【问题讨论】:
-
其中一个可能的原因是:Chrome 58 下存在问题,因为“文本控件内的选择应该是 Range 类型(不是 Caret)”[bugs.chromium.org/p/chromium/issues/detail?id=712579]。此问题已修复,但最终用户将在 2017 年 6 月 6 日之前使用。
-
concrete5也有同样的问题github.com/concrete5/concrete5/issues/5406
-
我遇到了同样的问题,已经详细解释了这个问题。这是由未正确执行操作的 document.execCommand('strikethrough') 引起的。见这里:stackoverflow.com/questions/43722113/…
-
仅供参考:据我所知,Chrome 59 仍然存在。
标签: angularjs google-chrome wysiwyg text-editor redactor.js