How to use the editor.Mode function in editor

To help you get started, we’ve selected a few editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kissyteam / kissy / build / editor / plugin / undo-debug.js View on Github external
pluginRenderUI: function (editor) {
            // 先 button 绑定事件
            editor.addButton('undo', {
                mode: Editor.Mode.WYSIWYG_MODE,
                tooltip: '\u64A4\u9500',
                editor: editor
            }, Btn.UndoBtn);
            editor.addButton('redo', {
                mode: Editor.Mode.WYSIWYG_MODE,
                tooltip: '\u91CD\u505A',
                editor: editor
            }, Btn.RedoBtn);
            cmd.init(editor);
        }
    };
github kissyteam / kissy / src / editor / sub-modules / plugin / undo / src / undo.js View on Github external
pluginRenderUI: function (editor) {
        // 先 button 绑定事件
        editor.addButton('undo', {
            mode: Editor.Mode.WYSIWYG_MODE,
            tooltip: '撤销',
            editor: editor
        }, Btn.UndoBtn);

        editor.addButton('redo', {
            mode: Editor.Mode.WYSIWYG_MODE,
            tooltip: '重做',
            editor: editor
        }, Btn.RedoBtn);
        cmd.init(editor);
    }
};
github kissyteam / kissy / build / editor / plugin / checkbox-source-area-debug.js View on Github external
], function (S, require, exports, module) {
    /**
 * @ignore
 * checkbox source editor for kissy editor
 * @author yiminghe@gmail.com
 */
    // 'editor', '../font/cmd'
    var Editor = require('editor');
    var util = require('util');
    var $ = require('node');
    var SOURCE_MODE = Editor.Mode.SOURCE_MODE, WYSIWYG_MODE = Editor.Mode.WYSIWYG_MODE;
    function CheckboxSourceArea(editor) {
        var self = this;
        self.editor = editor;
        self._init();
    }
    util.augment(CheckboxSourceArea, {
        _init: function () {
            var self = this, editor = self.editor, statusBarEl = editor.get('statusBarEl');
            self.holder = $('<span>' + '<label style="vertical-align:middle;">' + '<input type="checkbox" style="margin:0 5px;">' + '\u7F16\u8F91\u6E90\u4EE3\u7801</label>' + '</span>');
            self.holder.appendTo(statusBarEl);
            var el = self.el = self.holder.one('input');
            el.on('click', self._check, self);
            editor.on('wysiwygMode', self._wysiwygmode, self);
            editor.on('sourceMode', self._sourcemode, self);
        },
        _sourcemode: function () {
github kissyteam / kissy / build / editor / plugin / undo / cmd-debug.js View on Github external
restore: function (d) {
            // 代码模式下不和可视模式下混在一起
            if (this.editor.get('mode') !== Editor.Mode.WYSIWYG_MODE) {
                return undefined;
            }
            var self = this, history = self.history, editor = self.editor, editorDomBody = editor.get('document')[0].body, snapshot = history[self.index + d];
            if (snapshot) {
                editorDomBody.innerHTML = snapshot.contents;
                if (snapshot.bookmarks) {
                    editor.getSelection().selectBookmarks(snapshot.bookmarks);
                } else if (UA.ie) {
                    // IE BUG: If I don't set the selection to *somewhere* after setting
                    // document contents, then IE would create an empty paragraph at the bottom
                    // the next time the document is modified.
                    var $range = editorDomBody.createTextRange();
                    $range.collapse(true);
                    $range.select();
                }
                var selection = editor.getSelection();    // 将当前光标,选择区域滚动到可视区域
github kissyteam / kissy / src / editor / sub-modules / plugin / checkbox-source-area / coverage / src / checkbox-source-area.js View on Github external
KISSY.add(function(S, require) {
  _$jscoverage['/checkbox-source-area.js'].functionData[0]++;
  _$jscoverage['/checkbox-source-area.js'].lineData[8]++;
  var Editor = require('editor');
  _$jscoverage['/checkbox-source-area.js'].lineData[9]++;
  var util = require('util');
  _$jscoverage['/checkbox-source-area.js'].lineData[10]++;
  var Node = require('node');
  _$jscoverage['/checkbox-source-area.js'].lineData[12]++;
  var SOURCE_MODE = Editor.Mode.SOURCE_MODE, WYSIWYG_MODE = Editor.Mode.WYSIWYG_MODE;
  _$jscoverage['/checkbox-source-area.js'].lineData[15]++;
  function CheckboxSourceArea(editor) {
    _$jscoverage['/checkbox-source-area.js'].functionData[1]++;
    _$jscoverage['/checkbox-source-area.js'].lineData[16]++;
    var self = this;
    _$jscoverage['/checkbox-source-area.js'].lineData[17]++;
    self.editor = editor;
    _$jscoverage['/checkbox-source-area.js'].lineData[18]++;
    self._init();
  }
  _$jscoverage['/checkbox-source-area.js'].lineData[21]++;
  util.augment(CheckboxSourceArea, {
  _init: function() {
  _$jscoverage['/checkbox-source-area.js'].functionData[2]++;
  _$jscoverage['/checkbox-source-area.js'].lineData[23]++;
  var self = this, editor = self.editor, statusBarEl = editor.get('statusBarEl');
github kissyteam / kissy / src / editor / sub-modules / plugin / remove-format / coverage / src / remove-format.js View on Github external
pluginRenderUI: function(editor) {
  _$jscoverage['/remove-format.js'].functionData[2]++;
  _$jscoverage['/remove-format.js'].lineData[16]++;
  formatCmd.init(editor);
  _$jscoverage['/remove-format.js'].lineData[17]++;
  editor.addButton('removeFormat', {
  tooltip: '\u6e05\u9664\u683c\u5f0f', 
  listeners: {
  click: function() {
  _$jscoverage['/remove-format.js'].functionData[3]++;
  _$jscoverage['/remove-format.js'].lineData[21]++;
  editor.execCommand('removeFormat');
}}, 
  mode: Editor.Mode.WYSIWYG_MODE});
}});
  _$jscoverage['/remove-format.js'].lineData[29]++;
github kissyteam / kissy / src / editor / sub-modules / plugin / justify-right / coverage / src / justify-right.js View on Github external
_$jscoverage['/justify-right.js'].lineData[34]++;
  if (visit1_34_1(editor.get('mode') === Editor.Mode.SOURCE_MODE)) {
    _$jscoverage['/justify-right.js'].lineData[35]++;
    return;
  }
  _$jscoverage['/justify-right.js'].lineData[37]++;
  if (visit2_37_1(editor.queryCommandValue('justifyRight'))) {
    _$jscoverage['/justify-right.js'].lineData[38]++;
    self.set('checked', true);
  } else {
    _$jscoverage['/justify-right.js'].lineData[40]++;
    self.set('checked', false);
  }
});
}}, 
  mode: Editor.Mode.WYSIWYG_MODE});
  _$jscoverage['/justify-right.js'].lineData[49]++;
  editor.docReady(function() {
  _$jscoverage['/justify-right.js'].functionData[6]++;
  _$jscoverage['/justify-right.js'].lineData[50]++;
  editor.get('document').on('keydown', function(e) {
  _$jscoverage['/justify-right.js'].functionData[7]++;
  _$jscoverage['/justify-right.js'].lineData[51]++;
  if (visit3_51_1(e.ctrlKey && visit4_51_2(e.keyCode === Node.KeyCode.R))) {
    _$jscoverage['/justify-right.js'].lineData[52]++;
    editor.execCommand('justifyRight');
    _$jscoverage['/justify-right.js'].lineData[53]++;
    e.preventDefault();
  }
});
});
}});
github kissyteam / kissy / build / editor / plugin / menubutton.js View on Github external
Editor.prototype.addSelect = function(id, cfg, SelectType) {
    SelectType = SelectType || MenuButton.Select;
    var self = this, prefixCls = self.get("prefixCls") + "editor-";
    if(cfg) {
      cfg.editor = self;
      if(cfg.menu) {
        cfg.menu.zIndex = Editor.baseZIndex(Editor.ZIndexManager.SELECT)
      }
      if(cfg.elCls) {
        cfg.elCls = prefixCls + cfg.elCls
      }
    }
    var s = (new SelectType(S.mix({render:self.get("toolBarEl"), prefixCls:prefixCls}, cfg))).render();
    if(cfg.mode === Editor.Mode.WYSIWYG_MODE) {
      self.on("wysiwygMode", function() {
        s.set("disabled", false)
      });
      self.on("sourceMode", function() {
        s.set("disabled", true)
      })
    }
    self.addControl(id + "/select", s);
    return s
  };
  return MenuButton
