📄 overview-summary-tinymce_engine.class.js.html
字号:
var entities = tinyMCE.getParam(<span class="literal">'entities'</span>, <span class="literal">''</span>, true, <span class="literal">','</span>);
<span class="reserved">for</span> (var i=0; i<entities.length; i+=2)
settings[<span class="literal">'cleanup_entities'</span>][<span class="literal">'c'</span> + entities[i]] = entities[i+1];
<span class="comment">// Save away this config</span>
settings[<span class="literal">'index'</span>] = <span class="reserved">this</span>.configs.length;
<span class="reserved">this</span>.configs[<span class="reserved">this</span>.configs.length] = settings;
},
<span class="comment">/**
* Adds unload event handles to execute triggerSave.
*
* <span class="attrib">@private</span>
*/</span>
_addUnloadEvents : <span class="reserved">function</span>() {
<span class="reserved">if</span> (tinyMCE.isMSIE) {
<span class="reserved">if</span> (tinyMCE.settings[<span class="literal">'add_unload_trigger'</span>]) {
tinyMCE.addEvent(window, <span class="literal">"unload"</span>, TinyMCE_Engine.<span class="reserved">prototype</span>.unloadHandler);
tinyMCE.addEvent(window.document, <span class="literal">"beforeunload"</span>, TinyMCE_Engine.<span class="reserved">prototype</span>.unloadHandler);
}
} <span class="reserved">else</span> {
<span class="reserved">if</span> (tinyMCE.settings[<span class="literal">'add_unload_trigger'</span>])
tinyMCE.addEvent(window, <span class="literal">"unload"</span>, <span class="reserved">function</span> () {tinyMCE.triggerSave(true, true);});
}
},
<span class="comment">/**
* Assigns a default value for a specific config parameter.
*
* <span class="attrib">@param</span> {string} key Settings key to add default value to.
* <span class="attrib">@param</span> {object} def_val Default value to assign if the settings option isn't defined.
* <span class="attrib">@param</span> {boolean} t Trim all white space, if true all whitespace will be removed from option value.
* <span class="attrib">@private</span>
*/</span>
_def : <span class="reserved">function</span>(key, def_val, t) {
var v = tinyMCE.getParam(key, def_val);
v = t ? v.replace(/\s+/g,<span class="literal">""</span>) : v;
<span class="reserved">this</span>.settings[key] = v;
},
<span class="comment">/**
* Returns true/false if the specified plugin is loaded or not.
*
* <span class="attrib">@param</span> {string} n Plugin name to look for.
* <span class="attrib">@return</span> true/false if the specified plugin is loaded or not.
* <span class="attrib">@type</span> boolean
*/</span>
hasPlugin : <span class="reserved">function</span>(n) {
<span class="reserved">return</span> typeof(<span class="reserved">this</span>.plugins[n]) != <span class="literal">"undefined"</span> && <span class="reserved">this</span>.plugins[n] != null;
},
<span class="comment">/**
* Adds the specified plugin to the list of loaded plugins, this will also setup the baseURL
* property of the plugin.
*
* <span class="attrib">@param</span> {string} Plugin name/id.
* <span class="attrib">@param</span> {TinyMCE_Plugin} p Plugin instance to add.
*/</span>
addPlugin : <span class="reserved">function</span>(n, p) {
p.baseURL = tinyMCE.baseURL + <span class="literal">"/plugins/"</span> + n;
<span class="reserved">this</span>.plugins[n] = p;
},
<span class="comment">/**
* Sets the baseURL of the specified plugin, this is useful if the plugin is loaded from
* a external location.
*
* <span class="attrib">@param</span> {string} n Plugin name/id to set base URL on. This have to be added before.
* <span class="attrib">@param</span> {string} u Base URL of plugin, this string should be the URL prefix for the plugin without a trailing slash.
*/</span>
setPluginBaseURL : <span class="reserved">function</span>(n, u) {
<span class="reserved">this</span>.plugins[n].baseURL = u;
},
<span class="comment">/**
* Returns true/false if the specified theme is loaded or not.
*
* <span class="attrib">@param</span> {string} n Theme name/id to check for.
* <span class="attrib">@return</span> true/false if the specified theme is loaded or not.
* <span class="attrib">@type</span> boolean
*/</span>
hasTheme : <span class="reserved">function</span>(n) {
<span class="reserved">return</span> typeof(<span class="reserved">this</span>.themes[n]) != <span class="literal">"undefined"</span> && <span class="reserved">this</span>.themes[n] != null;
},
<span class="comment">/**
* Adds the specified theme in to the list of loaded themes.
*
* <span class="attrib">@param</span> {string} n Theme name/id to add the object reference to.
* <span class="attrib">@param</span> {TinyMCE_Theme} t Theme instance to add to the loaded list.
*/</span>
addTheme : <span class="reserved">function</span>(n, t) {
<span class="reserved">this</span>.themes[n] = t;
},
<span class="comment">/**
* Loads the specified script by writing the a script tag to the current page.
* This will also check if the file has been loaded before. This function should only be used
* when the page is loading.
*
* <span class="attrib">@param</span> {string} url Script URL to load.
*/</span>
loadScript : <span class="reserved">function</span>(url) {
<span class="reserved">if</span> (tinyMCE.gzipMode)
<span class="reserved">return</span>;
<span class="reserved">for</span> (var i=0; i<<span class="reserved">this</span>.loadedFiles.length; i++) {
<span class="reserved">if</span> (<span class="reserved">this</span>.loadedFiles[i] == url)
<span class="reserved">return</span>;
}
document.write(<span class="literal">'<sc'</span>+<span class="literal">'ript language="javascript" type="text/javascript" src="'</span> + url + <span class="literal">'"></script>'</span>);
<span class="reserved">this</span>.loadedFiles[<span class="reserved">this</span>.loadedFiles.length] = url;
},
<span class="comment">/**
* Loads the specified CSS by writing the a link tag to the current page.
* This will also check if the file has been loaded before. This function should only be used
* when the page is loading.
*
* <span class="attrib">@param</span> {string} url CSS file URL to load.
*/</span>
loadCSS : <span class="reserved">function</span>(url) {
<span class="reserved">for</span> (var i=0; i<<span class="reserved">this</span>.loadedFiles.length; i++) {
<span class="reserved">if</span> (<span class="reserved">this</span>.loadedFiles[i] == url)
<span class="reserved">return</span>;
}
document.write(<span class="literal">'<link href="'</span> + url + <span class="literal">'" rel="stylesheet" type="text/css" />'</span>);
<span class="reserved">this</span>.loadedFiles[<span class="reserved">this</span>.loadedFiles.length] = url;
},
<span class="comment">/**
* Imports a CSS file into a allready loaded document. This will add a link element
* to the head element of the document.
*
* <span class="attrib">@param</span> {DOMDocument} doc DOM Document to load CSS into.
* <span class="attrib">@param</span> {string} css_file CSS File URL to load.
*/</span>
importCSS : <span class="reserved">function</span>(doc, css_file) {
<span class="reserved">if</span> (css_file == <span class="literal">''</span>)
<span class="reserved">return</span>;
<span class="reserved">if</span> (typeof(doc.createStyleSheet) == <span class="literal">"undefined"</span>) {
var elm = doc.createElement(<span class="literal">"link"</span>);
elm.rel = <span class="literal">"stylesheet"</span>;
elm.href = css_file;
<span class="reserved">if</span> ((headArr = doc.getElementsByTagName(<span class="literal">"head"</span>)) != null && headArr.length > 0)
headArr[0].appendChild(elm);
} <span class="reserved">else</span>
var styleSheet = doc.createStyleSheet(css_file);
},
<span class="comment">/**
* Displays a confirm dialog when a user clicks/focus a textarea that is to be converted into
* a TinyMCE instance.
*
* <span class="attrib">@param</span> {DOMEvent} e DOM event instance.
* <span class="attrib">@param</span> {Array} settings Name/Value array of initialization settings.
*/</span>
confirmAdd : <span class="reserved">function</span>(e, settings) {
var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
var elementId = elm.name ? elm.name : elm.id;
tinyMCE.settings = settings;
<span class="reserved">if</span> (!elm.getAttribute(<span class="literal">'mce_noask'</span>) && confirm(tinyMCELang[<span class="literal">'lang_edit_confirm'</span>]))
tinyMCE.addMCEControl(elm, elementId);
elm.setAttribute(<span class="literal">'mce_noask'</span>, <span class="literal">'true'</span>);
},
<span class="comment">/**
* Moves the contents from the hidden textarea to the editor that gets inserted.
*
* <span class="attrib">@param</span> {string} form_element_name Form element name to move contents from.
* <span class="attrib">@deprecated</span>
*/</span>
updateContent : <span class="reserved">function</span>(form_element_name) {
<span class="comment">// Find MCE instance linked to given form element and copy it's value</span>
var formElement = document.getElementById(form_element_name);
<span class="reserved">for</span> (var n in tinyMCE.instances) {
var inst = tinyMCE.instances[n];
<span class="reserved">if</span> (!tinyMCE.isInstance(inst))
continue;
inst.switchSettings();
<span class="reserved">if</span> (inst.formElement == formElement) {
var doc = inst.getDoc();
tinyMCE._setHTML(doc, inst.formElement.value);
<span class="reserved">if</span> (!tinyMCE.isMSIE)
doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, <span class="reserved">this</span>.settings, doc.body, inst.visualAid);
}
}
},
<span class="comment">/**
* Adds a TinyMCE editor control instance to a specific form element.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -