How to use the editor.Style 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 / src / editor / sub-modules / plugin / color / cmd / src / cmd.js View on Github external
function applyColor(editor, c, styles) {
    var doc = editor.get('document')[0];
    editor.execCommand('save');
    if (c) {
        new Editor.Style(styles, {
            color: c
        }).apply(doc);
    } else {
        // Value 'inherit'  is treated as a wildcard,
        // which will match any value.
        //清除已设格式
        new Editor.Style(styles, {
            color: 'inherit'
        }).remove(doc);
    }
    editor.execCommand('save');
}
github kissyteam / kissy / src / editor / sub-modules / plugin / strike-through / sub-modules / cmd / src / cmd.js View on Github external
/**
 * @ignore
 * strike-through command
 * @author yiminghe@gmail.com
 */

var Editor = require('editor');
var Cmd = require('../font/cmd');

var STRIKE_STYLE = new Editor.Style({
    element: 'del',
    overrides: [
        {
            element: 'span',
            attributes: {
                style: 'text-decoration: line-through;'
            }
        },
        {
            element: 's'
        },
        {
            element: 'strike'
        }
    ]
});
github kissyteam / kissy / src / editor / sub-modules / plugin / bold / sub-modules / cmd / src / cmd.js View on Github external
/**
 * @ignore
 * bold command.
 * @author yiminghe@gmail.com
 */

var Editor = require('editor');
var Cmd = require('../font/cmd');
var BOLD_STYLE = new Editor.Style({
    element: 'strong',
    overrides: [
        {
            element: 'b'
        },
        {
            element: 'span',
            attributes: {
                style: 'font-weight: bold;'
            }
        }
    ]
});
module.exports = {
    init: function (editor) {
        Cmd.addButtonCmd(editor, 'bold', BOLD_STYLE);
github kissyteam / kissy / build / editor / plugin / underline / cmd-debug.js View on Github external
], function (S, require, exports, module) {
    /**
 * @ignore
 * underline command
 * @author yiminghe@gmail.com
 */
    var Editor = require('editor');
    var Cmd = require('../font/cmd');
    var UNDERLINE_STYLE = new Editor.Style({
            element: 'u',
            overrides: [{
                    element: 'span',
                    attributes: { style: 'text-decoration: underline;' }
                }]
        });
    module.exports = {
        init: function (editor) {
            Cmd.addButtonCmd(editor, 'underline', UNDERLINE_STYLE);
        }
    };
});
github kissyteam / kissy / src / editor / sub-modules / plugin / heading / sub-modules / cmd / coverage / src / cmd.js View on Github external
_$jscoverage['/cmd.js'].lineData[16]++;
  var currentValue;
  _$jscoverage['/cmd.js'].lineData[17]++;
  editor.execCommand('save');
  _$jscoverage['/cmd.js'].lineData[18]++;
  if (visit2_18_1(tag !== 'p')) {
    _$jscoverage['/cmd.js'].lineData[19]++;
    currentValue = editor.queryCommandValue('heading');
  }
  _$jscoverage['/cmd.js'].lineData[21]++;
  if (visit3_21_1(tag === currentValue)) {
    _$jscoverage['/cmd.js'].lineData[22]++;
    tag = 'p';
  }
  _$jscoverage['/cmd.js'].lineData[24]++;
  new Editor.Style({
  element: tag}).apply(editor.get('document')[0]);
  _$jscoverage['/cmd.js'].lineData[27]++;
  editor.execCommand('save');
}});
    _$jscoverage['/cmd.js'].lineData[31]++;
