initial commit
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Charmap plugin
|
||||
* by Christophe Dolivet
|
||||
* v0.1 (2006/09/22)
|
||||
*
|
||||
*
|
||||
* This plugin allow to use a visual keyboard allowing to insert any UTF-8 characters in the text.
|
||||
*
|
||||
* - plugin name to add to the plugin list: "charmap"
|
||||
* - plugin name to add to the toolbar list: "charmap"
|
||||
* - possible parameters to add to EditAreaLoader.init():
|
||||
* "charmap_default": (String) define the name of the default character range displayed on popup display
|
||||
* (default: "arrows")
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
var EditArea_charmap= {
|
||||
/**
|
||||
* Get called once this file is loaded (editArea still not initialized)
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
init: function(){
|
||||
this.default_language="Arrows";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML code for a specific control string or false if this plugin doesn't have that control.
|
||||
* A control can be a button, select list or any other HTML item to present in the EditArea user interface.
|
||||
* Language variables such as {$lang_somekey} will also be replaced with contents from
|
||||
* the language packs.
|
||||
*
|
||||
* @param {string} ctrl_name: the name of the control to add
|
||||
* @return HTML code for a specific control or false.
|
||||
* @type string or boolean
|
||||
*/
|
||||
,get_control_html: function(ctrl_name){
|
||||
switch(ctrl_name){
|
||||
case "charmap":
|
||||
// Control id, button img, command
|
||||
return parent.editAreaLoader.get_button_html('charmap_but', 'charmap.gif', 'charmap_press', false, this.baseURL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get called once EditArea is fully loaded and initialised
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
,onload: function(){
|
||||
if(editArea.settings["charmap_default"] && editArea.settings["charmap_default"].length>0)
|
||||
this.default_language= editArea.settings["charmap_default"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called each time the user touch a keyboard key.
|
||||
*
|
||||
* @param (event) e: the keydown event
|
||||
* @return true - pass to next handler in chain, false - stop chain execution
|
||||
* @type boolean
|
||||
*/
|
||||
,onkeydown: function(e){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a specific command, this function handles plugin commands.
|
||||
*
|
||||
* @param {string} cmd: the name of the command being executed
|
||||
* @param {unknown} param: the parameter of the command
|
||||
* @return true - pass to next handler in chain, false - stop chain execution
|
||||
* @type boolean
|
||||
*/
|
||||
,execCommand: function(cmd, param){
|
||||
// Handle commands
|
||||
switch(cmd){
|
||||
case "charmap_press":
|
||||
win= window.open(this.baseURL+"popup.html", "charmap", "width=500,height=270,scrollbars=yes,resizable=yes");
|
||||
win.focus();
|
||||
return false;
|
||||
}
|
||||
// Pass to next handler in chain
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Adds the plugin class to the list of available EditArea plugins
|
||||
editArea.add_plugin("charmap", EditArea_charmap);
|
||||
@@ -0,0 +1,64 @@
|
||||
body{
|
||||
background-color: #F0F0EE;
|
||||
font: 12px monospace, sans-serif;
|
||||
}
|
||||
|
||||
select{
|
||||
background-color: #F9F9F9;
|
||||
border: solid 1px #888888;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #2B6FB6;
|
||||
}
|
||||
|
||||
h1{
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
div#char_list{
|
||||
height: 200px;
|
||||
overflow: auto;
|
||||
padding: 1px;
|
||||
border: 1px solid #0A246A;
|
||||
background-color: #F9F9F9;
|
||||
clear: both;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
a.char{
|
||||
display: block;
|
||||
float: left;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
margin: 1px;
|
||||
border: solid 1px #888888;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a.char:hover{
|
||||
background-color: #CCCCCC;
|
||||
}
|
||||
|
||||
.preview{
|
||||
border: solid 1px #888888;
|
||||
width: 50px;
|
||||
padding: 2px 5px;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
text-align:center;
|
||||
background-color: #CCCCCC;
|
||||
font-size: 2em;
|
||||
float: right;
|
||||
font-weight: bold;
|
||||
margin: 0 0 5px 5px;
|
||||
}
|
||||
|
||||
#preview_code{
|
||||
font-size: 1.1em;
|
||||
width: 70px;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 245 B |
@@ -0,0 +1,373 @@
|
||||
var editArea;
|
||||
|
||||
|
||||
/**
|
||||
* UTF-8 list taken from http://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=dec
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
var char_range_list={
|
||||
"Basic Latin":"0021,007F",
|
||||
"Latin-1 Supplement":"0080,00FF",
|
||||
"Latin Extended-A":"0100,017F",
|
||||
"Latin Extended-B":"0180,024F",
|
||||
"IPA Extensions":"0250,02AF",
|
||||
"Spacing Modifier Letters":"02B0,02FF",
|
||||
|
||||
"Combining Diacritical Marks":"0300,036F",
|
||||
"Greek and Coptic":"0370,03FF",
|
||||
"Cyrillic":"0400,04FF",
|
||||
"Cyrillic Supplement":"0500,052F",
|
||||
"Armenian":"0530,058F",
|
||||
"Hebrew":"0590,05FF",
|
||||
"Arabic":"0600,06FF",
|
||||
"Syriac":"0700,074F",
|
||||
"Arabic Supplement":"0750,077F",
|
||||
|
||||
"Thaana":"0780,07BF",
|
||||
"Devanagari":"0900,097F",
|
||||
"Bengali":"0980,09FF",
|
||||
"Gurmukhi":"0A00,0A7F",
|
||||
"Gujarati":"0A80,0AFF",
|
||||
"Oriya":"0B00,0B7F",
|
||||
"Tamil":"0B80,0BFF",
|
||||
"Telugu":"0C00,0C7F",
|
||||
"Kannada":"0C80,0CFF",
|
||||
|
||||
"Malayalam":"0D00,0D7F",
|
||||
"Sinhala":"0D80,0DFF",
|
||||
"Thai":"0E00,0E7F",
|
||||
"Lao":"0E80,0EFF",
|
||||
"Tibetan":"0F00,0FFF",
|
||||
"Myanmar":"1000,109F",
|
||||
"Georgian":"10A0,10FF",
|
||||
"Hangul Jamo":"1100,11FF",
|
||||
"Ethiopic":"1200,137F",
|
||||
|
||||
"Ethiopic Supplement":"1380,139F",
|
||||
"Cherokee":"13A0,13FF",
|
||||
"Unified Canadian Aboriginal Syllabics":"1400,167F",
|
||||
"Ogham":"1680,169F",
|
||||
"Runic":"16A0,16FF",
|
||||
"Tagalog":"1700,171F",
|
||||
"Hanunoo":"1720,173F",
|
||||
"Buhid":"1740,175F",
|
||||
"Tagbanwa":"1760,177F",
|
||||
|
||||
"Khmer":"1780,17FF",
|
||||
"Mongolian":"1800,18AF",
|
||||
"Limbu":"1900,194F",
|
||||
"Tai Le":"1950,197F",
|
||||
"New Tai Lue":"1980,19DF",
|
||||
"Khmer Symbols":"19E0,19FF",
|
||||
"Buginese":"1A00,1A1F",
|
||||
"Phonetic Extensions":"1D00,1D7F",
|
||||
"Phonetic Extensions Supplement":"1D80,1DBF",
|
||||
|
||||
"Combining Diacritical Marks Supplement":"1DC0,1DFF",
|
||||
"Latin Extended Additional":"1E00,1EFF",
|
||||
"Greek Extended":"1F00,1FFF",
|
||||
"General Punctuation":"2000,206F",
|
||||
"Superscripts and Subscripts":"2070,209F",
|
||||
"Currency Symbols":"20A0,20CF",
|
||||
"Combining Diacritical Marks for Symbols":"20D0,20FF",
|
||||
"Letterlike Symbols":"2100,214F",
|
||||
"Number Forms":"2150,218F",
|
||||
|
||||
"Arrows":"2190,21FF",
|
||||
"Mathematical Operators":"2200,22FF",
|
||||
"Miscellaneous Technical":"2300,23FF",
|
||||
"Control Pictures":"2400,243F",
|
||||
"Optical Character Recognition":"2440,245F",
|
||||
"Enclosed Alphanumerics":"2460,24FF",
|
||||
"Box Drawing":"2500,257F",
|
||||
"Block Elements":"2580,259F",
|
||||
"Geometric Shapes":"25A0,25FF",
|
||||
|
||||
"Miscellaneous Symbols":"2600,26FF",
|
||||
"Dingbats":"2700,27BF",
|
||||
"Miscellaneous Mathematical Symbols-A":"27C0,27EF",
|
||||
"Supplemental Arrows-A":"27F0,27FF",
|
||||
"Braille Patterns":"2800,28FF",
|
||||
"Supplemental Arrows-B":"2900,297F",
|
||||
"Miscellaneous Mathematical Symbols-B":"2980,29FF",
|
||||
"Supplemental Mathematical Operators":"2A00,2AFF",
|
||||
"Miscellaneous Symbols and Arrows":"2B00,2BFF",
|
||||
|
||||
"Glagolitic":"2C00,2C5F",
|
||||
"Coptic":"2C80,2CFF",
|
||||
"Georgian Supplement":"2D00,2D2F",
|
||||
"Tifinagh":"2D30,2D7F",
|
||||
"Ethiopic Extended":"2D80,2DDF",
|
||||
"Supplemental Punctuation":"2E00,2E7F",
|
||||
"CJK Radicals Supplement":"2E80,2EFF",
|
||||
"Kangxi Radicals":"2F00,2FDF",
|
||||
"Ideographic Description Characters":"2FF0,2FFF",
|
||||
|
||||
"CJK Symbols and Punctuation":"3000,303F",
|
||||
"Hiragana":"3040,309F",
|
||||
"Katakana":"30A0,30FF",
|
||||
"Bopomofo":"3100,312F",
|
||||
"Hangul Compatibility Jamo":"3130,318F",
|
||||
"Kanbun":"3190,319F",
|
||||
"Bopomofo Extended":"31A0,31BF",
|
||||
"CJK Strokes":"31C0,31EF",
|
||||
"Katakana Phonetic Extensions":"31F0,31FF",
|
||||
|
||||
"Enclosed CJK Letters and Months":"3200,32FF",
|
||||
"CJK Compatibility":"3300,33FF",
|
||||
"CJK Unified Ideographs Extension A":"3400,4DBF",
|
||||
"Yijing Hexagram Symbols":"4DC0,4DFF",
|
||||
"CJK Unified Ideographs":"4E00,9FFF",
|
||||
"Yi Syllables":"A000,A48F",
|
||||
"Yi Radicals":"A490,A4CF",
|
||||
"Modifier Tone Letters":"A700,A71F",
|
||||
"Syloti Nagri":"A800,A82F",
|
||||
|
||||
"Hangul Syllables":"AC00,D7AF",
|
||||
"High Surrogates":"D800,DB7F",
|
||||
"High Private Use Surrogates":"DB80,DBFF",
|
||||
"Low Surrogates":"DC00,DFFF",
|
||||
"Private Use Area":"E000,F8FF",
|
||||
"CJK Compatibility Ideographs":"F900,FAFF",
|
||||
"Alphabetic Presentation Forms":"FB00,FB4F",
|
||||
"Arabic Presentation Forms-A":"FB50,FDFF",
|
||||
"Variation Selectors":"FE00,FE0F",
|
||||
|
||||
"Vertical Forms":"FE10,FE1F",
|
||||
"Combining Half Marks":"FE20,FE2F",
|
||||
"CJK Compatibility Forms":"FE30,FE4F",
|
||||
"Small Form Variants":"FE50,FE6F",
|
||||
"Arabic Presentation Forms-B":"FE70,FEFF",
|
||||
"Halfwidth and Fullwidth Forms":"FF00,FFEF",
|
||||
"Specials":"FFF0,FFFF",
|
||||
"Linear B Syllabary":"10000,1007F",
|
||||
"Linear B Ideograms":"10080,100FF",
|
||||
|
||||
"Aegean Numbers":"10100,1013F",
|
||||
"Ancient Greek Numbers":"10140,1018F",
|
||||
"Old Italic":"10300,1032F",
|
||||
"Gothic":"10330,1034F",
|
||||
"Ugaritic":"10380,1039F",
|
||||
"Old Persian":"103A0,103DF",
|
||||
"Deseret":"10400,1044F",
|
||||
"Shavian":"10450,1047F",
|
||||
"Osmanya":"10480,104AF",
|
||||
|
||||
"Cypriot Syllabary":"10800,1083F",
|
||||
"Kharoshthi":"10A00,10A5F",
|
||||
"Byzantine Musical Symbols":"1D000,1D0FF",
|
||||
"Musical Symbols":"1D100,1D1FF",
|
||||
"Ancient Greek Musical Notation":"1D200,1D24F",
|
||||
"Tai Xuan Jing Symbols":"1D300,1D35F",
|
||||
"Mathematical Alphanumeric Symbols":"1D400,1D7FF",
|
||||
"CJK Unified Ideographs Extension B":"20000,2A6DF",
|
||||
"CJK Compatibility Ideographs Supplement":"2F800,2FA1F",
|
||||
"Tags":"E0000,E007F",
|
||||
"Variation Selectors Supplement":"E0100,E01EF"
|
||||
};
|
||||
*/
|
||||
var char_range_list={
|
||||
"Aegean Numbers":"10100,1013F",
|
||||
"Alphabetic Presentation Forms":"FB00,FB4F",
|
||||
"Ancient Greek Musical Notation":"1D200,1D24F",
|
||||
"Ancient Greek Numbers":"10140,1018F",
|
||||
"Arabic":"0600,06FF",
|
||||
"Arabic Presentation Forms-A":"FB50,FDFF",
|
||||
"Arabic Presentation Forms-B":"FE70,FEFF",
|
||||
"Arabic Supplement":"0750,077F",
|
||||
"Armenian":"0530,058F",
|
||||
"Arrows":"2190,21FF",
|
||||
"Basic Latin":"0020,007F",
|
||||
"Bengali":"0980,09FF",
|
||||
"Block Elements":"2580,259F",
|
||||
"Bopomofo Extended":"31A0,31BF",
|
||||
"Bopomofo":"3100,312F",
|
||||
"Box Drawing":"2500,257F",
|
||||
"Braille Patterns":"2800,28FF",
|
||||
"Buginese":"1A00,1A1F",
|
||||
"Buhid":"1740,175F",
|
||||
"Byzantine Musical Symbols":"1D000,1D0FF",
|
||||
"CJK Compatibility Forms":"FE30,FE4F",
|
||||
"CJK Compatibility Ideographs Supplement":"2F800,2FA1F",
|
||||
"CJK Compatibility Ideographs":"F900,FAFF",
|
||||
"CJK Compatibility":"3300,33FF",
|
||||
"CJK Radicals Supplement":"2E80,2EFF",
|
||||
"CJK Strokes":"31C0,31EF",
|
||||
"CJK Symbols and Punctuation":"3000,303F",
|
||||
"CJK Unified Ideographs Extension A":"3400,4DBF",
|
||||
"CJK Unified Ideographs Extension B":"20000,2A6DF",
|
||||
"CJK Unified Ideographs":"4E00,9FFF",
|
||||
"Cherokee":"13A0,13FF",
|
||||
"Combining Diacritical Marks Supplement":"1DC0,1DFF",
|
||||
"Combining Diacritical Marks for Symbols":"20D0,20FF",
|
||||
"Combining Diacritical Marks":"0300,036F",
|
||||
"Combining Half Marks":"FE20,FE2F",
|
||||
"Control Pictures":"2400,243F",
|
||||
"Coptic":"2C80,2CFF",
|
||||
"Currency Symbols":"20A0,20CF",
|
||||
"Cypriot Syllabary":"10800,1083F",
|
||||
"Cyrillic Supplement":"0500,052F",
|
||||
"Cyrillic":"0400,04FF",
|
||||
"Deseret":"10400,1044F",
|
||||
"Devanagari":"0900,097F",
|
||||
"Dingbats":"2700,27BF",
|
||||
"Enclosed Alphanumerics":"2460,24FF",
|
||||
"Enclosed CJK Letters and Months":"3200,32FF",
|
||||
"Ethiopic Extended":"2D80,2DDF",
|
||||
"Ethiopic Supplement":"1380,139F",
|
||||
"Ethiopic":"1200,137F",
|
||||
"General Punctuation":"2000,206F",
|
||||
"Geometric Shapes":"25A0,25FF",
|
||||
"Georgian Supplement":"2D00,2D2F",
|
||||
"Georgian":"10A0,10FF",
|
||||
"Glagolitic":"2C00,2C5F",
|
||||
"Gothic":"10330,1034F",
|
||||
"Greek Extended":"1F00,1FFF",
|
||||
"Greek and Coptic":"0370,03FF",
|
||||
"Gujarati":"0A80,0AFF",
|
||||
"Gurmukhi":"0A00,0A7F",
|
||||
"Halfwidth and Fullwidth Forms":"FF00,FFEF",
|
||||
"Hangul Compatibility Jamo":"3130,318F",
|
||||
"Hangul Jamo":"1100,11FF",
|
||||
"Hangul Syllables":"AC00,D7AF",
|
||||
"Hanunoo":"1720,173F",
|
||||
"Hebrew":"0590,05FF",
|
||||
"High Private Use Surrogates":"DB80,DBFF",
|
||||
"High Surrogates":"D800,DB7F",
|
||||
"Hiragana":"3040,309F",
|
||||
"IPA Extensions":"0250,02AF",
|
||||
"Ideographic Description Characters":"2FF0,2FFF",
|
||||
"Kanbun":"3190,319F",
|
||||
"Kangxi Radicals":"2F00,2FDF",
|
||||
"Kannada":"0C80,0CFF",
|
||||
"Katakana Phonetic Extensions":"31F0,31FF",
|
||||
"Katakana":"30A0,30FF",
|
||||
"Kharoshthi":"10A00,10A5F",
|
||||
"Khmer Symbols":"19E0,19FF",
|
||||
"Khmer":"1780,17FF",
|
||||
"Lao":"0E80,0EFF",
|
||||
"Latin Extended Additional":"1E00,1EFF",
|
||||
"Latin Extended-A":"0100,017F",
|
||||
"Latin Extended-B":"0180,024F",
|
||||
"Latin-1 Supplement":"0080,00FF",
|
||||
"Letterlike Symbols":"2100,214F",
|
||||
"Limbu":"1900,194F",
|
||||
"Linear B Ideograms":"10080,100FF",
|
||||
"Linear B Syllabary":"10000,1007F",
|
||||
"Low Surrogates":"DC00,DFFF",
|
||||
"Malayalam":"0D00,0D7F",
|
||||
"Mathematical Alphanumeric Symbols":"1D400,1D7FF",
|
||||
"Mathematical Operators":"2200,22FF",
|
||||
"Miscellaneous Mathematical Symbols-A":"27C0,27EF",
|
||||
"Miscellaneous Mathematical Symbols-B":"2980,29FF",
|
||||
"Miscellaneous Symbols and Arrows":"2B00,2BFF",
|
||||
"Miscellaneous Symbols":"2600,26FF",
|
||||
"Miscellaneous Technical":"2300,23FF",
|
||||
"Modifier Tone Letters":"A700,A71F",
|
||||
"Mongolian":"1800,18AF",
|
||||
"Musical Symbols":"1D100,1D1FF",
|
||||
"Myanmar":"1000,109F",
|
||||
"New Tai Lue":"1980,19DF",
|
||||
"Number Forms":"2150,218F",
|
||||
"Ogham":"1680,169F",
|
||||
"Old Italic":"10300,1032F",
|
||||
"Old Persian":"103A0,103DF",
|
||||
"Optical Character Recognition":"2440,245F",
|
||||
"Oriya":"0B00,0B7F",
|
||||
"Osmanya":"10480,104AF",
|
||||
"Phonetic Extensions Supplement":"1D80,1DBF",
|
||||
"Phonetic Extensions":"1D00,1D7F",
|
||||
"Private Use Area":"E000,F8FF",
|
||||
"Runic":"16A0,16FF",
|
||||
"Shavian":"10450,1047F",
|
||||
"Sinhala":"0D80,0DFF",
|
||||
"Small Form Variants":"FE50,FE6F",
|
||||
"Spacing Modifier Letters":"02B0,02FF",
|
||||
"Specials":"FFF0,FFFF",
|
||||
"Superscripts and Subscripts":"2070,209F",
|
||||
"Supplemental Arrows-A":"27F0,27FF",
|
||||
"Supplemental Arrows-B":"2900,297F",
|
||||
"Supplemental Mathematical Operators":"2A00,2AFF",
|
||||
"Supplemental Punctuation":"2E00,2E7F",
|
||||
"Syloti Nagri":"A800,A82F",
|
||||
"Syriac":"0700,074F",
|
||||
"Tagalog":"1700,171F",
|
||||
"Tagbanwa":"1760,177F",
|
||||
"Tags":"E0000,E007F",
|
||||
"Tai Le":"1950,197F",
|
||||
"Tai Xuan Jing Symbols":"1D300,1D35F",
|
||||
"Tamil":"0B80,0BFF",
|
||||
"Telugu":"0C00,0C7F",
|
||||
"Thaana":"0780,07BF",
|
||||
"Thai":"0E00,0E7F",
|
||||
"Tibetan":"0F00,0FFF",
|
||||
"Tifinagh":"2D30,2D7F",
|
||||
"Ugaritic":"10380,1039F",
|
||||
"Unified Canadian Aboriginal Syllabics":"1400,167F",
|
||||
"Variation Selectors Supplement":"E0100,E01EF",
|
||||
"Variation Selectors":"FE00,FE0F",
|
||||
"Vertical Forms":"FE10,FE1F",
|
||||
"Yi Radicals":"A490,A4CF",
|
||||
"Yi Syllables":"A000,A48F",
|
||||
"Yijing Hexagram Symbols":"4DC0,4DFF"
|
||||
};
|
||||
|
||||
var insert="charmap_insert";
|
||||
|
||||
function map_load(){
|
||||
editArea=opener.editArea;
|
||||
// translate the document
|
||||
insert= editArea.get_translation(insert, "word");
|
||||
//alert(document.title);
|
||||
document.title= editArea.get_translation(document.title, "template");
|
||||
document.body.innerHTML= editArea.get_translation(document.body.innerHTML, "template");
|
||||
//document.title= editArea.get_translation(document.getElementBytitle, "template");
|
||||
|
||||
var selected_lang=opener.EditArea_charmap.default_language.toLowerCase();
|
||||
var selected=0;
|
||||
|
||||
var select= document.getElementById("select_range")
|
||||
for(var i in char_range_list){
|
||||
if(i.toLowerCase()==selected_lang)
|
||||
selected=select.options.length;
|
||||
select.options[select.options.length]=new Option(i, char_range_list[i]);
|
||||
}
|
||||
select.options[selected].selected=true;
|
||||
/* start=0;
|
||||
end=127;
|
||||
content="";
|
||||
for(var i=start; i<end; i++){
|
||||
content+="&#"+i+"; ";
|
||||
}
|
||||
document.getElementById("char_list").innerHTML=content;*/
|
||||
renderCharMapHTML();
|
||||
}
|
||||
|
||||
|
||||
function renderCharMapHTML() {
|
||||
range= document.getElementById("select_range").value.split(",");
|
||||
|
||||
start= parseInt(range[0],16);
|
||||
end= parseInt(range[1],16);
|
||||
var charsPerRow = 20, tdWidth=20, tdHeight=20;
|
||||
html="";
|
||||
for (var i=start; i<end; i++) {
|
||||
html+="<a class='char' onmouseover='previewChar(\""+ i + "\");' onclick='insertChar(\""+ i + "\");' title='"+ insert +"'>"+ String.fromCharCode(i) +"</a>";
|
||||
}
|
||||
document.getElementById("char_list").innerHTML= html;
|
||||
document.getElementById("preview_char").innerHTML="";
|
||||
}
|
||||
|
||||
function previewChar(i){
|
||||
document.getElementById("preview_char").innerHTML= String.fromCharCode(i);
|
||||
document.getElementById("preview_code").innerHTML= "&#"+ i +";";
|
||||
}
|
||||
|
||||
function insertChar(i){
|
||||
opener.parent.editAreaLoader.setSelectedText(editArea.id, String.fromCharCode( i));
|
||||
range= opener.parent.editAreaLoader.getSelectionRange(editArea.id);
|
||||
opener.parent.editAreaLoader.setSelectionRange(editArea.id, range["end"], range["end"]);
|
||||
window.focus();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Bulgarian translation
|
||||
* Author: Valentin Hristov
|
||||
* Company: SOFTKIT Bulgarian
|
||||
* Site: http://www.softkit-bg.com
|
||||
*/
|
||||
editArea.add_lang("bg",{
|
||||
charmap_but: "Виртуална клавиатура",
|
||||
charmap_title: "Виртуална клавиатура",
|
||||
charmap_choose_block: "избери езиков блок",
|
||||
charmap_insert:"постави този символ"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("cs",{
|
||||
charmap_but: "Visual keyboard",
|
||||
charmap_title: "Visual keyboard",
|
||||
charmap_choose_block: "select language block",
|
||||
charmap_insert:"insert this character"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("de",{
|
||||
charmap_but: "Sonderzeichen",
|
||||
charmap_title: "Sonderzeichen",
|
||||
charmap_choose_block: "Bereich auswählen",
|
||||
charmap_insert: "dieses Zeichen einfügen"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("dk",{
|
||||
charmap_but: "Visual keyboard",
|
||||
charmap_title: "Visual keyboard",
|
||||
charmap_choose_block: "select language block",
|
||||
charmap_insert:"insert this character"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("en",{
|
||||
charmap_but: "Visual keyboard",
|
||||
charmap_title: "Visual keyboard",
|
||||
charmap_choose_block: "select language block",
|
||||
charmap_insert:"insert this character"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("eo",{
|
||||
charmap_but: "Ekranklavaro",
|
||||
charmap_title: "Ekranklavaro",
|
||||
charmap_choose_block: "Elekto de lingvo",
|
||||
charmap_insert:"enmeti tiun signaron"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("es",{
|
||||
charmap_but: "Visual keyboard",
|
||||
charmap_title: "Visual keyboard",
|
||||
charmap_choose_block: "select language block",
|
||||
charmap_insert:"insert this character"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("fr",{
|
||||
charmap_but: "Clavier visuel",
|
||||
charmap_title: "Clavier visuel",
|
||||
charmap_choose_block: "choix du language",
|
||||
charmap_insert:"insérer ce caractère"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("hr",{
|
||||
charmap_but: "Virtualna tipkovnica",
|
||||
charmap_title: "Virtualna tipkovnica",
|
||||
charmap_choose_block: "Odaberi blok s jezikom",
|
||||
charmap_insert:"Ubaci taj znak"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("it",{
|
||||
charmap_but: "Tastiera visuale",
|
||||
charmap_title: "Tastiera visuale",
|
||||
charmap_choose_block: "seleziona blocco",
|
||||
charmap_insert:"inserisci questo carattere"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("ja",{
|
||||
charmap_but: "Visual keyboard",
|
||||
charmap_title: "Visual keyboard",
|
||||
charmap_choose_block: "select language block",
|
||||
charmap_insert:"insert this character"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("mkn",{
|
||||
charmap_but: "Visual keyboard",
|
||||
charmap_title: "Visual keyboard",
|
||||
charmap_choose_block: "select language block",
|
||||
charmap_insert:"insert this character"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("nl",{
|
||||
charmap_but: "Visueel toetsenbord",
|
||||
charmap_title: "Visueel toetsenbord",
|
||||
charmap_choose_block: "Kies een taal blok",
|
||||
charmap_insert:"Voeg dit symbool in"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("pl",{
|
||||
charmap_but: "Klawiatura ekranowa",
|
||||
charmap_title: "Klawiatura ekranowa",
|
||||
charmap_choose_block: "wybierz grupę znaków",
|
||||
charmap_insert:"wstaw ten znak"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("pt",{
|
||||
charmap_but: "Visual keyboard",
|
||||
charmap_title: "Visual keyboard",
|
||||
charmap_choose_block: "select language block",
|
||||
charmap_insert:"insert this character"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("ru",{
|
||||
charmap_but: "Визуальная клавиатура",
|
||||
charmap_title: "Визуальная клавиатура",
|
||||
charmap_choose_block: "выбрать языковой блок",
|
||||
charmap_insert:"вставить этот символ"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("sk",{
|
||||
charmap_but: "Vizuálna klávesnica",
|
||||
charmap_title: "Vizuálna klávesnica",
|
||||
charmap_choose_block: "vyber jazykový blok",
|
||||
charmap_insert: "vlož tento znak"
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
editArea.add_lang("zh",{
|
||||
charmap_but: "软键盘",
|
||||
charmap_title: "软键盘",
|
||||
charmap_choose_block: "选择一个语言块",
|
||||
charmap_insert:"插入此字符"
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
|
||||
<head>
|
||||
<title>{$charmap_title}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="css/charmap.css" />
|
||||
<script language="Javascript" type="text/javascript" src="jscripts/map.js">
|
||||
</script>
|
||||
</head>
|
||||
<body onload='map_load()'>
|
||||
<div id='preview_code' class='preview'></div>
|
||||
<div id='preview_char' class='preview'></div>
|
||||
<h1>{$charmap_title}:</h1>
|
||||
<select id='select_range' onchange='renderCharMapHTML()' title='{$charmap_choose_block}'>
|
||||
</select>
|
||||
<div id='char_list'>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
select#test_select{
|
||||
background-color: #FF0000;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 87 B |
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Bulgarian translation
|
||||
* Author: Valentin Hristov
|
||||
* Company: SOFTKIT Bulgarian
|
||||
* Site: http://www.softkit-bg.com
|
||||
*/
|
||||
editArea.add_lang("bg",{
|
||||
test_select: "избери таг",
|
||||
test_but: "тествай копието"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("cs",{
|
||||
test_select: "select tag",
|
||||
test_but: "test button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("de",{
|
||||
test_select: "Tag auswählen",
|
||||
test_but: "Test Button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("dk",{
|
||||
test_select: "select tag",
|
||||
test_but: "test button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("en",{
|
||||
test_select: "select tag",
|
||||
test_but: "test button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("eo",{
|
||||
test_select:"elekto de marko",
|
||||
test_but: "provo-butono"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("es",{
|
||||
test_select: "select tag",
|
||||
test_but: "test button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("fr",{
|
||||
test_select:"choix balise",
|
||||
test_but: "bouton de test"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("hr",{
|
||||
test_select: "Odaberi tag",
|
||||
test_but: "Probna tipka"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("it",{
|
||||
test_select: "seleziona tag",
|
||||
test_but: "pulsante di test"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("ja",{
|
||||
test_select: "select tag",
|
||||
test_but: "test button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("mk",{
|
||||
test_select: "select tag",
|
||||
test_but: "test button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("nl",{
|
||||
test_select: "select tag",
|
||||
test_but: "test button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("pl",{
|
||||
test_select: "wybierz tag",
|
||||
test_but: "test"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("pt",{
|
||||
test_select: "select tag",
|
||||
test_but: "test button"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("ru",{
|
||||
test_select: "выбрать тэг",
|
||||
test_but: "тестировать кнопку"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("sk",{
|
||||
test_select: "vyber tag",
|
||||
test_but: "testovacie tlačidlo"
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
editArea.add_lang("zh",{
|
||||
test_select: "选择标签",
|
||||
test_but: "测试按钮"
|
||||
});
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Plugin designed for test prupose. It add a button (that manage an alert) and a select (that allow to insert tags) in the toolbar.
|
||||
* This plugin also disable the "f" key in the editarea, and load a CSS and a JS file
|
||||
*/
|
||||
var EditArea_test= {
|
||||
/**
|
||||
* Get called once this file is loaded (editArea still not initialized)
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
init: function(){
|
||||
// alert("test init: "+ this._someInternalFunction(2, 3));
|
||||
editArea.load_css(this.baseURL+"css/test.css");
|
||||
editArea.load_script(this.baseURL+"test2.js");
|
||||
}
|
||||
/**
|
||||
* Returns the HTML code for a specific control string or false if this plugin doesn't have that control.
|
||||
* A control can be a button, select list or any other HTML item to present in the EditArea user interface.
|
||||
* Language variables such as {$lang_somekey} will also be replaced with contents from
|
||||
* the language packs.
|
||||
*
|
||||
* @param {string} ctrl_name: the name of the control to add
|
||||
* @return HTML code for a specific control or false.
|
||||
* @type string or boolean
|
||||
*/
|
||||
,get_control_html: function(ctrl_name){
|
||||
switch(ctrl_name){
|
||||
case "test_but":
|
||||
// Control id, button img, command
|
||||
return parent.editAreaLoader.get_button_html('test_but', 'test.gif', 'test_cmd', false, this.baseURL);
|
||||
case "test_select":
|
||||
html= "<select id='test_select' onchange='javascript:editArea.execCommand(\"test_select_change\")' fileSpecific='no'>"
|
||||
+" <option value='-1'>{$test_select}</option>"
|
||||
+" <option value='h1'>h1</option>"
|
||||
+" <option value='h2'>h2</option>"
|
||||
+" <option value='h3'>h3</option>"
|
||||
+" <option value='h4'>h4</option>"
|
||||
+" <option value='h5'>h5</option>"
|
||||
+" <option value='h6'>h6</option>"
|
||||
+" </select>";
|
||||
return html;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get called once EditArea is fully loaded and initialised
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
,onload: function(){
|
||||
alert("test load");
|
||||
}
|
||||
|
||||
/**
|
||||
* Is called each time the user touch a keyboard key.
|
||||
*
|
||||
* @param (event) e: the keydown event
|
||||
* @return true - pass to next handler in chain, false - stop chain execution
|
||||
* @type boolean
|
||||
*/
|
||||
,onkeydown: function(e){
|
||||
var str= String.fromCharCode(e.keyCode);
|
||||
// desactivate the "f" character
|
||||
if(str.toLowerCase()=="f"){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a specific command, this function handles plugin commands.
|
||||
*
|
||||
* @param {string} cmd: the name of the command being executed
|
||||
* @param {unknown} param: the parameter of the command
|
||||
* @return true - pass to next handler in chain, false - stop chain execution
|
||||
* @type boolean
|
||||
*/
|
||||
,execCommand: function(cmd, param){
|
||||
// Handle commands
|
||||
switch(cmd){
|
||||
case "test_select_change":
|
||||
var val= document.getElementById("test_select").value;
|
||||
if(val!=-1)
|
||||
parent.editAreaLoader.insertTags(editArea.id, "<"+val+">", "</"+val+">");
|
||||
document.getElementById("test_select").options[0].selected=true;
|
||||
return false;
|
||||
case "test_cmd":
|
||||
alert("user clicked on test_cmd");
|
||||
return false;
|
||||
}
|
||||
// Pass to next handler in chain
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is just an internal plugin method, prefix all internal methods with a _ character.
|
||||
* The prefix is needed so they doesn't collide with future EditArea callback functions.
|
||||
*
|
||||
* @param {string} a Some arg1.
|
||||
* @param {string} b Some arg2.
|
||||
* @return Some return.
|
||||
* @type unknown
|
||||
*/
|
||||
,_someInternalFunction : function(a, b) {
|
||||
return a+b;
|
||||
}
|
||||
};
|
||||
|
||||
// Adds the plugin class to the list of available EditArea plugins
|
||||
editArea.add_plugin("test", EditArea_test);
|
||||
@@ -0,0 +1 @@
|
||||
alert("test2.js is loaded from test plugin");
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @author Sergey Chikuyonok (serge.che@gmail.com)
|
||||
* @link http://chikuyonok.ru
|
||||
*/
|
||||
@@ -0,0 +1,420 @@
|
||||
/**
|
||||
* Layer that binds Zen Coding's actions to editArea
|
||||
*
|
||||
* @author Sergey Chikuyonok (serge.che@gmail.com)
|
||||
* @link http://chikuyonok.ru
|
||||
*
|
||||
* @include "zen_coding.js"
|
||||
* @include "html_matcher.js"
|
||||
*/
|
||||
|
||||
var EditArea_zencoding = (function() {
|
||||
/** @type {EditArea} Current editor's instance */
|
||||
var editor = null,
|
||||
editor_id = 0,
|
||||
is_mac = (/mac\s+os/i.test(navigator.userAgent));
|
||||
|
||||
/**
|
||||
* Return true if Alt key is pressed
|
||||
* @param {Event} evt
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function AltPressed(e) {
|
||||
if (window.event)
|
||||
return (window.event.altKey);
|
||||
else
|
||||
return e.modifiers ? (e.altKey || (e.modifiers % 2)) : e.altKey;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return true if Ctrl key is pressed
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function CtrlPressed(e) {
|
||||
// as usual, Opera brings few "suprises" here
|
||||
if (window.event && !is_mac) {
|
||||
return (window.event.ctrlKey);
|
||||
} else {
|
||||
return (e.ctrlKey || (e.metaKey && window.opera) || (e.modifiers==2) || (e.modifiers==3) || (e.modifiers>5));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Return true if Shift key is pressed
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function ShiftPressed(e) {
|
||||
if (window.event) {
|
||||
return (window.event.shiftKey);
|
||||
} else {
|
||||
return (e.shiftKey || (e.modifiers>3));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Finds abbreviation in cucrrent editor and returns it
|
||||
* @return {String|null}
|
||||
*/
|
||||
function findAbbreviation() {
|
||||
var range = editor.getSelectionRange(editor_id);
|
||||
if (range.start != range.end) {
|
||||
// abbreviation is selected by user
|
||||
return editor.getSelectedText(editor_id);
|
||||
} else {
|
||||
var content = editor.getValue(editor_id);
|
||||
return zen_coding.extractAbbreviation(content.substring(0, range.start));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns full line on text for passed character position
|
||||
*/
|
||||
function getLine(char_pos) {
|
||||
var content = editor.getValue(editor_id),
|
||||
start_ix = char_pos,
|
||||
end_ix,
|
||||
ch;
|
||||
|
||||
function isNewline(ch) {
|
||||
return ch == '\n' || ch == '\r';
|
||||
}
|
||||
|
||||
// find the beginnig of the line
|
||||
while (start_ix--) {
|
||||
if (isNewline(content.charAt(start_ix))) {
|
||||
start_ix++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// find the end of the line
|
||||
for (end_ix = char_pos; end_ix < content.length; end_ix++) {
|
||||
if (isNewline(content.charAt(end_ix)))
|
||||
break;
|
||||
}
|
||||
|
||||
return content.substring(start_ix, end_ix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns padding of current editor's line
|
||||
* @return {String}
|
||||
*/
|
||||
function getCurrentLinePadding() {
|
||||
var range = editor.getSelectionRange(editor_id),
|
||||
cur_line = getLine(range.start);
|
||||
|
||||
return (cur_line.match(/^(\s+)/) || [''])[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces current editor's substring with new content. Multiline content
|
||||
* will be automatically padded
|
||||
*
|
||||
* @param {String} editor_str Current editor's substring
|
||||
* @param {String} content New content
|
||||
*/
|
||||
function replaceEditorContent(editor_str, content) {
|
||||
if (!content)
|
||||
return;
|
||||
|
||||
// add padding for current line
|
||||
content = zen_coding.padString(content, getCurrentLinePadding());
|
||||
|
||||
// get char index where we need to place cursor
|
||||
var range = editor.getSelectionRange(editor_id);
|
||||
var start_pos = range.end - editor_str.length;
|
||||
var cursor_pos = content.indexOf('|');
|
||||
content = content.replace(/\|/g, '');
|
||||
|
||||
// replace content in editor
|
||||
editor.setSelectionRange(editor_id, start_pos, start_pos + editor_str.length);
|
||||
editor.setSelectedText(editor_id, content);
|
||||
|
||||
// place cursor
|
||||
if (cursor_pos != -1)
|
||||
editor.setSelectionRange(editor_id, start_pos + cursor_pos, start_pos + cursor_pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for the new edit point
|
||||
* @param {Number} Search direction: -1 — left, 1 — right
|
||||
* @param {Number} Initial offset from the current caret position
|
||||
* @return {Number} Returns -1 if edit point wasn't found
|
||||
*/
|
||||
function findNewEditPoint(inc, offset) {
|
||||
inc = inc || 1;
|
||||
offset = offset || 0;
|
||||
var content = editor.getValue(editor_id),
|
||||
cur_point = editor.getSelectionRange(editor_id).start + offset,
|
||||
max_len = content.length,
|
||||
next_point = -1;
|
||||
|
||||
function ch(ix) {
|
||||
return content.charAt(ix);
|
||||
}
|
||||
|
||||
while (cur_point < max_len && cur_point > 0) {
|
||||
cur_point += inc;
|
||||
var cur_char = ch(cur_point),
|
||||
next_char = ch(cur_point + 1),
|
||||
prev_char = ch(cur_point - 1);
|
||||
|
||||
switch (cur_char) {
|
||||
case '"':
|
||||
case '\'':
|
||||
if (next_char == cur_char && prev_char == '=') {
|
||||
// empty attribute
|
||||
next_point = cur_point + 1;
|
||||
}
|
||||
break;
|
||||
case '>':
|
||||
if (next_char == '<') {
|
||||
// between tags
|
||||
next_point = cur_point + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (next_point != -1)
|
||||
break;
|
||||
}
|
||||
|
||||
return next_point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unindent content, thus preparing text for tag wrapping
|
||||
* @param {String} text
|
||||
* @return {String}
|
||||
*/
|
||||
function unindent(text) {
|
||||
var pad = getCurrentLinePadding();
|
||||
var lines = zen_coding.splitByLines(text);
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i].search(pad) == 0)
|
||||
lines[i] = lines[i].substr(pad.length);
|
||||
}
|
||||
|
||||
return lines.join(zen_coding.getNewline());
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps content with abbreviation
|
||||
* @param {String} editor_type
|
||||
* @param {String} profile_name
|
||||
*/
|
||||
function mainWrapWithAbbreviation(editor_type, profile_name) {
|
||||
profile_name = profile_name || 'xhtml';
|
||||
|
||||
var range = editor.getSelectionRange(editor_id),
|
||||
content = editor.getValue(editor_id),
|
||||
start_offset = range.start,
|
||||
end_offset = range.end,
|
||||
|
||||
abbr = prompt('Enter abbreviation');
|
||||
|
||||
if (!abbr)
|
||||
return null;
|
||||
|
||||
if (start_offset == end_offset) {
|
||||
// no selection, find tag pair
|
||||
var range = HTMLPairMatcher(content, Math.max(start_offset, end_offset));
|
||||
|
||||
if (!range || range[0] == -1) // nothing to wrap
|
||||
return null;
|
||||
|
||||
start_offset = range[0];
|
||||
end_offset = range[1];
|
||||
|
||||
// narrow down selection until first non-space character
|
||||
var re_space = /\s|\n|\r/;
|
||||
function isSpace(ch) {
|
||||
return re_space.test(ch);
|
||||
}
|
||||
|
||||
while (start_offset < end_offset) {
|
||||
if (!isSpace(content.charAt(start_offset)))
|
||||
break;
|
||||
|
||||
start_offset++;
|
||||
}
|
||||
|
||||
while (end_offset > start_offset) {
|
||||
end_offset--;
|
||||
if (!isSpace(content.charAt(end_offset))) {
|
||||
end_offset++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var content = content.substring(start_offset, end_offset),
|
||||
result = zen_coding.wrapWithAbbreviation(abbr, unindent(content), editor_type, profile_name);
|
||||
|
||||
if (result) {
|
||||
editor.setSelectionRange(editor_id, end_offset, end_offset);
|
||||
replaceEditorContent(content, result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs Zen Coding action on keydown event
|
||||
* @param {Event} evt
|
||||
*/
|
||||
function keyDown(evt) {
|
||||
evt = evt || window.event;
|
||||
var letter = String.fromCharCode(evt.keyCode).toLowerCase(),
|
||||
stop_event = false;
|
||||
|
||||
if (CtrlPressed(evt) && !AltPressed(evt) && !ShiftPressed(evt)) {
|
||||
switch (evt.keyCode) {
|
||||
case 188: // Ctrl+, — expand abbreviation
|
||||
case 44:
|
||||
var abbr = findAbbreviation();
|
||||
if (abbr) {
|
||||
var profile_name = 'xhtml',
|
||||
syntax = (editArea.current_code_lang in zen_settings) ? editArea.current_code_lang : 'html';
|
||||
|
||||
var content = zen_coding.expandAbbreviation(abbr, syntax, profile_name);
|
||||
replaceEditorContent(abbr, content);
|
||||
}
|
||||
stop_event = true;
|
||||
break;
|
||||
case 77: // Ctrl+M — match pair
|
||||
case 109:
|
||||
var selection = editor.getSelectionRange(editor_id),
|
||||
range = HTMLPairMatcher(editor.getValue(editor_id), Math.max(selection.start, selection.end));
|
||||
|
||||
if (range && range[0] != -1)
|
||||
editor.setSelectionRange(editor_id, range[0], range[1]);
|
||||
|
||||
stop_event = true;
|
||||
break;
|
||||
case 72: // Ctrl+H — wrap with abbreviation
|
||||
mainWrapWithAbbreviation('html', 'xhtml');
|
||||
|
||||
stop_event = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (CtrlPressed(evt) && !AltPressed(evt) && ShiftPressed(evt)) {
|
||||
switch (evt.keyCode) {
|
||||
case 37: // Ctrl+Shift+LEFT_ARROW – prev edit point
|
||||
var new_point = findNewEditPoint(-1),
|
||||
range = editor.getSelectionRange(editor_id);
|
||||
|
||||
|
||||
if (new_point == range.start)
|
||||
// returned to the current position, start searching from the new one
|
||||
new_point = findNewEditPoint(-1, -2);
|
||||
|
||||
if (new_point != -1)
|
||||
editor.setSelectionRange(editor_id, new_point, new_point);
|
||||
|
||||
stop_event = true;
|
||||
break;
|
||||
|
||||
case 39: // Shift+Ctrl+RIGHT_ARROW – next edit point
|
||||
var new_point = findNewEditPoint(1);
|
||||
if (new_point != -1)
|
||||
editor.setSelectionRange(editor_id, new_point, new_point);
|
||||
|
||||
stop_event = true;
|
||||
break;
|
||||
|
||||
case 38: // Shift+Ctrl+UP_ARROW – go to matching pair
|
||||
var caret_pos = editor.getSelectionRange(editor_id).start,
|
||||
content = editor.getValue(editor_id);
|
||||
|
||||
if (content.charAt(caret_pos) == '<')
|
||||
// looks like caret is outside of tag pair
|
||||
caret_pos++;
|
||||
|
||||
var range = HTMLPairMatcher(content, caret_pos);
|
||||
|
||||
if (range && range[0] != -1) {
|
||||
// match found
|
||||
var open_tag = HTMLPairMatcher.last_match.opening_tag,
|
||||
close_tag = HTMLPairMatcher.last_match.closing_tag;
|
||||
|
||||
if (close_tag) { // exclude unary tags
|
||||
var new_pos = -1;
|
||||
if (open_tag.start <= caret_pos && open_tag.end >= caret_pos)
|
||||
new_pos = close_tag.start
|
||||
else if (close_tag.start <= caret_pos && close_tag.end >= caret_pos)
|
||||
new_pos = open_tag.start;
|
||||
|
||||
if (new_pos != -1)
|
||||
editor.setSelectionRange(editor_id, new_pos, new_pos);
|
||||
}
|
||||
}
|
||||
|
||||
stop_event = true;
|
||||
break;
|
||||
|
||||
case 77: // Shift+Ctrl+M — merge lines
|
||||
var range = editor.getSelectionRange(editor_id),
|
||||
content = editor.getValue(editor_id),
|
||||
start_ix = range.start,
|
||||
end_ix = range.end;
|
||||
|
||||
if (start_ix == end_ix) {
|
||||
// find matching tag
|
||||
var pair = HTMLPairMatcher(content, start_ix);
|
||||
if (pair) {
|
||||
start_ix = pair[0];
|
||||
end_ix = pair[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (start_ix != end_ix) {
|
||||
// got range, merge lines
|
||||
var text = content.substring(start_ix, end_ix),
|
||||
old_text = text;
|
||||
|
||||
var lines = text.split(/(\r|\n)/);
|
||||
|
||||
for (var i = 1; i < lines.length; i++) {
|
||||
lines[i] = lines[i].replace(/^\s+/, '');
|
||||
}
|
||||
|
||||
text = lines.join('').replace(/\s{2,}/, ' ');
|
||||
|
||||
editor.setSelectionRange(editor_id, end_ix, end_ix);
|
||||
replaceEditorContent(old_text, text);
|
||||
}
|
||||
|
||||
stop_event = true;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(stop_event){
|
||||
// in case of a control that sould'nt be used by IE but that is used => THROW a javascript error that will stop key action
|
||||
if(window.event) evt.keyCode = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
init: function() {
|
||||
editArea.load_script(this.baseURL+"core.js");
|
||||
},
|
||||
|
||||
onkeydown: function(evt) {
|
||||
editor = parent.editAreaLoader;
|
||||
editor_id = editArea.id;
|
||||
|
||||
return keyDown(evt);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
editArea.add_plugin("zencoding", EditArea_zencoding);
|
||||
Reference in New Issue
Block a user