forked from ether/ep_align
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (55 loc) · 1.6 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var eejs = require('ep_etherpad-lite/node/eejs/');
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_align/templates/editbarButtons.ejs");
return cb();
}
exports.eejsBlock_dd_format = function (hook_name, args, cb) {
args.content = args.content + eejs.require("ep_align/templates/fileMenu.ejs");
return cb();
}
function getInlineStyle(header) {
// TODO!
switch (header) {
case "h1":
return "font-size: 2.0em;line-height: 120%;";
break;
case "h2":
return "font-size: 1.5em;line-height: 120%;";
break;
case "h3":
return "font-size: 1.17em;line-height: 120%;";
break;
case "h4":
return "line-height: 120%;";
break;
case "h5":
return "font-size: 0.83em;line-height: 120%;";
break;
case "h6":
return "font-size: 0.75em;line-height: 120%;";
break;
case "code":
return "font-family: monospace";
}
return "";
}
// line, apool,attribLine,text
exports.getLineHTMLForExport = function (hook, context) {
var header = _analyzeLine(context.attribLine, context.apool);
if (header) {
var inlineStyle = getInlineStyle(header);
return "<" + header + " style=\"" + inlineStyle + "\">" + context.text.substring(1) + "</" + header + ">";
}
}
function _analyzeLine(alineAttrs, apool) {
var header = null;
if (alineAttrs) {
var opIter = Changeset.opIterator(alineAttrs);
if (opIter.hasNext()) {
var op = opIter.next();
header = Changeset.opAttributeValue(op, 'align', apool);
}
}
return header;
}