| 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 | 1×
1×
1×
1×
1×
142×
142×
10×
132×
123×
123×
9×
1×
136×
136×
6×
130×
125×
5×
1×
136×
136×
2×
134×
129×
129×
5×
1×
136×
136×
2×
134×
130×
130×
4×
1×
135×
1×
135×
1×
135×
135×
2×
133×
1×
3×
1×
2×
1×
5×
5×
5×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
| define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FormattingHelper = (function () {
function FormattingHelper() {
}
FormattingHelper.isBold = function (node) {
var nodeName = node.nodeName.toLowerCase();
if (this.validBoldTags.has(nodeName)) {
return true;
}
else if (this.inlineTagsSet.has(nodeName) && node.style) {
var fontWeight = node.style.fontWeight;
return fontWeight && (fontWeight === 'bold' || parseInt(fontWeight, 10) >= 600);
}
return false;
};
FormattingHelper.isItalic = function (node) {
var nodeName = node.nodeName.toLowerCase();
if (this.validItalicTags.has(nodeName)) {
return true;
}
if (this.inlineTagsSet.has(nodeName) && node.style) {
return node.style.fontStyle === 'italic';
}
return false;
};
FormattingHelper.isUnderline = function (node) {
var nodeName = node.nodeName.toLowerCase();
if (this.validUnderlineTags.has(nodeName)) {
return true;
}
if (this.inlineTagsSet.has(nodeName) && node.style) {
var style = node.style;
return style.textDecoration === 'underline' || style.textDecorationLine === 'underline';
}
return false;
};
FormattingHelper.isStrikethrough = function (node) {
var nodeName = node.nodeName.toLowerCase();
if (this.validStrikethroughTags.has(nodeName)) {
return true;
}
if (this.inlineTagsSet.has(nodeName) && node.style) {
var style = node.style;
return style.textDecoration === 'line-through' || style.textDecorationLine === 'line-through';
}
return false;
};
FormattingHelper.isSuperscript = function (node) {
return this.validSuperscriptTags.has(node.nodeName.toLowerCase());
};
FormattingHelper.isSubscript = function (node) {
return this.validSubscriptTags.has(node.nodeName.toLowerCase());
};
FormattingHelper.isInlineCode = function (node) {
var nodeName = node.nodeName.toLowerCase();
if (this.validInlineCodeTags.has(nodeName)) {
return true;
}
return false;
};
FormattingHelper.getFontColor = function (node) {
return this.getStyleProperty(node, 'color');
};
FormattingHelper.getBackgroundColor = function (node) {
return this.getStyleProperty(node, 'backgroundColor');
};
FormattingHelper.getStyleProperty = function (node, property) {
var nodeName = node.nodeName.toLowerCase();
Eif (this.inlineTagsSet.has(nodeName) && node.style) {
return node.style[property] || '';
}
return '';
};
FormattingHelper.validBoldTags = new Set(['strong', 'b']);
FormattingHelper.validItalicTags = new Set(['em', 'i']);
FormattingHelper.validUnderlineTags = new Set(['u']);
FormattingHelper.validStrikethroughTags = new Set(['del', 'strike', 's']);
FormattingHelper.validSuperscriptTags = new Set(['sup']);
FormattingHelper.validSubscriptTags = new Set(['sub']);
FormattingHelper.validInlineCodeTags = new Set(['code']);
FormattingHelper.inlineTagsSet = new Set(['a', 'abbr', 'acronym', 'b', 'bdo', 'big', 'cite', 'code', 'dfn', 'em',
'font', 'i', 'kbd', 'label', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'u', 'var', 'del']);
return FormattingHelper;
}());
exports.FormattingHelper = FormattingHelper;
});
|