Skip to content

Commit

Permalink
Item14323: more work simplifying and generalising
Browse files Browse the repository at this point in the history
  • Loading branch information
cdot committed Mar 2, 2017
1 parent 832a986 commit 4d0def2
Show file tree
Hide file tree
Showing 6 changed files with 453 additions and 998 deletions.
198 changes: 57 additions & 141 deletions TinyMCEPlugin/data/System/TinyMCEPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1487762226" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1488486156" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
---+!! !TinyMCEPlugin
<!--
Expand Down Expand Up @@ -52,94 +52,42 @@ Below is the default configuration. If it is to be modified, it should be copied
%TWISTY{showlink="Show default parameters..."}%
<verbatim class="js">
%STARTSECTION{"TINYMCEPLUGIN_INIT"}%
"mode" : "textareas",
"editor_selector" : "foswikiWysiwygEdit",
"save_on_tinymce_forms" : true,
"table_default_cellpadding" : 0,
"table_default_cellspacing" : 1,
"table_default_border" : 1,
"theme" : "modern",
"convert_urls" : true,
"relative_urls" : false,
"remove_script_host" : false,
"dialog_type" : "modal",
"extended_valid_elements" : "li[type],a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|data*]",
"setupcontent_callback" : "FoswikiTiny.setUpContent",
"save_callback" : "FoswikiTiny.saveCallback",%IF{
"$TINYMCEPLUGIN_DEBUG"
then="
\"debug\" : true,"
}%
"plugins" : "%IF{"defined 'TINYMCEPLUGIN_MCEPLUGINS'"
then="%TINYMCEPLUGIN_MCEPLUGINS%"
else="%STARTSECTION{"MCEPLUGINS"}%contextmenu table searchreplace save autosave paste fullscreen lists link anchor charmap hr code legacyoutput image textcolor colorpicker %ENDSECTION{"MCEPLUGINS"}%"
}%%IF{
"defined 'TINYMCEPLUGIN_ADDITIONAL_MCEPLUGINS'"
then=" %TINYMCEPLUGIN_ADDITIONAL_MCEPLUGINS%"
}%",
"external_plugins" : {
"foswikibuttons": "%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin/plugins/foswikibuttons/editor_plugin.uncompressed.js"
},
"foswiki_secret_id" : "%WYSIWYG_SECRET_ID%",
mode : "textareas",
editor_selector : "foswikiWysiwygEdit",
table_default_cellpadding : 0,
table_default_cellspacing : 1,
table_default_border : 1,
theme : "modern",
skin : "lightgray",
debug : true,
plugins : "contextmenu table searchreplace save autosave paste fullscreen lists link anchor charmap hr code legacyoutput image textcolor colorpicker wordcount",
external_plugins : {
foswikibuttons: "%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin/plugins/foswikibuttons/editor_plugin.uncompressed.js"
},
foswiki_secret_id : "%WYSIWYG_SECRET_ID%",
style_formats: [
{ title: 'Normal', remove: "all" },
{ title: "Heading 1", block: "h1" },
{ title: "Heading 2", block: "h2" },
{ title: "Heading 3", block: "h3" },
{ title: "Heading 4", block: "h4" },
{ title: "Heading 5", block: "h5" },
{ title: "Heading 6", block: "h6" },
{ title: "VERBATIM", block : "pre", "remove" : "all", "classes" : "TMLverbatim" },
{ title: "LITERAL", block : "div", "remove" : "all", "classes" : "WYSIWYG_LITERAL" },
{ title: "Protect on save", block : "div", "remove" : "all", "classes" : "WYSIWYG_PROTECTED" },
{ title: "Protect forever", block : "div", "remove" : "all", "classes" : "WYSIWYG_STICKY" }
],
"foswikibuttons_cursoridletime" : 250,
"paste_create_paragraphs" : true,
"paste_create_linebreaks" : false,
"paste_convert_middot_lists" : true,
"paste_convert_headers_to_strong" : false,
"paste_remove_spans" : true,
"paste_remove_styles" : true,
"paste_strip_class_attributes" : "all",
"menubar" : false,
"toolbar" : "%IF{
"defined 'TINYMCEPLUGIN_BUTTONS1'"
then="%TINYMCEPLUGIN_BUTTONS1%"
else="%STARTSECTION{"BUTTONS1"}%styleselect | bold italic tt forecolor | removeformat | bullist numlist %IF{"context SUPPORTS_PARA_INDENT" then="fwexdent fwindent" else="outdent indent"}% blockquote | link unlink anchor | undo redo | searchreplace table upload insertlink image charmap hr restoredraft fullscreen code hide%ENDSECTION{"BUTTONS1"}%"
}%%IF{
"defined 'TINYMCEPLUGIN_ADDITIONAL_BUTTONS1'"
then=" %TINYMCEPLUGIN_ADDITIONAL_BUTTONS1%"
}%",
"autosave_interval" : "%IF{
"defined 'TINYMCEPLUGIN_AUTOSAVE_INTERVAL'"
then="%TINYMCEPLUGIN_AUTOSAVE_INTERVAL%"
else="%STARTSECTION{"AUTOSAVE_INTERVAL"}%180s%ENDSECTION{"AUTOSAVE_INTERVAL"}%"
}%",
"autosave_retention" : "%IF{
"defined 'TINYMCEPLUGIN_AUTOSAVE_RETENTION'"
then="%TINYMCEPLUGIN_AUTOSAVE_RETENTION%"
else="%STARTSECTION{"AUTOSAVE_RETENTION"}%4320m%ENDSECTION{"AUTOSAVE_RETENTION"}%"
}%",
"entity_encoding" : "%IF{
"defined 'TINYMCEPLUGIN_ENTITY_ENCODING'"
then="%TINYMCEPLUGIN_ENTITY_ENCODING%"
else="%STARTSECTION{"ENTITY_ENCODING"}%numeric%ENDSECTION{"ENTITY_ENCODING"}%"
}%",
"skin" : "%IF{
"defined 'TINYMCEPLUGIN_MCESKIN'"
then="%TINYMCEPLUGIN_MCESKIN%"
else="%STARTSECTION{"MCESKIN"}%lightgray%ENDSECTION{"MCESKIN"}%"
}%",
%IF{
"defined 'TINYMCEPLUGIN_MCESKIN_VARIANT' AND $'TINYMCEPLUGIN_MCESKIN_VARIANT'"
then="\"skin_variant\" : \"%TINYMCEPLUGIN_MCESKIN_VARIANT%\",$n"
else="%IF{
"NOT defined 'TINYMCEPLUGIN_MCESKIN' OR $'TINYMCEPLUGIN_MCESKIN'='lightgray'"
then="\\"skin_variant\\" : \\"%STARTSECTION{"MCESKIN_VARIANT"}%silver%ENDSECTION{"MCESKIN_VARIANT"}%\\",$dollarn"
}%"
}%"keep_styles" : false,
"content_css" : "%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin/wysiwyg.css,%PUBURLPATH%/%SYSTEMWEB%/SkinTemplates/base.css,%FOSWIKI_STYLE_URL%,%FOSWIKI_COLORS_URL%"
{ title: 'Normal', block: "p" },
{ title: "Heading 1", block: "h1" },
{ title: "Heading 2", block: "h2" },
{ title: "Heading 3", block: "h3" },
{ title: "Heading 4", block: "h4" },
{ title: "Heading 5", block: "h5" },
{ title: "Heading 6", block: "h6" },
{ title: "VERBATIM", block : "pre", classes : "TMLverbatim" },
{ title: "LITERAL", block : "div", classes : "WYSIWYG_LITERAL" },
{ title: "Protect on save", block : "div", classes : "WYSIWYG_PROTECTED" },
{ title: "Protect forever", block : "div", classes : "WYSIWYG_STICKY" }
],
style_formats_autohide: true,
removeformat: [
{ selector: 'div,p,pre', remove: 'all' }
],
contextmenu: "link image inserttable | cell row column deletetable | example",
menubar : false,
toolbar : "styleselect | bold italic fwtt forecolor | removeformat | bullist numlist %IF{"context SUPPORTS_PARA_INDENT" then="fwexdent fwindent" else="outdent indent"}% blockquote | link unlink anchor | undo redo | searchreplace table fwupload fwinsertlink image charmap hr restoredraft fullscreen code fwhide",
autosave_interval : "180s",
autosave_retention : "4320m",
content_css: "%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin/wysiwyg.css,%PUBURLPATH%/%SYSTEMWEB%/SkinTemplates/base.css,%FOSWIKI_STYLE_URL%,%FOSWIKI_COLORS_URL%"
%ENDSECTION{"TINYMCEPLUGIN_INIT"}%
</verbatim>
%ENDTWISTY%
Expand All @@ -153,22 +101,11 @@ Example:
| *Variable* | *Default* | *Description* |
| =TINYMCEPLUGIN_INIT= | - | A string holding the !TinyMCE initialisation object. If set, =TINYMCEPLUGIN_INIT_TOPIC= is ignored |
| =TINYMCEPLUGIN_INIT_TOPIC= | [[%SYSTEMWEB%.TinyMCEPlugin]] | The fully qualified Web.Topic containing a [[VarSTARTSECTION][section]] named =INIT= which holds the !TinyMCE initialisation parameters |
| =TINYMCEPLUGIN_MCEPLUGINS= | %INCLUDE{"%TOPIC%" section="MCEPLUGINS"}% | Comma separated list of !TinyMCE plugins to initialise |
| =TINYMCEPLUGIN_ADDITIONAL_MCEPLUGINS= || Comma separated list of additional !TinyMCE plugins to initialise. |
| =TINYMCEPLUGIN_BUTTONS1= | %INCLUDE{"%TOPIC%" section="BUTTONS1"}% | Comma separated list of toolbar buttons (in order) for the first, second and third rows (of buttons) |
| =TINYMCEPLUGIN_BUTTONS2= | %INCLUDE{"%TOPIC%" section="BUTTONS2"}% |^|
| =TINYMCEPLUGIN_BUTTONS3= | |^|
| =TINYMCEPLUGIN_ADDITIONAL_BUTTONS1,= %BR% =TINYMCEPLUGIN_ADDITIONAL_BUTTONS2,= %BR% =TINYMCEPLUGIN_ADDITIONAL_BUTTONS3= || Comma separated list of toolbar buttons (in order) to be appended to the end of a button row |
| =TINYMCEPLUGIN_AUTOSAVE_RETENTION= | %INCLUDE{"%TOPIC%" section="AUTOSAVE_RETENTION"}% | Autosave drafts stored in the web browser are expired after this length of time (<span style="font-weight: bold; text-decoration: underline">m</span>inutes or <span style="font-weight: bold; text-decoration: underline">s</span>econds). See =autosave= plugin notes |
| =TINYMCEPLUGIN_AUTOSAVE_INTERVAL= | %INCLUDE{"%TOPIC%" section="AUTOSAVE_INTERVAL"}% | Frequency (in <span style="font-weight: bold; text-decoration: underline">m</span>inutes or <span style="font-weight: bold; text-decoration: underline">s</span>econds) that the autosave plugin updates the draft stored in the web browser |
| =TINYMCEPLUGIN_INIT_browser= | See [[%TOPIC%#Browser_Specific_Settings][Browser Specific Settings]] below | Add extra parameters to =TINYMCEPLUGIN_INIT= string for a specific =_browser= |
| =TINYMCEPLUGIN_DISABLE= | 0 | If set to 1, disables TinyMCEPlugin. _Please use_ =NOWYSIWYG= _instead_ |
| =NOWYSIWYG= | 0 | If this global setting is set to 1, TinyMCEPlugin (and all other WYSIWYG editors) will be disabled. |
| =TINYMCEPLUGIN_BAD_BROWSERS= | =(?i-xsm:Konqueror)= | A regular expression that matches the user-agent string of any browser for which !TinyMCE should not be loaded. |
| =TINYMCEPLUGIN_DEBUG= | 0 | If set to 1, the uncompressed version of !TinyMCE Javascript and CSS sources will be loaded by the browser. Useful for debugging. |
| =TINYMCEPLUGIN_ENTITY_ENCODING= | %INCLUDE{"%TOPIC%" section="ENTITY_ENCODING"}% | Controls how entities/characters get processed by !TinyMCE. Allowed values: =named, numeric, raw= |
| =TINYMCEPLUGIN_MCESKIN= | %INCLUDE{"%TOPIC%" section="MCESKIN"}% | The !TinyMCE skin to use. Possible values: =lightgray= |
| =TINYMCEPLUGIN_MCESKIN_VARIANT= | %INCLUDE{"%TOPIC%" section="MCESKIN_VARIANT"}% | A !TinyMCE skin may have _variants_. |

---+++ Browser Specific Settings
Additional options may be set for specific browsers. You can define extra options for MSIE, OPERA, GECKO, UNKNOWN and SAFARI. For example,
Expand Down Expand Up @@ -204,31 +141,10 @@ These plugins are enabled by default in the standard distribution of Foswiki.
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/table][table]] | tablecontrols, [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/table#Table_controls.2Fbuttons][others]] | Refer to !TinyMCE documentation | |

---+++ Additional Plugins
To enable extra plugins, set the =TINYMCEPLUGIN_ADDITIONAL_MCEPLUGINS= variable in your [[%LOCALSITEPREFS%]].
If the plugin also offers a toolbar button, you will need to add it into the appropriate place in the =TINYMCEPLUGIN_ADDITIONAL_BUTTONS*= variables.
See the Tiny MCE documentation for a complete list of available plugins. To enable extra plugins, set the =TINYMCEPLUGIN_ADDITIONAL_MCEPLUGINS= variable in your [[%LOCALSITEPREFS%]].

For example, to make use of the =emotions= and =wordcount= plugins add the following to [[%LOCALSITEPREFS%]]:

<pre class="tml">
---++ TinyMCE customisations
&nbsp;&nbsp;&nbsp;* Set TINYMCEPLUGIN_ADDITIONAL_MCEPLUGINS = emotions, wordcount
&nbsp;&nbsp;&nbsp;* Set TINYMCEPLUGIN_ADDITIONAL_BUTTONS2 = emotions
</pre>

Some notable plugins:
| *Plugin Name* | *Toolbar buttons* | *Description* | *Notes* |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize][autoresize]] | - | Automatically resizes the editor to the content inside it | |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/emotions][emotions]] | emotions | Insert smiley images into the !TinyMCE editable area | |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/iespell][iespell]] | iespell | Provides spell check for Internet Explorers | |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime][insertdatetime]] | insertdate, inserttime | Provides buttons to insert customised date and time strings | |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media][media]] | media | Handles embedded media such as !QuickTime, !Flash, !ShockWave, !RealPlayer and Windows Media Player | Requires customisation of edit templates |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker][spellchecker]] | spellchecker | Adds spellchecker functionality to !TinyMCE by providing a new button that performs a AJAX call to a backend PHP page that uses PSpell/ASpell or Google spellchecker | |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style][style]] | styleprops | Adds CSS style editing support to !TinyMCE, this will enable you to edit almost any CSS style property in a visual way. | Generally, HTML/CSS markup in topics is *not* desirable |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/visualchars][visualchars]] | visualchars | Adds the possibility to see invisible characters like =&amp;nbsp;= | |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/wordcount][wordcount]] | - | Display the number of words down in the right corner of the editor. | |
| [[http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras][xhtmlxtras]] | cite, ins, del, abbr, acronym | Adds support for some XHTML elements, including cite, ins, del, abbr, and acronym. | Generally, XHTML markup in topics is *not* desirable. Foswiki plugins exist to provide similar functions with more friendly TML markup |


