diff options
author | Bret McMillan <bretm@redhat.com> | 2008-11-17 14:16:41 -0500 |
---|---|---|
committer | Bret McMillan <bretm@redhat.com> | 2008-11-17 14:16:41 -0500 |
commit | d493deead64ba76da6d8a295d619644167b01477 (patch) | |
tree | 621c060ed8c2fed52bcf8f647fef166b0bdaf4ca | |
parent | 6e6e46400b225f0ed2152f076a1f17622c31796c (diff) | |
download | mediawiki-stuff-d493deead64ba76da6d8a295d619644167b01477.tar.gz mediawiki-stuff-d493deead64ba76da6d8a295d619644167b01477.tar.xz mediawiki-stuff-d493deead64ba76da6d8a295d619644167b01477.zip |
dos2unix fixes
-rw-r--r-- | extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/editor_plugin.js | 248 |
1 files changed, 124 insertions, 124 deletions
diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/editor_plugin.js b/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/editor_plugin.js index 8767200..47f2770 100644 --- a/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/editor_plugin.js +++ b/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/editor_plugin.js @@ -1,125 +1,125 @@ -/**
- * $Id$
- *
- * @author Bret McMillan <bretm@redhat.com>
- * @copyright Copyright © 2004-2008, Red Hat, Inc., All rights reserved.
- *
- * Adapted from:
- * - the "example" and "bbcode" plugins provided by Moxicode
- * - Remy Sharp's wiki2html code: http://remysharp.com/2008/04/01/wiki-to-html-using-javascript/
- *
- * See also: http://en.wikipedia.org/wiki/Wikipedia:Cheatsheet
- */
-
-(function() {
- tinymce.create('tinymce.plugins.MediaWikiPlugin', {
- /**
- * Initializes the plugin, this will be executed after the plugin has been created.
- * This call is done before the editor instance has finished it's initialization so use the onInit event
- * of the editor instance to intercept that event.
- *
- * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
- * @param {string} url Absolute URL to where the plugin is located.
- */
- init : function(ed, url) {
- var t = this;
- // load wiki2html syncronous calls...
- // might want to explore async later
- tinymce.ScriptLoader.load(tinymce.PluginManager.urls.mediawiki + '/wiki2html.js');
-
- ed.onBeforeSetContent.add(function(ed, o) {
- o.content = t['_mw2html'](o.content);
- });
-
- ed.onPostProcess.add(function(ed, o) {
- if (o.set)
- o.content = t['_mw2html'](o.content);
-
- if (o.get)
- o.content = t['_html2mw'](o.content);
-
- });
- },
-
- /**
- * Returns information about the plugin as a name/value array.
- * The current keys are longname, author, authorurl, infourl and version.
- *
- * @return {Object} Name/value array containing information about the plugin.
- */
- getInfo : function() {
- return {
- longname : 'MediaWiki plugin',
- author : 'Bret McMillan <bretm@redhat.com>',
- authorurl : 'http://www.redhat.com/',
- infourl : 'http://www.redhat.com/',
- version : "0.1"
- };
- },
-
- // Private methods
-
- // HTML -> MediaWiki, it'd be nice to get this upstream into remy's code
- _html2mw : function(s) {
- // s = tinymce.trim(s);
-
- function rep(re, str) {
- s = s.replace(re, str);
- };
-
- // WikiWord urls
- rep(/<a.*?href=\"([A-Z].*?)\".*?>\1<\/a>/gim, "[[$1]]");
-
- // handle where url's text is the same as the url
- rep(/<a.*?href=\"(.*?)\".*?>\1<\/a>/gim, "$1");
-
-
- // handle external urls with body text
- rep(/<a.*?href=\"(.+?)\".*?>(.+?)<\/a>/gim,"[$1 $2]");
-
- // <em> to ''
- rep(/<em>(.*?)<\/em>/gim, "''$1''");
-
- // <strong> to '''
- rep(/<strong>(.*?)<\/strong>/gim, "'''$1'''");
-
- // headers
- rep(/<h1>(.*?)<\/h1>/gim, "\n=$1=");
- rep(/<h2>(.*?)<\/h2>/gim, "\n==$1==");
- rep(/<h3>(.*?)<\/h3>/gim, "\n===$1===");
- rep(/<h4>(.*?)<\/h4>/gim, "\n====$1====");
- rep(/<h5>(.*?)<\/h5>/gim, "\n=====$1=====");
- rep(/<h5>(.*?)<\/h6>/gim, "\n======$1======");
-
- // <p>
- rep(/<p>([\s\S]*?)<\/p>/gim, '\n\n$1');
-
- // <br>
- rep(/<br[^>]*>/gim, '\n\n');
-
- // <nbsp>
- //rep(/ /gi, ' ');
-
- // ul,ol lists
- // XXXXXXXXXXXXXXXXXXXXXX
-
-
- // images
- // XXXXXXXXXXXXXXXXXXXXXX
-
- // tables
- // XXXXXXXXXXXXXXXXXXXXXX
-
- return s;
- },
-
- // MediaWiki -> HTML, delegate to remy's code
- _mw2html : function(s) {
- //s = tinymce.trim(s);
- return s.wiki2html();
- }
- });
-
- // Register plugin
- tinymce.PluginManager.add('mediawiki', tinymce.plugins.MediaWikiPlugin);
+/** + * $Id$ + * + * @author Bret McMillan <bretm@redhat.com> + * @copyright Copyright © 2004-2008, Red Hat, Inc., All rights reserved. + * + * Adapted from: + * - the "example" and "bbcode" plugins provided by Moxicode + * - Remy Sharp's wiki2html code: http://remysharp.com/2008/04/01/wiki-to-html-using-javascript/ + * + * See also: http://en.wikipedia.org/wiki/Wikipedia:Cheatsheet + */ + +(function() { + tinymce.create('tinymce.plugins.MediaWikiPlugin', { + /** + * Initializes the plugin, this will be executed after the plugin has been created. + * This call is done before the editor instance has finished it's initialization so use the onInit event + * of the editor instance to intercept that event. + * + * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. + * @param {string} url Absolute URL to where the plugin is located. + */ + init : function(ed, url) { + var t = this; + // load wiki2html syncronous calls... + // might want to explore async later + tinymce.ScriptLoader.load(tinymce.PluginManager.urls.mediawiki + '/wiki2html.js'); + + ed.onBeforeSetContent.add(function(ed, o) { + o.content = t['_mw2html'](o.content); + }); + + ed.onPostProcess.add(function(ed, o) { + if (o.set) + o.content = t['_mw2html'](o.content); + + if (o.get) + o.content = t['_html2mw'](o.content); + + }); + }, + + /** + * Returns information about the plugin as a name/value array. + * The current keys are longname, author, authorurl, infourl and version. + * + * @return {Object} Name/value array containing information about the plugin. + */ + getInfo : function() { + return { + longname : 'MediaWiki plugin', + author : 'Bret McMillan <bretm@redhat.com>', + authorurl : 'http://www.redhat.com/', + infourl : 'http://www.redhat.com/', + version : "0.1" + }; + }, + + // Private methods + + // HTML -> MediaWiki, it'd be nice to get this upstream into remy's code + _html2mw : function(s) { + // s = tinymce.trim(s); + + function rep(re, str) { + s = s.replace(re, str); + }; + + // WikiWord urls + rep(/<a.*?href=\"([A-Z].*?)\".*?>\1<\/a>/gim, "[[$1]]"); + + // handle where url's text is the same as the url + rep(/<a.*?href=\"(.*?)\".*?>\1<\/a>/gim, "$1"); + + + // handle external urls with body text + rep(/<a.*?href=\"(.+?)\".*?>(.+?)<\/a>/gim,"[$1 $2]"); + + // <em> to '' + rep(/<em>(.*?)<\/em>/gim, "''$1''"); + + // <strong> to ''' + rep(/<strong>(.*?)<\/strong>/gim, "'''$1'''"); + + // headers + rep(/<h1>(.*?)<\/h1>/gim, "\n=$1="); + rep(/<h2>(.*?)<\/h2>/gim, "\n==$1=="); + rep(/<h3>(.*?)<\/h3>/gim, "\n===$1==="); + rep(/<h4>(.*?)<\/h4>/gim, "\n====$1===="); + rep(/<h5>(.*?)<\/h5>/gim, "\n=====$1====="); + rep(/<h5>(.*?)<\/h6>/gim, "\n======$1======"); + + // <p> + rep(/<p>([\s\S]*?)<\/p>/gim, '\n\n$1'); + + // <br> + rep(/<br[^>]*>/gim, '\n\n'); + + // <nbsp> + //rep(/ /gi, ' '); + + // ul,ol lists + // XXXXXXXXXXXXXXXXXXXXXX + + + // images + // XXXXXXXXXXXXXXXXXXXXXX + + // tables + // XXXXXXXXXXXXXXXXXXXXXX + + return s; + }, + + // MediaWiki -> HTML, delegate to remy's code + _mw2html : function(s) { + //s = tinymce.trim(s); + return s.wiki2html(); + } + }); + + // Register plugin + tinymce.PluginManager.add('mediawiki', tinymce.plugins.MediaWikiPlugin); })();
\ No newline at end of file |