Yii 1.x imperavi redactor execCommand('strikethrough') not working

一笑奈何 提交于 2020-01-07 06:54:05

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/43722113/yii-1-x-imperavi-redactor-execcommandstrikethrough-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!