diff --git a/.editorconfig b/.editorconfig index 0f09989..8f96039 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,7 @@ root = true [*] indent_style = space -indent_size = 2 +indent_size = 4 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true diff --git a/Plumbing.js b/Plumbing.js index c348f6b..f54eebf 100644 --- a/Plumbing.js +++ b/Plumbing.js @@ -6,7 +6,7 @@ var all = require('plumber-all'); var glob = require('plumber-glob'); -var requireJS = require('plumber-requirejs'); +var traceur = require('plumber-traceur'); var uglifyJS = require('plumber-uglifyjs'); var write = require('plumber-write'); @@ -20,7 +20,7 @@ module.exports = function (pipelines) { pipelines['build'] = [ glob('src/scribe-plugin-heading-command.js'), - requireJS(), + traceur.toAmd(), writeBoth ]; }; diff --git a/package.json b/package.json index b60adc6..87411dc 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "plumber": "~0.3.0", "plumber-all": "~0.3.0", "plumber-glob": "~0.3.0", - "plumber-requirejs": "~0.3.0", "plumber-uglifyjs": "~0.3.0", - "plumber-write": "~0.3.0" + "plumber-write": "~0.3.0", + "plumber-traceur": "~0.3.2" }, "repository": { "type": "git", diff --git a/src/scribe-plugin-heading-command.js b/src/scribe-plugin-heading-command.js index 3f22a68..e9b99c5 100644 --- a/src/scribe-plugin-heading-command.js +++ b/src/scribe-plugin-heading-command.js @@ -1,54 +1,51 @@ -define(function () { - /** - * This plugin adds a command for headings. - */ +/** + * This plugin adds a command for headings. + */ - 'use strict'; - - return function (level) { +function headingCommandPlugin(level) { return function (scribe) { - var tag = ''; - var nodeName = 'H' + level; - var commandName = 'h' + level; - - /** - * Chrome: the `heading` command doesn't work. Supported by Firefox only. - */ - - var headingCommand = new scribe.api.Command('formatBlock'); - - headingCommand.execute = function () { - if (this.queryState()) { - scribe.api.Command.prototype.execute.call(this, '

'); - } else { - scribe.api.Command.prototype.execute.call(this, tag); - } - }; - - headingCommand.queryState = function () { - var selection = new scribe.api.Selection(); - return !! selection.getContaining(function (node) { - return node.nodeName === nodeName; - }); - }; - - /** - * All: Executing a heading command inside a list element corrupts the markup. - * Disabling for now. - */ - headingCommand.queryEnabled = function () { - var selection = new scribe.api.Selection(); - var listNode = selection.getContaining(function (node) { - return node.nodeName === 'OL' || node.nodeName === 'UL'; - }); - - return scribe.api.Command.prototype.queryEnabled.apply(this, arguments) - && scribe.allowsBlockElements() && ! listNode; - }; - - scribe.commands[commandName] = headingCommand; + var tag = ''; + var nodeName = 'H' + level; + var commandName = 'h' + level; + + /** + * Chrome: the `heading` command doesn't work. Supported by Firefox only. + */ + + var headingCommand = new scribe.api.Command('formatBlock'); + + headingCommand.execute = function () { + if (this.queryState()) { + scribe.api.Command.prototype.execute.call(this, '

'); + } else { + scribe.api.Command.prototype.execute.call(this, tag); + } + }; + + headingCommand.queryState = function () { + var selection = new scribe.api.Selection(); + return !! selection.getContaining(function (node) { + return node.nodeName === nodeName; + }); + }; + + /** + * All: Executing a heading command inside a list element corrupts the markup. + * Disabling for now. + */ + headingCommand.queryEnabled = function () { + var selection = new scribe.api.Selection(); + var listNode = selection.getContaining(function (node) { + return node.nodeName === 'OL' || node.nodeName === 'UL'; + }); + + return scribe.api.Command.prototype.queryEnabled.apply(this, arguments) + && scribe.allowsBlockElements() && ! listNode; + }; + + scribe.commands[commandName] = headingCommand; }; - }; +}; -}); +export default headingCommandPlugin;