From a0109c4933e0bfb5ed9dbcf94f932991ca689542 Mon Sep 17 00:00:00 2001 From: svncommit Date: Thu, 14 Sep 2006 03:49:28 +0000 Subject: Initial TinyMCE editor support (still need to work on spellcheck and skins) --- .../plugins/searchreplace/editor_plugin.js | 1 + .../plugins/searchreplace/editor_plugin_src.js | 185 +++++++++++++++++++++ .../plugins/searchreplace/images/replace.gif | Bin 0 -> 125 bytes .../plugins/searchreplace/images/search.gif | Bin 0 -> 191 bytes .../plugins/searchreplace/jscripts/replace.js | 40 +++++ .../plugins/searchreplace/jscripts/search.js | 36 ++++ .../js/tiny_mce/plugins/searchreplace/langs/en.js | 21 +++ .../js/tiny_mce/plugins/searchreplace/readme.txt | 1 + .../js/tiny_mce/plugins/searchreplace/replace.htm | 49 ++++++ .../js/tiny_mce/plugins/searchreplace/search.htm | 42 +++++ 10 files changed, 375 insertions(+) create mode 100644 program/js/tiny_mce/plugins/searchreplace/editor_plugin.js create mode 100644 program/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js create mode 100644 program/js/tiny_mce/plugins/searchreplace/images/replace.gif create mode 100644 program/js/tiny_mce/plugins/searchreplace/images/search.gif create mode 100644 program/js/tiny_mce/plugins/searchreplace/jscripts/replace.js create mode 100644 program/js/tiny_mce/plugins/searchreplace/jscripts/search.js create mode 100644 program/js/tiny_mce/plugins/searchreplace/langs/en.js create mode 100644 program/js/tiny_mce/plugins/searchreplace/readme.txt create mode 100644 program/js/tiny_mce/plugins/searchreplace/replace.htm create mode 100644 program/js/tiny_mce/plugins/searchreplace/search.htm (limited to 'program/js/tiny_mce/plugins/searchreplace') diff --git a/program/js/tiny_mce/plugins/searchreplace/editor_plugin.js b/program/js/tiny_mce/plugins/searchreplace/editor_plugin.js new file mode 100644 index 000000000..a78b35e06 --- /dev/null +++ b/program/js/tiny_mce/plugins/searchreplace/editor_plugin.js @@ -0,0 +1 @@ +tinyMCE.importPluginLanguagePack('searchreplace','en,tr,sv,zh_cn,fa,fr_ca,fr,de,pl,pt_br,cs,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,zh_tw,zh_tw_utf8,sk');var TinyMCE_SearchReplacePlugin={getInfo:function(){return{longname:'Search/Replace',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_searchreplace.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},initInstance:function(inst){inst.addShortcut('ctrl','f','lang_searchreplace_search_desc','mceSearch',true);},getControlHTML:function(cn){switch(cn){case"search":return tinyMCE.getButtonHTML(cn,'lang_searchreplace_search_desc','{$pluginurl}/images/search.gif','mceSearch',true);case"replace":return tinyMCE.getButtonHTML(cn,'lang_searchreplace_replace_desc','{$pluginurl}/images/replace.gif','mceSearchReplace',true);}return"";},execCommand:function(editor_id,element,command,user_interface,value){var instance=tinyMCE.getInstanceById(editor_id);function defValue(key,default_value){value[key]=typeof(value[key])=="undefined"?default_value:value[key];}function replaceSel(search_str,str,back){instance.execCommand('mceInsertContent',false,str);}if(!value)value=new Array();defValue("editor_id",editor_id);defValue("searchstring","");defValue("replacestring",null);defValue("replacemode","none");defValue("casesensitive",false);defValue("backwards",false);defValue("wrap",false);defValue("wholeword",false);defValue("inline","yes");switch(command){case"mceResetSearch":tinyMCE.lastSearchRng=null;return true;case"mceSearch":if(user_interface){var template=new Array();if(value['replacestring']!=null){template['file']='../../plugins/searchreplace/replace.htm';template['width']=320;template['height']=100+(tinyMCE.isNS7?20:0);template['width']+=tinyMCE.getLang('lang_searchreplace_replace_delta_width',0);template['height']+=tinyMCE.getLang('lang_searchreplace_replace_delta_height',0);}else{template['file']='../../plugins/searchreplace/search.htm';template['width']=310;template['height']=105+(tinyMCE.isNS7?25:0);template['width']+=tinyMCE.getLang('lang_searchreplace_search_delta_width',0);template['height']+=tinyMCE.getLang('lang_searchreplace_replace_delta_height',0);}instance.execCommand('SelectAll');if(tinyMCE.isMSIE){var r=instance.selection.getRng();r.collapse(true);r.select();}else instance.selection.getSel().collapseToStart();tinyMCE.openWindow(template,value);}else{var win=tinyMCE.getInstanceById(editor_id).contentWindow;var doc=tinyMCE.getInstanceById(editor_id).contentWindow.document;var body=tinyMCE.getInstanceById(editor_id).contentWindow.document.body;if(body.innerHTML==""){alert(tinyMCE.getLang('lang_searchreplace_notfound'));return true;}if(value['replacemode']=="current"){replaceSel(value['string'],value['replacestring'],value['backwards']);value['replacemode']="none";tinyMCE.execInstanceCommand(editor_id,'mceSearch',user_interface,value,false);return true;}if(tinyMCE.isMSIE){var rng=tinyMCE.lastSearchRng?tinyMCE.lastSearchRng:doc.selection.createRange();var flags=0;if(value['wholeword'])flags=flags|2;if(value['casesensitive'])flags=flags|4;if(!rng.findText){alert('This operation is currently not supported by this browser.');return true;}if(value['replacemode']=="all"){while(rng.findText(value['string'],value['backwards']?-1:1,flags)){rng.scrollIntoView();rng.select();rng.collapse(false);replaceSel(value['string'],value['replacestring'],value['backwards']);}alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));return true;}if(rng.findText(value['string'],value['backwards']?-1:1,flags)){rng.scrollIntoView();rng.select();rng.collapse(value['backwards']);tinyMCE.lastSearchRng=rng;}else alert(tinyMCE.getLang('lang_searchreplace_notfound'));}else{if(value['replacemode']=="all"){while(win.find(value['string'],value['casesensitive'],value['backwards'],value['wrap'],value['wholeword'],false,false))replaceSel(value['string'],value['replacestring'],value['backwards']);alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));return true;}if(!win.find(value['string'],value['casesensitive'],value['backwards'],value['wrap'],value['wholeword'],false,false))alert(tinyMCE.getLang('lang_searchreplace_notfound'));}}return true;case"mceSearchReplace":value['replacestring']="";tinyMCE.execInstanceCommand(editor_id,'mceSearch',user_interface,value,false);return true;}return false;}};tinyMCE.addPlugin("searchreplace",TinyMCE_SearchReplacePlugin); \ No newline at end of file diff --git a/program/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js b/program/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js new file mode 100644 index 000000000..eed96db9e --- /dev/null +++ b/program/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js @@ -0,0 +1,185 @@ +/** + * $RCSfile: editor_plugin_src.js,v $ + * $Revision: 1.27 $ + * $Date: 2006/02/13 15:09:28 $ + * + * @author Moxiecode + * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. + */ + +/* Import theme specific language pack */ +tinyMCE.importPluginLanguagePack('searchreplace', 'en,tr,sv,zh_cn,fa,fr_ca,fr,de,pl,pt_br,cs,nl,da,he,nb,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,zh_tw,zh_tw_utf8,sk'); + +var TinyMCE_SearchReplacePlugin = { + getInfo : function() { + return { + longname : 'Search/Replace', + author : 'Moxiecode Systems', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_searchreplace.html', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; + }, + + initInstance : function(inst) { + inst.addShortcut('ctrl', 'f', 'lang_searchreplace_search_desc', 'mceSearch', true); + }, + + getControlHTML : function(cn) { + switch (cn) { + case "search": + return tinyMCE.getButtonHTML(cn, 'lang_searchreplace_search_desc', '{$pluginurl}/images/search.gif', 'mceSearch', true); + case "replace": + return tinyMCE.getButtonHTML(cn, 'lang_searchreplace_replace_desc', '{$pluginurl}/images/replace.gif', 'mceSearchReplace', true); + } + return ""; + }, + + /** + * Executes the search/replace commands. + */ + execCommand : function(editor_id, element, command, user_interface, value) { + var instance = tinyMCE.getInstanceById(editor_id); + + function defValue(key, default_value) { + value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; + } + + function replaceSel(search_str, str, back) { + instance.execCommand('mceInsertContent', false, str); + } + + if (!value) + value = new Array(); + + // Setup defualt values + defValue("editor_id", editor_id); + defValue("searchstring", ""); + defValue("replacestring", null); + defValue("replacemode", "none"); + defValue("casesensitive", false); + defValue("backwards", false); + defValue("wrap", false); + defValue("wholeword", false); + defValue("inline", "yes"); + + // Handle commands + switch (command) { + case "mceResetSearch": + tinyMCE.lastSearchRng = null; + return true; + + case "mceSearch": + if (user_interface) { + // Open search dialog + var template = new Array(); + + if (value['replacestring'] != null) { + template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme + template['width'] = 320; + template['height'] = 100 + (tinyMCE.isNS7 ? 20 : 0); + template['width'] += tinyMCE.getLang('lang_searchreplace_replace_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); + } else { + template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme + template['width'] = 310; + template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); + template['width'] += tinyMCE.getLang('lang_searchreplace_search_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_searchreplace_replace_delta_height', 0); + } + + instance.execCommand('SelectAll'); + + if (tinyMCE.isMSIE) { + var r = instance.selection.getRng(); + r.collapse(true); + r.select(); + } else + instance.selection.getSel().collapseToStart(); + + tinyMCE.openWindow(template, value); + } else { + var win = tinyMCE.getInstanceById(editor_id).contentWindow; + var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; + var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body; + + // Whats the point + if (body.innerHTML == "") { + alert(tinyMCE.getLang('lang_searchreplace_notfound')); + return true; + } + + // Handle replace current + if (value['replacemode'] == "current") { + replaceSel(value['string'], value['replacestring'], value['backwards']); + + // Search next one + value['replacemode'] = "none"; + tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); + + return true; + } + + if (tinyMCE.isMSIE) { + var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); + var flags = 0; + + if (value['wholeword']) + flags = flags | 2; + + if (value['casesensitive']) + flags = flags | 4; + + if (!rng.findText) { + alert('This operation is currently not supported by this browser.'); + return true; + } + + // Handle replace all mode + if (value['replacemode'] == "all") { + while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { + rng.scrollIntoView(); + rng.select(); + rng.collapse(false); + replaceSel(value['string'], value['replacestring'], value['backwards']); + } + + alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); + return true; + } + + if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { + rng.scrollIntoView(); + rng.select(); + rng.collapse(value['backwards']); + tinyMCE.lastSearchRng = rng; + } else + alert(tinyMCE.getLang('lang_searchreplace_notfound')); + } else { + if (value['replacemode'] == "all") { + while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) + replaceSel(value['string'], value['replacestring'], value['backwards']); + + alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); + return true; + } + + if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) + alert(tinyMCE.getLang('lang_searchreplace_notfound')); + } + } + return true; + + case "mceSearchReplace": + value['replacestring'] = ""; + + tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); + return true; + } + + // Pass to next handler in chain + return false; + } +}; + +tinyMCE.addPlugin("searchreplace", TinyMCE_SearchReplacePlugin); diff --git a/program/js/tiny_mce/plugins/searchreplace/images/replace.gif b/program/js/tiny_mce/plugins/searchreplace/images/replace.gif new file mode 100644 index 000000000..784c73e2a Binary files /dev/null and b/program/js/tiny_mce/plugins/searchreplace/images/replace.gif differ diff --git a/program/js/tiny_mce/plugins/searchreplace/images/search.gif b/program/js/tiny_mce/plugins/searchreplace/images/search.gif new file mode 100644 index 000000000..cfe76b5d5 Binary files /dev/null and b/program/js/tiny_mce/plugins/searchreplace/images/search.gif differ diff --git a/program/js/tiny_mce/plugins/searchreplace/jscripts/replace.js b/program/js/tiny_mce/plugins/searchreplace/jscripts/replace.js new file mode 100644 index 000000000..3cb417813 --- /dev/null +++ b/program/js/tiny_mce/plugins/searchreplace/jscripts/replace.js @@ -0,0 +1,40 @@ +function init() { + tinyMCEPopup.resizeToInnerSize(); + + var formObj = document.forms[0]; + + formObj.searchstring.value = tinyMCE.getWindowArg("searchstring"); + formObj.replacestring.value = tinyMCE.getWindowArg("replacestring"); + formObj.casesensitivebox.checked = tinyMCE.getWindowArg("casesensitive"); +// formObj.backwards[0].checked = tinyMCE.getWindowArg("backwards"); +// formObj.backwards[1].checked = !tinyMCE.getWindowArg("backwards"); +// formObj.wrapatend.checked = tinyMCE.getWindowArg("wrap"); +// formObj.wholeword.checked = tinyMCE.getWindowArg("wholeword"); + + tinyMCEPopup.execCommand("mceResetSearch", false, {dummy : ""}, false); +} + +function searchNext(replacemode) { + var formObj = document.forms[0]; + + // Whats the point? + if (formObj.searchstring.value == "" || formObj.searchstring.value == formObj.replacestring.value) + return; + + // Do search + tinyMCEPopup.execCommand('mceSearch', false, { + string : formObj.searchstring.value, + replacestring : formObj.replacestring.value, + replacemode : replacemode, + casesensitive : formObj.casesensitivebox.checked, + backwards : false +// wrap : formObj.wrapatend.checked, +// wholeword : formObj.wholeword.checked + }, false); + + window.focus(); +} + +function cancelAction() { + tinyMCEPopup.close(); +} diff --git a/program/js/tiny_mce/plugins/searchreplace/jscripts/search.js b/program/js/tiny_mce/plugins/searchreplace/jscripts/search.js new file mode 100644 index 000000000..5202fdc50 --- /dev/null +++ b/program/js/tiny_mce/plugins/searchreplace/jscripts/search.js @@ -0,0 +1,36 @@ +function init() { + tinyMCEPopup.resizeToInnerSize(); + + var formObj = document.forms[0]; + + formObj.searchstring.value = tinyMCE.getWindowArg("searchstring"); + formObj.casesensitivebox.checked = tinyMCE.getWindowArg("casesensitive"); + formObj.backwards[0].checked = tinyMCE.getWindowArg("backwards"); + formObj.backwards[1].checked = !tinyMCE.getWindowArg("backwards"); +// formObj.wrapatend.checked = tinyMCE.getWindowArg("wrap"); +// formObj.wholeword.checked = tinyMCE.getWindowArg("wholeword"); + + tinyMCEPopup.execCommand("mceResetSearch", false, {dummy : ""}, false); +} + +function searchNext() { + var formObj = document.forms[0]; + + if (formObj.searchstring.value == "") + return; + + // Do search + tinyMCEPopup.execCommand('mceSearch', false, { + string : formObj.searchstring.value, + casesensitive : formObj.casesensitivebox.checked, + backwards : formObj.backwards[0].checked +// wrap : formObj.wrapatend.checked, +// wholeword : formObj.wholeword.checked + }, false); + + window.focus(); +} + +function cancelAction() { + tinyMCEPopup.close(); +} diff --git a/program/js/tiny_mce/plugins/searchreplace/langs/en.js b/program/js/tiny_mce/plugins/searchreplace/langs/en.js new file mode 100644 index 000000000..32af8282e --- /dev/null +++ b/program/js/tiny_mce/plugins/searchreplace/langs/en.js @@ -0,0 +1,21 @@ +// UK lang variables + +tinyMCE.addToLang('',{ +searchreplace_search_desc : 'Find', +searchreplace_searchnext_desc : 'Find again', +searchreplace_replace_desc : 'Find/Replace', +searchreplace_notfound : 'The search has been completed. The search string could not be found.', +searchreplace_search_title : 'Find', +searchreplace_replace_title : 'Find/Replace', +searchreplace_allreplaced : 'All occurrences of the search string were replaced.', +searchreplace_findwhat : 'Find what', +searchreplace_replacewith : 'Replace with', +searchreplace_direction : 'Direction', +searchreplace_up : 'Up', +searchreplace_down : 'Down', +searchreplace_case : 'Match case', +searchreplace_findnext : 'Find next', +searchreplace_replace : 'Replace', +searchreplace_replaceall : 'Replace all', +searchreplace_cancel : 'Cancel' +}); diff --git a/program/js/tiny_mce/plugins/searchreplace/readme.txt b/program/js/tiny_mce/plugins/searchreplace/readme.txt new file mode 100644 index 000000000..4fdb78aec --- /dev/null +++ b/program/js/tiny_mce/plugins/searchreplace/readme.txt @@ -0,0 +1 @@ +Check the TinyMCE documentation for details on this plugin. diff --git a/program/js/tiny_mce/plugins/searchreplace/replace.htm b/program/js/tiny_mce/plugins/searchreplace/replace.htm new file mode 100644 index 000000000..0629da334 --- /dev/null +++ b/program/js/tiny_mce/plugins/searchreplace/replace.htm @@ -0,0 +1,49 @@ + + + {$lang_searchreplace_replace_title} + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + +
+
+ + diff --git a/program/js/tiny_mce/plugins/searchreplace/search.htm b/program/js/tiny_mce/plugins/searchreplace/search.htm new file mode 100644 index 000000000..fe9055ed5 --- /dev/null +++ b/program/js/tiny_mce/plugins/searchreplace/search.htm @@ -0,0 +1,42 @@ + + + {$lang_searchreplace_search_title} + + + + + +
+ + + + + + + + + + +
 
+ + + + + + + +
+ + + + +
+ + + + + +
+
+ + -- cgit v1.2.3