github kissyteam / kissy / build / editor / plugin / color / btn-debug.js View on Github external
if (t.hasClass(prefixCls + 'editor-color-a')) {
                    self.fire('selectColor', { color: t.style('background-color') });
                } else if (t.hasClass(prefixCls + 'editor-color-remove')) {
                    self.fire('selectColor', { color: null });
                }
            },
            destructor: function () {
                var self = this;
                if (self.colorWin) {
                    self.colorWin.destroy();
                }
            }
        }, {
            ATTRS: {
                checkable: { value: true },
                mode: { value: Editor.Mode.WYSIWYG_MODE }
            }
        });
    var tpl = '<div class="{icon}"></div>' + '<div class="{indicator}" style="background-color:{defaultColor}"></div>';
    function runCmd(editor, cmdType, color) {
        setTimeout(function () {
            editor.execCommand(cmdType, color);
        }, 0);
    }
    ColorButton.init = function (editor, cfg) {
        var prefix = editor.get('prefixCls') + 'editor-toolbar-', cmdType = cfg.cmdType, defaultColor = cfg.defaultColor, tooltip = cfg.tooltip;
        var button = editor.addButton(cmdType, {
                elCls: cmdType + 'Btn',
                content: util.substitute(tpl, {
                    defaultColor: defaultColor,
                    icon: prefix + 'item ' + prefix + cmdType,
                    indicator: prefix + 'color-indicator'
github kissyteam / kissy / build / editor / plugin / outdent.js View on Github external
editor.addButton("outdent", {tooltip:"\u51cf\u5c11\u7f29\u8fdb\u91cf", listeners:{click:function() {
      editor.execCommand("outdent");
      editor.focus()
    }, afterSyncUI:function() {
      var self = this;
      editor.on("selectionChange", function() {
        if(editor.get("mode") === Editor.Mode.SOURCE_MODE) {
          return
        }
        if(editor.queryCommandValue("outdent")) {
          self.set("disabled", false)
        }else {
          self.set("disabled", true)
        }
      })
    }}, mode:Editor.Mode.WYSIWYG_MODE})
  }});
  return outdent