问题描述
在Chrome 58更新了Bold,Italic&下划线停止工作。在调试中,我发现execCommand('strikethrough')没有触及选定的文本。
formatMultiple:function(tag)
{
this.inline.formatConvert(tag);
this.selection.save();
document.execCommand('strikethrough'); //这里,它并不是文本
this。$ editor.find('strike')。each($。proxy(function(i,s)
{
var $ el = $(s);
this.inline.formatRemoveSameChildren($ el,tag);
var $ span;
if(this。 inline.type)
{
$ span = $('< span>')。attr('data-redactor-tag',tag).attr('data-verified','redactor' );
$ span = this.inline.setFormat($ span);
}
else
{
$ span = $('<'+ tag + ''>')。attr('data-redactor-tag',tag).attr('data-verified','redactor');
}
$ el.replaceWith $ span.html($ el.contents()));
if(tag =='span')
{
var $ parent = $ span.parent();
if($ parent&& $ parent [0] .tagName =='SPAN'&&& this.inline.type =='style')
{
var arr = this.inline.value.split(';');
for(var z = 0; z {
if(arr [z] ==='')return;
var style = arr [z] .split(':');
$ parent.css(style [0],'');
if(this.utils.removeEmptyAttr($ parent,'style'))
{
$ parent.replaceWith($ parent.contents());
}
}
}
}
},这));
//清除文字装饰
if(tag!='span')
{
this。$ editor.find(this.opts.inlineTags.join ','))。each($。proxy(function(i,s)
{
var $ el = $(s);
var property = $ el.css('text );
if(property =='line-through')
{
$ el.css('text-decoration','');
this。 utils.removeEmptyAttr($ el,'style');
}
},this));
}
if(tag!='del')
{
var _this = this;
this。$ editor.find('inline')。each(function(i,s)
{
_this.utils.replaceToTag(s,'del');
});
}
this.selection.restore();
this.code.sync();
},
我测试了用document.execCommand创建一个小提琴('删除线),它的工作。即使在浏览器的控制台,它的作品。想知道会发生什么变化?
同样的问题已经在这里报道:,并提供解决方法。请看一看。
After Chrome 58 update few features like Bold, Italic & Underline stopped working. On debugging i found that execCommand('strikethrough') is not striking the selected text.
formatMultiple: function(tag)
{
this.inline.formatConvert(tag);
this.selection.save();
document.execCommand('strikethrough'); //HERE, IT IS NOT STRIKING THE TEXT
this.$editor.find('strike').each($.proxy(function(i,s)
{
var $el = $(s);
this.inline.formatRemoveSameChildren($el, tag);
var $span;
if (this.inline.type)
{
$span = $('<span>').attr('data-redactor-tag', tag).attr('data-verified', 'redactor');
$span = this.inline.setFormat($span);
}
else
{
$span = $('<' + tag + '>').attr('data-redactor-tag', tag).attr('data-verified', 'redactor');
}
$el.replaceWith($span.html($el.contents()));
if (tag == 'span')
{
var $parent = $span.parent();
if ($parent && $parent[0].tagName == 'SPAN' && this.inline.type == 'style')
{
var arr = this.inline.value.split(';');
for (var z = 0; z < arr.length; z++)
{
if (arr[z] === '') return;
var style = arr[z].split(':');
$parent.css(style[0], '');
if (this.utils.removeEmptyAttr($parent, 'style'))
{
$parent.replaceWith($parent.contents());
}
}
}
}
}, this));
// clear text decoration
if (tag != 'span')
{
this.$editor.find(this.opts.inlineTags.join(', ')).each($.proxy(function(i,s)
{
var $el = $(s);
var property = $el.css('text-decoration');
if (property == 'line-through')
{
$el.css('text-decoration', '');
this.utils.removeEmptyAttr($el, 'style');
}
}, this));
}
if (tag != 'del')
{
var _this = this;
this.$editor.find('inline').each(function(i,s)
{
_this.utils.replaceToTag(s, 'del');
});
}
this.selection.restore();
this.code.sync();
},
I tested creating a fiddle with document.execCommand('strikethrough') and it worked. Even in browser`s console it works. Wondering what could have changed?
Same issue were already reported here: Redactor editor text format issues with Chrome version 58 and work around solution has been provided there. Please have a look.
这篇关于Yii 1.x imperavi redactor execCommand('删除线')不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!