github kissyteam / kissy / build / editor / plugin / strike-through / cmd-debug.js View on Github external
], function (S, require, exports, module) {
    /**
 * @ignore
 * strike-through command
 * @author yiminghe@gmail.com
 */
    var Editor = require('editor');
    var Cmd = require('../font/cmd');
    var STRIKE_STYLE = new Editor.Style({
            element: 'del',
            overrides: [
                {
                    element: 'span',
                    attributes: { style: 'text-decoration: line-through;' }
                },
                { element: 's' },
                { element: 'strike' }
            ]
        });
    module.exports = {
        init: function (editor) {
            Cmd.addButtonCmd(editor, 'strikeThrough', STRIKE_STYLE);
        }
    };
});
github kissyteam / kissy / build / editor / plugin / heading / cmd-debug.js View on Github external
exec: function (editor, tag) {
                        var currentValue;
                        editor.execCommand('save');
                        if (tag !== 'p') {
                            currentValue = editor.queryCommandValue('heading');
                        }
                        if (tag === currentValue) {
                            tag = 'p';
                        }
                        new Editor.Style({ element: tag }).apply(editor.get('document')[0]);
                        editor.execCommand('save');
                    }
                });
github kissyteam / kissy / src / editor / sub-modules / plugin / strike-through / sub-modules / cmd / coverage / src / cmd.js View on Github external
KISSY.add(function(S, require) {
  _$jscoverage['/cmd.js'].functionData[0]++;
  _$jscoverage['/cmd.js'].lineData[7]++;
  var Editor = require('editor');
  _$jscoverage['/cmd.js'].lineData[8]++;
  var Cmd = require('../font/cmd');
  _$jscoverage['/cmd.js'].lineData[10]++;
  var STRIKE_STYLE = new Editor.Style({
  element: 'del', 
  overrides: [{
  element: 'span', 
  attributes: {
  style: 'text-decoration: line-through;'}}, {
  element: 's'}, {
  element: 'strike'}]});
  _$jscoverage['/cmd.js'].lineData[27]++;
  return {
  init: function(editor) {
  _$jscoverage['/cmd.js'].functionData[1]++;
  _$jscoverage['/cmd.js'].lineData[29]++;
  Cmd.addButtonCmd(editor, "strikeThrough", STRIKE_STYLE);
}};
});
github kissyteam / kissy / src / editor / sub-modules / plugin / underline / sub-modules / cmd / coverage / src / cmd.js View on Github external
KISSY.add(function(S, require) {
  _$jscoverage['/cmd.js'].functionData[0]++;
  _$jscoverage['/cmd.js'].lineData[7]++;
  var Editor = require('editor');
  _$jscoverage['/cmd.js'].lineData[8]++;
  var Cmd = require('../font/cmd');
  _$jscoverage['/cmd.js'].lineData[10]++;
  var UNDERLINE_STYLE = new Editor.Style({
  element: 'u', 
  overrides: [{
  element: 'span', 
  attributes: {
  style: 'text-decoration: underline;'}}]});
  _$jscoverage['/cmd.js'].lineData[21]++;
  return {
  init: function(editor) {
  _$jscoverage['/cmd.js'].functionData[1]++;
  _$jscoverage['/cmd.js'].lineData[23]++;
  Cmd.addButtonCmd(editor, "underline", UNDERLINE_STYLE);
}};
});
github kissyteam / kissy / src / editor / sub-modules / plugin / font / cmd / coverage / src / cmd.js View on Github external
exec: function(editor, value) {
  _$jscoverage['/cmd.js'].functionData[7]++;
  _$jscoverage['/cmd.js'].lineData[93]++;
  editor.focus();
  _$jscoverage['/cmd.js'].lineData[94]++;
  var currentValue = visit15_94_1(editor.queryCommandValue(cmdType) || '');
  _$jscoverage['/cmd.js'].lineData[95]++;
  var style = new Editor.Style(styleObj, {
  value: value}), doc = editor.get('document')[0];
  _$jscoverage['/cmd.js'].lineData[99]++;
  editor.execCommand('save');
  _$jscoverage['/cmd.js'].lineData[100]++;
  if (visit16_100_1(value.toLowerCase() === currentValue.toLowerCase())) {
    _$jscoverage['/cmd.js'].lineData[101]++;
    style.remove(doc);
  } else {
    _$jscoverage['/cmd.js'].lineData[103]++;
    style.apply(doc);
  }
  _$jscoverage['/cmd.js'].lineData[105]++;
  editor.execCommand('save');
}});
    _$jscoverage['/cmd.js'].lineData[108]++;