Skip to content

Commit

Permalink
Item14323: fix switch back from raw mode, and get rid of Makefiles wh…
Browse files Browse the repository at this point in the history
…ich can't handle the tinymce model and make debugging a PITA
  • Loading branch information
cdot committed Mar 22, 2017
1 parent ef75b01 commit 326a4f7
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
3 changes: 1 addition & 2 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ sub renderCSS {

sub renderJS {
my ( $this, $text ) = @_;

$text =~ s/\.js$/.uncompressed.js/
if $this->{debug} && $text !~ /(\.uncompressed|_src)\./;
if $this->{debug} && $text !~ /(\.uncompressed|_src|\.dev)\./;
$text .= '?version=' . $this->{version};
$text =
"<script type='text/javascript' src='$this->{puburl}/$text'></script>\n";
Expand Down
2 changes: 1 addition & 1 deletion TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub/System/TinyMCEPlugin/watermark_protect_on_save.gif 0644
pub/System/TinyMCEPlugin/watermark_verbatim.gif 0644
#pub/System/TinyMCEPlugin/watermarks.psd 0644
pub/System/TinyMCEPlugin/wikiringlogo20x20.png 0644
pub/System/TinyMCEPlugin/wysiwyg_src.css 0644
pub/System/TinyMCEPlugin/wysiwyg.uncompressed.css 0644
pub/System/TinyMCEPlugin/wysiwyg.css 0644
pub/System/TinyMCEPlugin/wysiwyg.css.gz 0644
pub/System/TinyMCEQuickHelp/Format_Drop_Down.png 0644
Expand Down
31 changes: 17 additions & 14 deletions TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin/TinyMCE.pm
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
# JQuery plugin for Foswiki JQueryPlugin
# This plugin is responsible for loading the Javascript that interfaces
# with the TinyMCE editor.
#
# Javascript is Copyright (C) 2012 Sven Dowideit - SvenDowideit@fosiki.com
# Portions Copyright (C) 2017 Crawford Currie http://c-dot.co.uk
#

# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
Expand All @@ -19,6 +21,8 @@ use warnings;
use Foswiki::Plugins::JQueryPlugin::Plugin;
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );

use Assert;

=begin TML
---+ package Foswiki::Plugins::TinyMCEPlugin::TinyMCE
Expand All @@ -33,8 +37,6 @@ This is the perl stub for tinyMCE.
Constructor
<script type="text/javascript" src="$pluginURL/foswiki$USE_SRC.js?v=$encodedVersion"></script>
=cut

sub new {
Expand All @@ -49,13 +51,11 @@ sub new {
homepage => 'http://foswiki.org/Extensions/TinyMCEPlugin',
documentation => "$Foswiki::cfg{SystemWebName}.TinyMCEPlugin",
puburl => '%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin',
javascript => [
'foswiki_tiny.js',
'/tinymce/js/tinymce/tinymce.min.js'

#'/tinymce_dev/js/tinymce/tinymce.dev.js'
],
dependencies => ['foswiki']
javascript =>
[ 'foswiki_tiny.js', 'tinymce/js/tinymce/tinymce.min.js' ],
css => ['wysiwyg.css'],
dependencies => ['foswiki'],
debug => DEBUG
),
$class
);
Expand All @@ -66,9 +66,12 @@ sub new {
sub renderJS {
my ( $this, $text ) = @_;

$text .= '?version=' . $this->{version} if ( $this->{version} =~ '$Rev$' );
$text =
"<script type='text/javascript' src='$this->{puburl}/$text'></script>\n";
$text = $this->SUPER::renderJS($text);

# TinyMCE has different naming conventions
$text =~ s(/tinymce/js/tinymce/tinymce\.min\.uncompressed\.js)
(/tinymce_dev/js/tinymce/tinymce.dev.js);
return $text;
}
Expand Down
6 changes: 0 additions & 6 deletions TinyMCEPlugin/pub/System/TinyMCEPlugin/Makefile

This file was deleted.

6 changes: 0 additions & 6 deletions TinyMCEPlugin/pub/System/TinyMCEPlugin/plugins/Makefile

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
// Muddy-boots the initialized status of the editor to
// block the save event that would otherwise blow away
// the textarea content when a submit event is raised
// in a form that wraps the editor.
// for a form that wraps around the editor.
editor.initialized = false;
editor.hide();
},
Expand All @@ -175,14 +175,26 @@
// Get the textarea content
var text = editor.getElement().value;

var throbberPath = foswiki.getPreference('PUBURLPATH')
+ '/' + foswiki.getPreference('SYSTEMWEB')
+ '/' + 'DocumentGraphics/processing.gif';
// When switching back from a raw edit, a show side-effects
// and will re-load the content from the textarea, which contains
// the raw TML. So we hide the editable area until the transform
// is finished. Not pretty, but it works.
$(editor.getBody()).hide();
// This is supposed to start a throbber, but I've yet to see one.
editor.setProgressState(true);
// Now do the show. This will load the (hidden) editable area from
// the textarea.
editor.show();

transform(
editor, "tml2html", text, function(text, req, o) { // Success
// Set the HTML content in the editable area (doesn't affect
// the textarea, which still has the raw TML)
editor.setContent(text);
editor.show();
// Undo the hide above
$(editor.getBody()).show();
// Kill the progress state
editor.setProgressState(false);
// We can do this safely because the only way this code can
// be reached is through an execCommand, and that's only
// available when the editor is initialised. Reverse the
Expand All @@ -192,9 +204,12 @@
editor.isNotDirty = true;
},
function(type, req, o) {
// Kill the progress state
editor.setProgressState(false);
editor.hide();
// Handle a failure by firing an event back at the
// textarea we are sitting on
$(edit.getElement()).trigger(
$(editor.getElement()).trigger(
"fwTxError",
"There was a problem retrieving " + o.url
+ ": " + type + " " + req.status);
Expand Down

0 comments on commit 326a4f7

Please sign in to comment.