Skip to content

Instantly share code, notes, and snippets.

@anthonyjb
Created June 9, 2016 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonyjb/39b8d7242b7f520343bd7c4cebabcd82 to your computer and use it in GitHub Desktop.
Save anthonyjb/39b8d7242b7f520343bd7c4cebabcd82 to your computer and use it in GitHub Desktop.
Custom H3 Tool
class ContentTools.Tools.H3 extends ContentTools.Tools.Heading
# Convert the current text block to a H3
# Store the tool on the tool shelf
ContentTools.ToolShelf.stow(@, 'h3')
# Configure the tool
@label = 'Heading 3'
@icon = 'subheading' # (or add a custom icon)
@tagName = 'h3'
# Place the tool in the default toolbox
ContentTools.DEFAULT_TOOLS[1] = [
'heading',
'subheading',
'h3',
'paragraph',
'unordered-list',
'ordered-list',
'table',
'indent',
'unindent',
'line-break'
]
ContentTools.Tools.H3 = (function(_super) {
// Convert the current text block to a H3
__extends(H3, _super);
function H3() {
return H3.__super__.constructor.apply(this, arguments);
}
// Store the tool on the tool shelf
ContentTools.ToolShelf.stow(H3, 'h3');
// Configure the tool
H3.label = 'H3';
H3.icon = 'subheading'; // (or add a custom icon)
H3.tagName = 'h3';
return H3;
})(ContentTools.Tools.Heading);
// Place the tool in the default toolbox
ContentTools.DEFAULT_TOOLS[1] = [
'heading',
'subheading',
'h3',
'paragraph',
'unordered-list',
'ordered-list',
'table',
'indent',
'unindent',
'line-break'
];
// Inheritance in CoffeeScript is handled by a set of predefined functions, if
// your JS doesn't have access to these you will need to define them directly to
// inherit from the Heading tool as ContentTools doesn't directly expose them.
var __slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment