-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommands.js
34 lines (28 loc) · 913 Bytes
/
commands.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
// jshint strict: false
/**
* commands -
* utility to abstract the interface for document.execCommand
* @access protected
*/
import conf from '../config/config';
import browser from './browser';
const commands = {
exec (command, value=null, contextDocument=document) {
if (command === 'formatBlock') {
value = commands.prepBlockValue(value);
}
contextDocument.execCommand(command, false, value);
},
formatBlock (style, contextDocument=document) {
commands.exec('formatBlock', style, contextDocument);
},
defaultBlockFormat (contextDocument=document) {
commands.formatBlock(conf.defaultBlock, contextDocument);
},
prepBlockValue (value) {
const ieVersion = browser.ieVersion();
value = value.toUpperCase();
return ieVersion && ieVersion < 12 ? `<${value}>` : value;
}
};
export default commands;