LoginSignup
3
4

More than 5 years have passed since last update.

スマホでも使えるWYSIWYGエディタQuillの日本語入力

Posted at

スマホでも使えるWYSIWYGエディタQuillってことでつかってみのだが。。。

iphoneで「確定」する前の状態でバックスペースで削除した文字が、
次の動作(入力などのキーボード操作)をした瞬間に、削除前の文字列が復元されて入力される現象に遭遇。。。

とりあえず下記の用にソースを修正して回避した。

変更前

Keyboard.prototype._initListeners = function() {
            return dom(this.quill.root).on('keydown', (function(_this) {
                return function(event) {
                    var prevent;
                    prevent = false;
                    _.each(_this.hotkeys[event.which], function(hotkey) {
                        var metaKey;

                            metaKey = dom.isMac() ? event.metaKey : event.metaKey || event.ctrlKey;
                            if (!!hotkey.metaKey !== !!metaKey) {
                                return;
                            }
                            if (!!hotkey.shiftKey !== !!event.shiftKey) {
                                return;
                            }
                            if (!!hotkey.altKey !== !!event.altKey) {
                                return;
                            }

                            prevent = hotkey.callback(_this.quill.getSelection(), hotkey, event) === false || prevent;
                        return true;
                    });
                    return !prevent;
                };
            })(this));
        };

変更後


Keyboard.prototype._initListeners = function() {
            return dom(this.quill.root).on('keydown', (function(_this) {
                return function(event) {
                    var prevent;
                    prevent = false;
                    _.each(_this.hotkeys[event.which], function(hotkey) {
                        var metaKey;

                        if (dom.isIOS() !== true) {
                            metaKey = dom.isMac() ? event.metaKey : event.metaKey || event.ctrlKey;
                            if (!!hotkey.metaKey !== !!metaKey) {
                                return;
                            }
                            if (!!hotkey.shiftKey !== !!event.shiftKey) {
                                return;
                            }
                            if (!!hotkey.altKey !== !!event.altKey) {
                                return;
                            }

                            prevent = hotkey.callback(_this.quill.getSelection(), hotkey, event) === false || prevent;
                        }

                        return true;
                    });
                    return !prevent;
                };
            })(this));
        };


3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4