---++ Frequently Asked Questions

The topic [[TinyMCEFrequentlyAskedQuestions]] contains more help with things like: "How do I configure the buttons in my skin?", "How do I disable the WYSIWYG?" etc.
Expand Down Expand Up @@ -382,23 +298,23 @@ Many thanks to the following sponsors for supporting this work:
%META:FIELD{name="License" title="License" value="[[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]]"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions.%25$ROOTMODULE%25"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Support.%25$ROOTMODULE%25"}%
%META:FILEATTACHMENT{name="wysiwyg.css.gz" attr="h" comment="" date="1487762226" size="390" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki_tiny.uncompressed.js" attr="h" comment="" date="1487762226" size="18556" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_hidden_verbatim.gif" attr="h" comment="" date="1487762226" size="1654" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermarks.psd" attr="h" comment="" date="1487762226" size="427691" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_literal.gif" attr="h" comment="" date="1487762226" size="1029" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_protect_on_save.gif" attr="h" comment="" date="1487762226" size="1492" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki.uncompressed.js" attr="h" comment="" date="1487762226" size="4233" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki_tiny.js.gz" attr="h" comment="" date="1487762226" size="2625" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="wysiwyg_src.css" attr="h" comment="" date="1487762226" size="1007" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_verbatim.gif" attr="h" comment="" date="1487762226" size="1181" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="wysiwyg.css" attr="h" comment="" date="1487762226" size="827" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="screenshot.png" attr="h" comment="" date="1487762226" size="30118" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_hidden.gif" attr="h" comment="" date="1487762226" size="950" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki.js" attr="h" comment="" date="1487762226" size="1847" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki.js.gz" attr="h" comment="" date="1487762226" size="869" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_protect_forever.gif" attr="h" comment="" date="1487762226" size="1494" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="tinymce.gif" attr="h" comment="screenshot" date="1487762226" size="35155" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" date="1487762226" size="1343" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki_tiny.js" attr="h" comment="" date="1487762226" size="8435" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="Makefile" attr="h" comment="" date="1487762226" size="147" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="wysiwyg.css.gz" attr="h" comment="" date="1488486156" size="390" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki_tiny.uncompressed.js" attr="h" comment="" date="1488486156" size="18556" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_hidden_verbatim.gif" attr="h" comment="" date="1488486156" size="1654" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermarks.psd" attr="h" comment="" date="1488486156" size="427691" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_literal.gif" attr="h" comment="" date="1488486156" size="1029" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_protect_on_save.gif" attr="h" comment="" date="1488486156" size="1492" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki.uncompressed.js" attr="h" comment="" date="1488486156" size="4233" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki_tiny.js.gz" attr="h" comment="" date="1488486156" size="2625" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="wysiwyg_src.css" attr="h" comment="" date="1488486156" size="1007" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_verbatim.gif" attr="h" comment="" date="1488486156" size="1181" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="wysiwyg.css" attr="h" comment="" date="1488486156" size="827" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="screenshot.png" attr="h" comment="" date="1488486156" size="30118" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_hidden.gif" attr="h" comment="" date="1488486156" size="950" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki.js" attr="h" comment="" date="1488486156" size="1847" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki.js.gz" attr="h" comment="" date="1488486156" size="869" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="watermark_protect_forever.gif" attr="h" comment="" date="1488486156" size="1494" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="tinymce.gif" attr="h" comment="screenshot" date="1488486156" size="35155" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" date="1488486156" size="1343" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="foswiki_tiny.js" attr="h" comment="" date="1488486156" size="8435" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="Makefile" attr="h" comment="" date="1488486156" size="147" user="ProjectContributor" version="1"}%
3 changes: 1 addition & 2 deletions TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin.pm
Expand Up @@ -133,8 +133,7 @@ sub installTinyMCE {

my $scripts = <<"SCRIPT";
<script type="text/javascript">
jQuery(function(\$) { FoswikiTiny.install(); });
FoswikiTiny.init = {$init};
jQuery(function(\$) { FoswikiTiny.init({$init}); });
</script>
SCRIPT

Expand Down

0 comments on commit 4d0def2

Please sign in to comment.