19 include_once($ROOT_PATH.
'wysiwyg_plugin.inc');
46 $this->_add_button(
'bold',
'Bold',
'Bold',
'false',
'14');
47 $this->_add_button(
'italic',
'Italic',
'Italic',
'false',
'15');
48 $this->_add_button(
'underline',
'Underline',
'Underline',
'false',
'16');
49 $this->_add_button(
'strikethrough',
'StrikeThrough',
'StrikeThrough',
'false',
'17');
62 <script type=
"text/javascript" language=
"Javascript">
65 HTMLArea.prototype._convertTags =
function(fromTag, toTag) {
72 if (fromTag == null || toTag == null) {
76 fromTag = fromTag.toLowerCase();
77 toTag = toTag.toLowerCase();
80 var sel = this._getSelection();
81 var parent = this.parentBlock(this.getParentElement());
82 var elements = parent.getElementsByTagName(fromTag);
85 var elementsArray = [];
86 for(var i = 0; i<elements.length; i++) {
87 if (sel.containsNode(elements[i],
true)) {
88 elementsArray.push(elements[i]);
93 var anchorNode = sel.anchorNode;
94 var anchorOffset = sel.anchorOffset;
95 var focusNode = sel.focusNode;
96 var focusOffset = sel.focusOffset;
99 for(var j = 0; j< elementsArray.length; j++) {
100 var replacementEl = document.createElement(toTag);
101 replacementEl.innerHTML = elementsArray[j].innerHTML;
102 elementsArray[j].parentNode.replaceChild(replacementEl, elementsArray[j]);
105 var oldAnchorTextNode = elementsArray[j].firstChild;
106 var newAnchorTextNode = replacementEl.firstChild;
107 while(oldAnchorTextNode.nodeName !=
'#text' && oldAnchorTextNode.hasChildNodes()) {
108 newAnchorTextNode = newAnchorTextNode.firstChild;
109 oldAnchorTextNode = oldAnchorTextNode.firstChild;
111 var oldFocusTextNode = elementsArray[j].lastChild;
112 var newFocusTextNode = replacementEl.lastChild;
113 while(oldFocusTextNode.nodeName !=
'#text' && oldFocusTextNode.hasChildNodes()) {
114 newFocusTextNode = newFocusTextNode.lastChild;
115 oldFocusTextNode = oldFocusTextNode.lastChild;
117 if (oldAnchorTextNode === anchorNode) {
118 anchorNode = newAnchorTextNode;
120 if (oldFocusTextNode === focusNode) {
121 focusNode = newFocusTextNode;
126 if (anchorNode != null && focusNode != null) {
127 var range = this._createRange();
128 range.setStart(anchorNode, anchorOffset);
129 range.setEnd(focusNode, focusOffset);
130 sel.removeAllRanges();
153 (!HTMLArea.is_ie) && (cmd =
"bold");
156 (!HTMLArea.is_ie) && (cmd =
"italic");
159 (!HTMLArea.is_ie) && (cmd =
"underline");
162 cmd =
"strikethrough";
179 this._doc.execCommand(cmdID, UI, param);
181 if (this._doc.queryCommandState(
"bold")) {
182 this._convertTags(
'b',
'strong');
186 this._doc.execCommand(cmdID, UI, param);
188 if (this._doc.queryCommandState(
"italic")) {
189 this._convertTags(
'i',
'em');
193 this._doc.execCommand(cmdID, UI, param);
195 case "strikethrough":
196 this._doc.execCommand(cmdID, UI, param);