⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 overview-summary-tinymce_control.class.js.html

📁 tinyMCE在线编辑器使用手册
💻 HTML
📖 第 1 页 / 共 5 页
字号:

								<span class="reserved">if</span> (scmd == <span class="literal">"removeformat"</span>) {
									ch[z].style.cssText = <span class="literal">''</span>;
									tinyMCE.setAttrib(ch[z], <span class="literal">'class'</span>, <span class="literal">''</span>);
								}
							}
						}
					}
				}

				<span class="comment">// Cleaup wrappers</span>
				var nodes = doc.getElementsByTagName(wrapper);
				<span class="reserved">for</span> (var i=nodes.length-1; i&gt;=0; i--) {
					var elm = nodes[i];
					var isNew = tinyMCE.getAttrib(elm, <span class="literal">"mce_new"</span>) == <span class="literal">"true"</span>;

					elm.removeAttribute(<span class="literal">"mce_new"</span>);

					<span class="comment">// Is only child a element</span>
					<span class="reserved">if</span> (elm.childNodes &amp;&amp; elm.childNodes.length == 1 &amp;&amp; elm.childNodes[0].nodeType == 1) {
						<span class="comment">//tinyMCE.debug("merge1" + isNew);</span>
						<span class="reserved">this</span>._mergeElements(scmd, elm, elm.childNodes[0], isNew);
						continue;
					}

					<span class="comment">// Is I the only child</span>
					<span class="reserved">if</span> (elm.parentNode.childNodes.length == 1 &amp;&amp; !invalidRe.test(elm.nodeName) &amp;&amp; !invalidRe.test(elm.parentNode.nodeName)) {
						<span class="comment">//tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);</span>
						<span class="reserved">if</span> (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))
							<span class="reserved">this</span>._mergeElements(scmd, elm.parentNode, elm, false);
					}
				}

				<span class="comment">// Remove empty wrappers</span>
				var nodes = doc.getElementsByTagName(wrapper);
				<span class="reserved">for</span> (var i=nodes.length-1; i&gt;=0; i--) {
					var elm = nodes[i];
					var isEmpty = true;

					<span class="comment">// Check if it has any attribs</span>
					var tmp = doc.createElement(<span class="literal">"body"</span>);
					tmp.appendChild(elm.cloneNode(false));

					<span class="comment">// Is empty span, remove it</span>
					tmp.innerHTML = tmp.innerHTML.replace(new RegExp(<span class="literal">'style=""|class=""'</span>, <span class="literal">'gi'</span>), <span class="literal">''</span>);
					<span class="comment">//tinyMCE.debug(tmp.innerHTML);</span>
					<span class="reserved">if</span> (new RegExp(<span class="literal">'&lt;span&gt;'</span>, <span class="literal">'gi'</span>).test(tmp.innerHTML)) {
						<span class="reserved">for</span> (var x=0; x&lt;elm.childNodes.length; x++) {
							<span class="reserved">if</span> (elm.parentNode != null)
								elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true), elm);
						}

						elm.parentNode.removeChild(elm);
					}
				}

				<span class="comment">// Re add the visual aids</span>
				<span class="reserved">if</span> (scmd == <span class="literal">"removeformat"</span>)
					tinyMCE.handleVisualAid(<span class="reserved">this</span>.getBody(), true, <span class="reserved">this</span>.visualAid, <span class="reserved">this</span>);

				tinyMCE.triggerNodeChange();

				break;

			case <span class="literal">"FontName"</span>:
				<span class="reserved">if</span> (value == null) {
					var s = <span class="reserved">this</span>.getSel();

					<span class="comment">// Find font and select it</span>
					<span class="reserved">if</span> (tinyMCE.isGecko &amp;&amp; s.isCollapsed) {
						var f = tinyMCE.getParentElement(<span class="reserved">this</span>.getFocusElement(), <span class="literal">"font"</span>);

						<span class="reserved">if</span> (f != null)
							<span class="reserved">this</span>.selection.selectNode(f, false);
					}

					<span class="comment">// Remove format</span>
					<span class="reserved">this</span>.getDoc().execCommand(<span class="literal">"RemoveFormat"</span>, false, null);

					<span class="comment">// Collapse range if font was found</span>
					<span class="reserved">if</span> (f != null &amp;&amp; tinyMCE.isGecko) {
						var r = <span class="reserved">this</span>.getRng().cloneRange();
						r.collapse(true);
						s.removeAllRanges();
						s.addRange(r);
					}
				} <span class="reserved">else</span>
					<span class="reserved">this</span>.getDoc().execCommand(<span class="literal">'FontName'</span>, false, value);

				<span class="reserved">if</span> (tinyMCE.isGecko)
					window.setTimeout(<span class="literal">'tinyMCE.triggerNodeChange(false);'</span>, 1);

				<span class="reserved">return</span>;

			case <span class="literal">"FontSize"</span>:
				<span class="reserved">this</span>.getDoc().execCommand(<span class="literal">'FontSize'</span>, false, value);

				<span class="reserved">if</span> (tinyMCE.isGecko)
					window.setTimeout(<span class="literal">'tinyMCE.triggerNodeChange(false);'</span>, 1);

				<span class="reserved">return</span>;

			case <span class="literal">"forecolor"</span>:
				<span class="reserved">this</span>.getDoc().execCommand(<span class="literal">'forecolor'</span>, false, value);
				break;

			case <span class="literal">"HiliteColor"</span>:
				<span class="reserved">if</span> (tinyMCE.isGecko) {
					<span class="reserved">this</span>._setUseCSS(true);
					<span class="reserved">this</span>.getDoc().execCommand(<span class="literal">'hilitecolor'</span>, false, value);
					<span class="reserved">this</span>._setUseCSS(false);
				} <span class="reserved">else</span>
					<span class="reserved">this</span>.getDoc().execCommand(<span class="literal">'BackColor'</span>, false, value);
				break;

			case <span class="literal">"Cut"</span>:
			case <span class="literal">"Copy"</span>:
			case <span class="literal">"Paste"</span>:
				var cmdFailed = false;

				<span class="comment">// Try executing command</span>
				eval(<span class="literal">'try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}'</span>);

				<span class="reserved">if</span> (tinyMCE.isOpera &amp;&amp; cmdFailed)
					alert(<span class="literal">'Currently not supported by your browser, use keyboard shortcuts instead.'</span>);

				<span class="comment">// Alert error in gecko if command failed</span>
				<span class="reserved">if</span> (tinyMCE.isGecko &amp;&amp; cmdFailed) {
					<span class="comment">// Confirm more info</span>
					<span class="reserved">if</span> (confirm(tinyMCE.getLang(<span class="literal">'lang_clipboard_msg'</span>)))
						window.open(<span class="literal">'http://www.mozilla.org/editor/midasdemo/securityprefs.html'</span>, <span class="literal">'mceExternal'</span>);

					<span class="reserved">return</span>;
				} <span class="reserved">else</span>
					tinyMCE.triggerNodeChange();
			break;

			case <span class="literal">"mceSetContent"</span>:
				<span class="reserved">if</span> (!value)
					value = <span class="literal">""</span>;

				<span class="comment">// Call custom cleanup code</span>
				value = tinyMCE.storeAwayURLs(value);
				value = tinyMCE._customCleanup(<span class="reserved">this</span>, <span class="literal">"insert_to_editor"</span>, value);
				tinyMCE._setHTML(doc, value);
				tinyMCE.setInnerHTML(doc.body, tinyMCE._cleanupHTML(<span class="reserved">this</span>, doc, tinyMCE.settings, doc.body));
				tinyMCE.convertAllRelativeURLs(doc.body);
				tinyMCE.handleVisualAid(doc.body, true, <span class="reserved">this</span>.visualAid, <span class="reserved">this</span>);
				tinyMCE._setEventsEnabled(doc.body, false);
				<span class="reserved">return</span> true;

			case <span class="literal">"mceCleanup"</span>:
				var b = <span class="reserved">this</span>.selection.getBookmark();
				tinyMCE._setHTML(<span class="reserved">this</span>.contentDocument, <span class="reserved">this</span>.getBody().innerHTML);
				tinyMCE.setInnerHTML(<span class="reserved">this</span>.getBody(), tinyMCE._cleanupHTML(<span class="reserved">this</span>, <span class="reserved">this</span>.contentDocument, <span class="reserved">this</span>.settings, <span class="reserved">this</span>.getBody(), <span class="reserved">this</span>.visualAid));
				tinyMCE.convertAllRelativeURLs(doc.body);
				tinyMCE.handleVisualAid(<span class="reserved">this</span>.getBody(), true, <span class="reserved">this</span>.visualAid, <span class="reserved">this</span>);
				tinyMCE._setEventsEnabled(<span class="reserved">this</span>.getBody(), false);
				<span class="reserved">this</span>.repaint();
				<span class="reserved">this</span>.selection.moveToBookmark(b);
				tinyMCE.triggerNodeChange();
			break;

			case <span class="literal">"mceReplaceContent"</span>:
				<span class="reserved">this</span>.getWin().focus();

				var selectedText = <span class="literal">""</span>;

				<span class="reserved">if</span> (tinyMCE.isMSIE) {
					var rng = doc.selection.createRange();
					selectedText = rng.text;
				} <span class="reserved">else</span>
					selectedText = <span class="reserved">this</span>.getSel().toString();

				<span class="reserved">if</span> (selectedText.length &gt; 0) {
					value = tinyMCE.replaceVar(value, <span class="literal">"selection"</span>, selectedText);
					tinyMCE.execCommand(<span class="literal">'mceInsertContent'</span>, false, value);
				}

				tinyMCE.triggerNodeChange();
			break;

			case <span class="literal">"mceSetAttribute"</span>:
				<span class="reserved">if</span> (typeof(value) == <span class="literal">'object'</span>) {
					var targetElms = (typeof(value[<span class="literal">'targets'</span>]) == <span class="literal">"undefined"</span>) ? <span class="literal">"p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address"</span> : value[<span class="literal">'targets'</span>];
					var targetNode = tinyMCE.getParentElement(<span class="reserved">this</span>.getFocusElement(), targetElms);

					<span class="reserved">if</span> (targetNode) {
						targetNode.setAttribute(value[<span class="literal">'name'</span>], value[<span class="literal">'value'</span>]);
						tinyMCE.triggerNodeChange();
					}
				}
			break;

			case <span class="literal">"mceSetCSSClass"</span>:
				<span class="reserved">this</span>.execCommand(<span class="literal">"SetStyleInfo"</span>, false, {command : <span class="literal">"setattrib"</span>, name : <span class="literal">"class"</span>, value : value});
			break;

			case <span class="literal">"mceInsertRawHTML"</span>:
				var key = <span class="literal">'tiny_mce_marker'</span>;

				<span class="reserved">this</span>.execCommand(<span class="literal">'mceBeginUndoLevel'</span>);

				<span class="comment">// Insert marker key</span>
				<span class="reserved">this</span>.execCommand(<span class="literal">'mceInsertContent'</span>, false, key);

				<span class="comment">// Store away scroll pos</span>
				var scrollX = <span class="reserved">this</span>.getDoc().body.scrollLeft + <span class="reserved">this</span>.getDoc().documentElement.scrollLeft;
				var scrollY = <span class="reserved">this</span>.getDoc().body.scrollTop + <span class="reserved">this</span>.getDoc().documentElement.scrollTop;

				<span class="comment">// Find marker and replace with RAW HTML</span>
				var html = <span class="reserved">this</span>.getBody().innerHTML;
				<span class="reserved">if</span> ((pos = html.indexOf(key)) != -1)
					tinyMCE.setInnerHTML(<span class="reserved">this</span>.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));

				<span class="comment">// Restore scoll pos</span>
				<span class="reserved">this</span>.contentWindow.scrollTo(scrollX, scrollY);

				<span class="reserved">this</span>.execCommand(<span class="literal">'mceEndUndoLevel'</span>);

				break;

			case <span class="literal">"mceInsertContent"</span>:
				var insertHTMLFailed = false;
				<span class="reserved">this</span>.getWin().focus();

				<span class="reserved">if</span> (tinyMCE.isGecko || tinyMCE.isOpera) {
					try {
						<span class="comment">// Is plain text or HTML, &amp;amp;, &amp;nbsp; etc will be encoded wrong in FF</span>
						<span class="reserved">if</span> (value.indexOf(<span class="literal">'&lt;'</span>) == -1 &amp;&amp; !value.match(/(&amp;#38;|&amp;#160;|&amp;#60;|&amp;#62;)/g)) {
							var r = <span class="reserved">this</span>.getRng();
							var n = <span class="reserved">this</span>.getDoc().createTextNode(tinyMCE.entityDecode(value));
							var s = <span class="reserved">this</span>.getSel();
							var r2 = r.cloneRange();

							<span class="comment">// Insert text at cursor position</span>
							s.removeAllRanges();
							r.deleteContents();
							r.insertNode(n);

							<span class="comment">// Move the cursor to the end of text</span>
							r2.selectNode(n);
							r2.collapse(false);
							s.removeAllRanges();
							s.addRange(r2);
						} <span class="reserved">else</span> {
							value = tinyMCE.fixGeckoBaseHREFBug(1, <span class="reserved">this</span>.getDoc(), value);
							<span class="reserved">this</span>.getDoc().execCommand(<span class="literal">'inserthtml'</span>, false, value);
							tinyMCE.fixGeckoBaseHREFBug(2, <span class="reserved">this</span>.getDoc(), value);
						}
					} catch (ex) {
						insertHTMLFailed = true;
					}

					<span class="reserved">if</span> (!insertHTMLFailed) {
						tinyMCE.triggerNodeChange();
						<span class="reserved">return</span>;
					}
				}

				<span class="comment">// Ugly hack in Opera due to non working "inserthtml"</span>
				<span class="reserved">if</span> (tinyMCE.isOpera &amp;&amp; insertHTMLFailed) {
					<span class="reserved">this</span>.getDoc().execCommand(<span class="literal">"insertimage"</span>, false, tinyMCE.uniqueURL);
					var ar = tinyMCE.getElementsByAttributeValue(<span class="reserved">this</span>.getBody(), <span class="literal">"img"</span>, <span class="literal">"src"</span>, tinyMCE.uniqueURL);
					ar[0].outerHTML = value;
					<span class="reserved">return</span>;
				}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -