From 7d9b4e2e642d647f63b239ec1211f61951989f8d Mon Sep 17 00:00:00 2001 From: Bret McMillan Date: Mon, 17 Nov 2008 17:37:17 -0500 Subject: headers aren't eating the world now, many other tags are commented out until unit-test pages look decent --- extensions/TinyMCE_MW2.php | 41 +++++++++------------- .../tiny_mce/plugins/mediawiki/editor_plugin.js | 29 ++++++++------- .../tiny_mce/plugins/mediawiki/wiki2html.js | 6 ++-- 3 files changed, 33 insertions(+), 43 deletions(-) diff --git a/extensions/TinyMCE_MW2.php b/extensions/TinyMCE_MW2.php index 3866a80..dfa0375 100644 --- a/extensions/TinyMCE_MW2.php +++ b/extensions/TinyMCE_MW2.php @@ -32,25 +32,18 @@ $wgExtensionCredits['other'][] = array( "author" => "Bret McMillan ", "version" => "0.1", "url" => "http://www.redhat.com/", - "description" => "Easily implement Moxiecode's TinyMCE into MediaWiki using the plugin framework, extends Joseph Socoloski's original work" - ); + "description" => "Easily implement Moxiecode's TinyMCE into MediaWiki using the plugin framework (rework of Joseph Socoloski's original work)" +); # REGISTER HOOKS $wgHooks['ArticleAfterFetchContent'][] = 'wfCheckBeforeEdit'; $wgHooks['EditPage::showEditForm:initial'][] = 'wfTinymceAddScript'; -function wfTinymceAddScript ($q) { +function wfTinymceAddScript($q) { + global $wgOut, $wgScriptPath; - global $wgOut, $wgTitle, $wgScriptPath, $wgMyWikiURL; - global $wgTempText, $wgTinymceDir, $wgTinymceTheme, $wgExt_valid_elements, $wgUseTinymce; - - $wgTinymceDir = "tinymce"; - $ns_allowed = true; - $ns = $wgTitle->getNamespace(); - - if ($ns_allowed && $wgUseTinymce) { - # use the more modern example straight from moxiecode - $wgOut->addScript(""); - $wgOut->addScript( "" ); - - #Since editing add the button - $wgOut->addHTML("

Toggle Visual Editor

"); - } else { - $wgOut->addScript("" ); - $wgUseTinymce = true; - } - return true; + document_base_url : \"$wgMyWikiURL\"});" + ); + # Since editing add the button + $wgOut->addHTML("

Toggle Visual Editor

"); + return true; } # Check existing article for any tags we don't want TinyMCE parsing... 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 e69dc5f..566af50 100644 --- a/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/editor_plugin.js +++ b/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/editor_plugin.js @@ -68,7 +68,7 @@ m.replace(/
  • (.*?)<\/li>/gim, glyph + "$1"); // TODO: fixme, this needs to be recursive... - //m = t['convertlists'](m); + m = t['convertlists'](m); return m; }); @@ -111,29 +111,25 @@ rep(/

    (.*?)<\/h3>/gim, "===$1==="); rep(/

    (.*?)<\/h4>/gim, "====$1===="); rep(/

    (.*?)<\/h5>/gim, "=====$1====="); - rep(/
    (.*?)<\/h6>/gim, "======$1======"); + rep(/
    (.*?)<\/h6>/gim, "======$1======"); - //

    - rep(/

    ([\s\S]*?)<\/p>/gim, '\n$1'); + // block elements, spacing, etc... + //

    + //rep(/

    ([\s\S]*?)<\/p>/gim, '$1\n'); //

    - rep(/([\s\S]*?)<\/p>/gim, '\n$1'); - + //rep(/([\s\S]*?)<\/p>/gim, '\n$1'); // various indents... //

    - rep(/

    ([\s\S]*?)<\/p>/gim, '\n $1'); - rep(/

    ([\s\S]*?)<\/pre>/gim, '\n $1');
    -			rep(/
    ([\s\S]*?)<\/blockquote>/gim, '\n $1'); - - // - rep(/\ \;/gim, ' '); - + //rep(/

    ([\s\S]*?)<\/p>/gim, '\n $1'); + //rep(/

    ([\s\S]*?)<\/pre>/gim, '\n $1');
    +			//rep(/
    ([\s\S]*?)<\/blockquote>/gim, '\n $1'); //
    - rep(/]*?>/gim, '\n'); + //rep(/]*?>/gim, '\n'); // ul,ol lists - s = t['convertlists'](s); + // s = t['convertlists'](s); // tables // XXXXXXXXXXXXXXXXXXXXXX @@ -145,6 +141,9 @@ // probably due to a tinymce cleanup function repairing bad html // rep(/\s*?\s*?/gim, ""); + // + //rep(/\ \;/gim, ' '); + return s; }, diff --git a/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/wiki2html.js b/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/wiki2html.js index 2d3f442..312e8b4 100644 --- a/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/wiki2html.js +++ b/extensions/tinymce/jscripts/tiny_mce/plugins/mediawiki/wiki2html.js @@ -88,9 +88,9 @@ function wiki2html(s) { }) /* BLOCK ELEMENTS */ - .replace(/(?:^|\n+)([^# =\*<].+)(?:\n+|$)/gm, function (m, l) { + .replace(/(?:^\s*|\n+\s*)([^\s\+\|#=\*<].+)(?:\s*\n+|$)/gm, function (m, l) { if (l.match(/^\^+$/)) return l; - return "\n

    " + l + "

    \n"; + return "

    " + l + "

    \n"; }) .replace(/(?:^|\n)[ ]{2}(.*)+/g, function (m, l) { // blockquotes @@ -103,7 +103,7 @@ function wiki2html(s) { return '
    ' + m.replace(/(^|\n)[ ]+/g, "$1") + '
    '; }) - .replace(/(?:^|\n)([=]+)(.*)\1/g, function (m, l, t) { // headings + .replace(/^([=]+)(.*?)\1/mg, function (m, l, t) { // headings return '' + t + ''; }) -- cgit