Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ep_headings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.ep_initialized
npm_debug.log
3 changes: 2 additions & 1 deletion ep_headings/ep.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
Expand Down
7 changes: 6 additions & 1 deletion ep_headings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

exports.eejsBlock_dd_format = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_headings/templates/fileMenu.ejs");
return cb();
}
7 changes: 5 additions & 2 deletions ep_headings/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"description": "Adds heading support to Etherpad Lite.",
"name": "ep_headings",
"version": "0.1.5",
"version": "0.1.6",
"author": "fourplusone <info@fourplusone.de>",
"contributors": [
{
"name": "Matthias Bartelmeß",
"email": "mba@fourplusone.de"
}
},
{ "name": "John McLear",
"email": "john@mclear.co.uk"
}
],
"dependencies": {},
"engines": {
Expand Down
4 changes: 3 additions & 1 deletion ep_headings/static/css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ h3 { font-size: 1.17em; }

h5 { font-size: .83em; }

h6 { font-size: .75em; }
h6 { font-size: .75em; }

h7 { font-family:monospace; }
28 changes: 22 additions & 6 deletions ep_headings/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion ep_headings/static/js/shared.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 4 additions & 3 deletions ep_headings/templates/editbarButtons.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<li class="separator acl-write"></li>
<li id="headings" class="acl-write">
<select id="heading-selection">
<li class="headings acl-write">
<select class="heading-selection">
<option value="dummy" selected>Heading</option>
<option value="-1">Normal</option>
<option value="0">Heading 1</option>
Expand All @@ -9,5 +9,6 @@
<option value="3">Heading 4</option>
<option value="4">Heading 5</option>
<option value="5">Heading 6</option>
<option value="6">Monospace</option>
</select>
</li>
</li>
14 changes: 14 additions & 0 deletions ep_headings/templates/fileMenu.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<hr>
<li><a href="#" data-key="align">Heading</a>
<ul class="submenu">
<li><a href="#" class="ep_heading_n">Normal</a></li>
<li><a href="#" class="ep_heading_h1">Heading 1</a></li>
<li><a href="#" class="ep_heading_h2">Heading 2</a></li>
<li><a href="#" class="ep_heading_h3">Heading 3</a></li>
<li><a href="#" class="ep_heading_h4">Heading 4</a></li>
<li><a href="#" class="ep_heading_h5">Heading 5</a></li>
<li><a href="#" class="ep_heading_h6">Heading 6</a></li>
<li><a href="#" class="ep_heading_m">Monospace</a></li>
</ul>
</li>