📄 js_quicktags.js
字号:
// JS QuickTags version 1.2//// Copyright (c) 2002-2005 Alex King// http://www.alexking.org///// Licensed under the LGPL license// http://www.gnu.org/copyleft/lesser.html//// **********************************************************************// This program is distributed in the hope that it will be useful, but// WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // **********************************************************************//// This JavaScript will insert the tags below at the cursor position in IE and // Gecko-based browsers (Mozilla, Camino, Firefox, Netscape). For browsers that // do not support inserting at the cursor position (Safari, OmniWeb) it appends// the tags to the end of the content.//// The variable 'edCanvas' must be defined as the <textarea> element you want // to be editing in. See the accompanying 'index.html' page for an example.var edButtons = new Array();var edLinks = new Array();var edOpenTags = new Array();function edButton(id, display, tagStart, tagEnd, access, open) { this.id = id; // used to name the toolbar button this.display = display; // label on button this.tagStart = tagStart; // open tag this.tagEnd = tagEnd; // close tag this.access = access; // set to -1 if tag does not need to be closed this.open = open; // set to -1 if tag does not need to be closed}edButtons.push( new edButton( 'ed_bold' ,'B' ,'<strong>' ,'</strong>' ,'b' ));edButtons.push( new edButton( 'ed_italic' ,'I' ,'<em>' ,'</em>' ,'i' ));edButtons.push( new edButton( 'ed_link' ,'Link' ,'' ,'</a>' ,'a' )); // special case/*edButtons.push( new edButton( 'ed_ext_link' ,'Ext. Link' ,'' ,'</a>' ,'e' )); // special case*/edButtons.push( new edButton( 'ed_img' ,'IMG' ,'' ,'' ,'m' ,-1 )); // special caseedButtons.push( new edButton( 'ed_ul' ,'UL' ,'<ul>\n' ,'</ul>\n\n' ,'u' ));edButtons.push( new edButton( 'ed_ol' ,'OL' ,'<ol>\n' ,'</ol>\n\n' ,'o' ));edButtons.push( new edButton( 'ed_li' ,'LI' ,'\t<li>' ,'</li>\n' ,'l' ));edButtons.push( new edButton( 'ed_block' ,'B-QUOTE' ,'<blockquote>' ,'</blockquote>' ,'q' ));edButtons.push( new edButton( 'ed_separator' ,'SEPAR' ,'[separator]' ,'' ,'' ,-1 )); // special caseedButtons.push( new edButton( 'ed_newpage' ,'PAGE' ,'[newpage]' ,'' ,'' ,-1 )); // special casevar extendedStart = edButtons.length;// below here are the extended buttonsedButtons.push( new edButton( 'ed_h1' ,'H1' ,'<h1>' ,'</h1>\n\n' ,'1' ));edButtons.push( new edButton( 'ed_h2' ,'H2' ,'<h2>' ,'</h2>\n\n' ,'2' ));edButtons.push( new edButton( 'ed_h3' ,'H3' ,'<h3>' ,'</h3>\n\n' ,'3' ));edButtons.push( new edButton( 'ed_h4' ,'H4' ,'<h4>' ,'</h4>\n\n' ,'4' ));edButtons.push( new edButton( 'ed_p' ,'P' ,'<p>' ,'</p>\n\n' ,'p' ));edButtons.push( new edButton( 'ed_code' ,'CODE' ,'[code]' ,'[/code]' ,'c' ));edButtons.push( new edButton( 'ed_quote' ,'QUOTE' ,'[quote]' ,'[/quote]' ,'x' ));edButtons.push( new edButton( 'ed_pre' ,'PRE' ,'<pre>' ,'</pre>' ));edButtons.push( new edButton( 'ed_dl' ,'DL' ,'<dl>\n' ,'</dl>\n\n' ));edButtons.push( new edButton( 'ed_dt' ,'DT' ,'\t<dt>' ,'</dt>\n' ));edButtons.push( new edButton( 'ed_dd' ,'DD' ,'\t<dd>' ,'</dd>\n' ));edButtons.push( new edButton( 'ed_table' ,'TABLE' ,'<table>\n<tbody>' ,'</tbody>\n</table>\n' ));edButtons.push( new edButton( 'ed_tr' ,'TR' ,'\t<tr>\n' ,'\n\t</tr>\n' ));edButtons.push( new edButton( 'ed_td' ,'TD' ,'\t\t<td>' ,'</td>\n' ));edButtons.push( new edButton( 'ed_under' ,'U' ,'<u>' ,'</u>' ));edButtons.push( new edButton( 'ed_strike' ,'S' ,'<s>' ,'</s>' ));edButtons.push( new edButton( 'ed_nobr' ,'NOBR' ,'<nobr>' ,'</nobr>' ));edButtons.push( new edButton( 'ed_footnote' ,'Footnote' ,'' ,'' ,'f' ));function edLink(display, URL, newWin) { this.display = display; this.URL = URL; if (!newWin) { newWin = 1; } this.newWin = newWin;}edLinks[edLinks.length] = new edLink('alexking.org' ,'http://www.alexking.org/' );function edShowButton(button, i) { if (button.access) { var accesskey = ' accesskey = "' + button.access + '"' } else { var accesskey = ''; } switch (button.id) { case 'ed_img': document.write('<input type="button" id="' + button.id + '" ' + accesskey + ' class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />'); break; case 'ed_link': document.write('<input type="button" id="' + button.id + '" ' + accesskey + ' class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />'); break; case 'ed_ext_link': document.write('<input type="button" id="' + button.id + '" ' + accesskey + ' class="ed_button" onclick="edInsertExtLink(edCanvas, ' + i + ');" value="' + button.display + '" />');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -