diff --git a/ep_headings/.gitignore b/ep_headings/.gitignore new file mode 100644 index 0000000..9a0e97c --- /dev/null +++ b/ep_headings/.gitignore @@ -0,0 +1,2 @@ +.ep_initialized +npm_debug.log diff --git a/ep_headings/ep.json b/ep_headings/ep.json index 1b57928..23cdb3f 100644 --- a/ep_headings/ep.json +++ b/ep_headings/ep.json @@ -14,7 +14,8 @@ "hooks": { "eejsBlock_editbarMenuLeft": "ep_headings/index", "collectContentPre": "ep_headings/static/js/shared", - "collectContentPost": "ep_headings/static/js/shared" + "collectContentPost": "ep_headings/static/js/shared", + "eejsBlock_dd_format":"ep_headings/index" } } ] diff --git a/ep_headings/index.js b/ep_headings/index.js index f392815..399ee19 100644 --- a/ep_headings/index.js +++ b/ep_headings/index.js @@ -4,4 +4,9 @@ var eejs = require('ep_etherpad-lite/node/eejs/'); exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) { args.content = args.content + eejs.require("ep_headings/templates/editbarButtons.ejs"); return cb(); -} \ No newline at end of file +} + +exports.eejsBlock_dd_format = function (hook_name, args, cb) { + args.content = args.content + eejs.require("ep_headings/templates/fileMenu.ejs"); + return cb(); +} diff --git a/ep_headings/package.json b/ep_headings/package.json index b8363c3..081c19f 100644 --- a/ep_headings/package.json +++ b/ep_headings/package.json @@ -1,13 +1,16 @@ { "description": "Adds heading support to Etherpad Lite.", "name": "ep_headings", - "version": "0.1.5", + "version": "0.1.6", "author": "fourplusone ", "contributors": [ { "name": "Matthias Bartelmeß", "email": "mba@fourplusone.de" - } + }, + { "name": "John McLear", + "email": "john@mclear.co.uk" + } ], "dependencies": {}, "engines": { diff --git a/ep_headings/static/css/editor.css b/ep_headings/static/css/editor.css index 395e482..e9c7159 100644 --- a/ep_headings/static/css/editor.css +++ b/ep_headings/static/css/editor.css @@ -13,4 +13,6 @@ h3 { font-size: 1.17em; } h5 { font-size: .83em; } -h6 { font-size: .75em; } \ No newline at end of file +h6 { font-size: .75em; } + +h7 { font-family:monospace; } diff --git a/ep_headings/static/js/index.js b/ep_headings/static/js/index.js index fe42168..2291764 100644 --- a/ep_headings/static/js/index.js +++ b/ep_headings/static/js/index.js @@ -6,27 +6,43 @@ var headingClass = 'heading'; var cssFiles = ['ep_headings/static/css/editor.css']; // All our tags are block elements, so we just return them. -var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']; +var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7']; var aceRegisterBlockElements = function(){ return tags; } // Bind the event handler to the toolbar buttons var postAceInit = function(hook, context){ - var hs = $('#heading-selection'); + var hs = $('.heading-selection'); hs.on('change', function(){ var value = $(this).val(); var intValue = parseInt(value,10); if(!_.isNaN(intValue)){ - context.ace.callWithAce(function(ace){ - ace.ace_doInsertHeading(intValue); - },'insertheading' , true); - hs.val("dummy"); + applyHeading(context, intValue); } + // give focus to editor (required for FF) + $('iframe[name="ace_outer"]').contents().find('iframe[name="ace_inner"]').focus(); }) + $('.ep_heading_n').click(function(){applyHeading(context,-1)}); + $('.ep_heading_h1').click(function(){applyHeading(context,0)}); + $('.ep_heading_h2').click(function(){applyHeading(context,1)}); + $('.ep_heading_h3').click(function(){applyHeading(context,2)}); + $('.ep_heading_h4').click(function(){applyHeading(context,3)}); + $('.ep_heading_h5').click(function(){applyHeading(context,4)}); + $('.ep_heading_h6').click(function(){applyHeading(context,5)}); + $('.ep_heading_m').click(function(){applyHeading(context,6)}); }; +function applyHeading(context, heading){ + context.ace.callWithAce(function(ace){ + ace.ace_doInsertHeading(heading); + },'insertheading' , true); + $('.heading-selection').val("dummy"); + + // give focus back to editor + $('iframe[name="ace_outer"]').contents().find('iframe[name="ace_inner"]').contents().find("#innerdocbody").focus(); +} // Our heading attribute will result in a heaading:h1... :h6 class function aceAttribsToClasses(hook, context){ diff --git a/ep_headings/static/js/shared.js b/ep_headings/static/js/shared.js index 88efb51..c5bc327 100644 --- a/ep_headings/static/js/shared.js +++ b/ep_headings/static/js/shared.js @@ -1,6 +1,6 @@ var _ = require('ep_etherpad-lite/static/js/underscore'); -var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']; +var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7']; var collectContentPre = function(hook, context){ var tname = context.tname; diff --git a/ep_headings/templates/editbarButtons.ejs b/ep_headings/templates/editbarButtons.ejs index f1f985e..fdf6e92 100644 --- a/ep_headings/templates/editbarButtons.ejs +++ b/ep_headings/templates/editbarButtons.ejs @@ -1,6 +1,6 @@
  • -
  • - @@ -9,5 +9,6 @@ + -
  • \ No newline at end of file + diff --git a/ep_headings/templates/fileMenu.ejs b/ep_headings/templates/fileMenu.ejs new file mode 100644 index 0000000..e3d342c --- /dev/null +++ b/ep_headings/templates/fileMenu.ejs @@ -0,0 +1,14 @@ +
    +
  • Heading + +
  • +