-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
54 lines (45 loc) · 1.41 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
module.exports = enable;
function enable (doc) {
doc.body.contentEditable = true;
return {
exec: call(doc),
bold: call(doc, 'bold'),
italic: call(doc, 'italic'),
underline: call(doc, 'underline'),
color: call(doc, 'foreColor'),
bgcolor: call(doc, 'backColor'),
fontName: call(doc, 'fontName'),
fontSize: call(doc, 'fontSize'),
plain: call(doc, 'removeFormat'),
center: call(doc, 'justifyCenter'),
justify: call(doc, 'justifyFull'),
left: call(doc, 'justifyLeft'),
right: call(doc, 'justifyRight'),
indent: call(doc, 'indent'),
outdent: call(doc, 'outdent'),
img: call(doc, 'insertImage'),
link: call(doc, 'createLink'),
unlink: call(doc, 'unlink'),
orderedList: call(doc, 'insertOrderedList'),
unorderedList: call(doc, 'insertUnorderedList'),
selectAll: call(doc, 'selectAll'),
undo: call(doc, 'undo'),
redo: call(doc, 'redo'),
copy: call(doc, 'copy'),
paste: call(doc, 'paste'),
delete: call(doc, 'delete'),
heading: call(doc, 'heading')
};
}
function exec (doc, cmd, value, showDefaultUI) {
doc.execCommand(cmd, showDefaultUI || false, value);
};
function call (doc, commandName) {
return arguments.length == 1 ? custom : command;
function custom (commandName, value, ui) {
return exec(doc, commandName, value, ui);
}
function command (value, ui) {
return exec(doc, commandName, value, ui);
}
}