1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// JavaScript
class Editor {
constructor (sLang) {
this.xEditor = GetCurrentEditor();
this.lNode = [];
this.lParsableNodes = ["P", "LI"];
this.lRootNodes = ["DIV", "UL", "OL"];
};
* _getParsableNodes (xRootNode=this.xEditor.rootElement) {
// recursive function
try {
for (let xNode of xRootNode.childNodes) {
//echo("tag: " + xNode.tagName);
if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"
|
>
>
>
>
>
>
>
>
|
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
|
// JavaScript
class Editor {
constructor (sLang) {
this.xEditor = GetCurrentEditor();
this.lNode = [];
this.lParsableNodes = ["P", "LI"];
this.lRootNodes = ["DIV", "UL", "OL"];
};
_getTextFromNode (xNode) {
if ("innerHTML" in xNode) {
return xNode.innerHTML;
} else {
return xNode.textContent;
}
};
* _getParsableNodes (xRootNode=this.xEditor.rootElement) {
// recursive function
try {
for (let xNode of xRootNode.childNodes) {
//echo("tag: " + xNode.tagName);
if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
};
* getParagraphs () {
try {
let i = 0;
for (let xNode of this._getParsableNodes()) {
this.lNode.push(xNode);
yield [i, xNode.innerHTML];
i += 1;
}
} catch (e) {
Cu.reportError(e);
}
};
|
|
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
};
* getParagraphs () {
try {
let i = 0;
for (let xNode of this._getParsableNodes()) {
this.lNode.push(xNode);
yield [i, this._getTextFromNode(xNode)];
i += 1;
}
} catch (e) {
Cu.reportError(e);
}
};
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
} catch (e) {
Cu.reportError(e);
}
};
getParagraph (iPara) {
try {
return this.lNode[iPara].innerHTML;
} catch (e) {
Cu.reportError(e);
}
};
writeParagraph (iPara, sText) {
try {
this.lNode[iPara].innerHTML = sText;
} catch (e) {
Cu.reportError(e);
}
};
changeParagraph (iPara, sModif, iStart, iEnd) {
let sText = this.getParagraph(iPara);
|
|
>
>
|
>
>
>
|
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
90
|
} catch (e) {
Cu.reportError(e);
}
};
getParagraph (iPara) {
try {
return this._getTextFromNode(this.lNode[iPara]);
} catch (e) {
Cu.reportError(e);
}
};
writeParagraph (iPara, sText) {
try {
let xNode = this.lNode[iPara];
if ("innerHTML" in xNode) {
xNode.innerHTML = sText;
} else {
xNode.textContent = sText;
}
} catch (e) {
Cu.reportError(e);
}
};
changeParagraph (iPara, sModif, iStart, iEnd) {
let sText = this.getParagraph(iPara);
|