Feature Proposal: Preferences For Raw Edit or Wysiwyg Edit
Motivation
Our users are used to the Raw editor. The
WYSIWYG is a good option and it would be useful if it remained an option. I don't want to disable
WYSIWYG in configure, but use a preference variable to dictate which editor is to be the default.
Description and Documentation
The Edit button is by default the
WYSIWYG editor. Clicking on a link to a new topic opens the same editor. The Raw edit option is seen on the bottom task bar. Can a preference setting reverse the roles, with Raw being the default and
WYSIWYG on the bottom?
Examples
When the RAW Editor is called
- If WYSIWYG is disabled in
config
- From the
Raw Edit button found bottom right
When the WYSIWYG Editor is called
-
Edit button. Top right of each page
-
Edit button. Bottom left of each page
- The
NEWLINK in the page content
- From pages like the Sandbox WebHome that has
Create buttons
- From the LeftBar
Create New Topic which calls WebCreateNewTopic
- In the URL - adding a non existent topic in the URL calls a form.
Do you wish to create the topic....
Impact
Use Case Scenarios
1 A user has a preference to use the
WYSIWYG editor.
- If the WYSIWYG editor is enabled then this type of user is happy
2. A user has a preference to use the RAW Editor
- This user can click on
Raw Edit at the bottom of the page. However the WYSIWYG editor is used for newlinks and other types of page creation.
Proposal
- Allow both WYSIWYG and
Raw Edit editing
- Create a preference variable that defines the behaviour of the Edit buttons.
- If
Raw Edit is the preference then the default roles are reversed. A WYSIWYG button replaces the Raw Edit button etc.
Implementation
Create a variable in the Main.Preferences called something like
RAWEDIT and this will be set to
0 or
1 . This can be changed in the web preferences or even the user preference.
Change the 2 definitions for
create_topic_link or
edit_topic_link that are found in
viewtopicactionbuttons.tmpl
%TMPL:DEF{"create_topic_link"}%<span><a href='%SCRIPTURL{"edit"}%/%WEB% /%TOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"contextTinyMCEPluginEnabled"
then=";nowysiwyg=%RAWEDIT%" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Create new topic'
accesskey='c'>&Create"}%</a></span>%TMPL:END%
%TMPL:DEF{"edit_topic_link"}%<span><a href='%SCRIPTURL{"edit"}%/%WEB% /%TOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"context TinyMCEPluginEnabled"
then=";nowysiwyg=%RAWEDIT%" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text '
accesskey='e'>&Edit"}%</a></span>%TMPL:END%
- The
Edit button.on the top right now behaves as required.
- The
Edit button.on the bottom left now behaves as required.
- In TWiki.Preferences set
NEWLINKFORMAT as follows
Set NEWLINKFORMAT = <a class="twikiNewLink" href="%SCRIPTURLPATH{"edit"}%/$web/$topic?
topicparent=%WEB%.%TOPIC%;nowysiwyg=%RAWEDIT%" rel="nofollow"
title="%MAKETEXT{"Create this topic"}%">$text</a>
The first 3 cases have been catered for. The cases where WebCreateNewTopic creates a new topic is more tricky.
For cases such as in the Sandbox users can create a new topic from a form. Such forms need to have a line included
<input type="hidden" name="nowysiwyg" value='%RAWEDIT%' />
For the link on the left menu
Create New Topic a similar line has to be added to
data/TWiki/WebCreateNewTopicTemplate.txt
The template used for non exiting topics entered at the URL is
data/TWiki/WebTopicViewTemplate.txt append
&nowysiwyg=%RAWEDIT% to the line
Do you wishto create...
--
Contributors: PeterJones - 2009-04-08
Discussion
Please do this! In my company there's a lot of people that would not have the skills to use the raw editor. But at least us at the development dept. would much prefer to set our own user preferences to use it by default. (hope this is the kind of comment to put here as it's kind of a "use-case"

)
--
CarlosEduardoKnippschild - 2009-05-18
Yes, Carlos, that is the place to provide feedback. Thank you!
This is a good proposal. There are even some sites who want to enable raw edit by default.
Today at the
HelsinkiReleaseMeeting2009x05x04 I suggested to use a
* Set EDITOR = wysiwyg setting by default in TWiki.TWikiPreferences. It can be overloaded at user level with a
* Set EDITOR = raw setting for those who prefer raw edit by default. The idea to use an EDITOR variable is to plan for the future when someone might want to offer other editors, such as
emacs. This is food for thought.
--
PeterThoeny - 2009-05-18
The implementation above works by changing a few templates and by using the parameter
nowysiwyg which is
0 or
1 . In this case the preference variable
RAWEDIT ( or
EDITOR as it could be) must be set to
0 or
1 . The question is if this preference variable is set to a word ( such as
raw or
emacs ) how can we get the editor to interpret it?
--
PeterJones - 2009-05-20
On name of setting, possibly use a more specific name to avoid namespace collision? Such as
TWIKIEDITOR or
TWEDITOR or
EDITMETHOD.
You can use
IfStatements in the skin and templates to produce the proper URL parameter, such as this (untested) conditional:
nowysiwyg=%IF{ "$ EDITMETHOD='wysiwyg'" then="0" then="1" }%
--
PeterThoeny - 2009-05-20
The solution proposed by
PeterThoeny, if possible, seems to solve current and future issues of this kind... I would be happy enough with it!
--
CarlosEduardoKnippschild - 2009-05-21
It is not obvious how to expand the IF THEN ELSE clause in the TWikiPreferences file for the NEWLINKFORMAT variable
* Set NEWLINKFORMAT = <a class="twikiNewLink" href="%SCRIPTURLPATH{"edit"}%/$web/$topic?topicparent=%WEB%.%TOPIC%;nowysiwyg=%IF{ "$ EDITMETHOD='wysiwyg'" then="0" then="1" }% " rel="nofollow" title="%MAKETEXT{"this topic does not yet exist; you can create it"}%">$text</a>
The clause on its own does work. It does not want to expand correctly inside another statement. Any ideas?
--
PeterJones - 2009-05-29
There were some typos in the above.
I have now implemented this by using the preference
Set EDITMETHOD = wysiwyg
If it is set to
wysiwyg then the behaviour is as it was before. i.e. the WYSIWYG editor is used always except when selecting the
Raw Edit button.
If it is not set to
wysiwyg then
raw edit is used everywhere. The previous
Raw Edit button now becomes the WYSIWYG button.
This reversing the roles of the editors but always allowing both of them to be available.
I can edit this topic but get kicked off when trying to add comments
--
PeterJones - 2009-06-04
This is a great idea. Please make sure that you really capture every place, as there are subtle situations where the editor is called (e.g., templates stored in TWiki directory). It took us a while to locate all the situations where we had to change the installation to make sure our users got the raw editor, which most prefer.
--
ThomasWeigert - 2009-06-04
As soon as you have this ready, can you post the diffs, so that interested people could merge the changes manually into their installation? Thanks.
--
ThomasWeigert - 2009-06-04
Here are the diffs between the original and the new
--
PeterJones - 2009-06-29
--
PeterJones - 2009-06-29
To recap:
- In the twiki/templates directory cp viewtopicactionbuttons.tmpl viewtopicactionbuttons.tmpl.orig
- Replace with the new viewtopicactionbuttons.tmpl
- In the data/TWiki directory cp WebCreateNewTopicTemplate.txt WebCreateNewTopicTemplate.txt.orig
- Replace with the new WebCreateNewTopicTemplate.txt
- In the TWiki/TWikiPreferences topic, set the NEWLINKFORMAT with the following line
* Set NEWLINKFORMAT = $text
- In the TWiki/TWikiPreferences topic, add a new variable
* Set EDITMETHOD = rawedit
The EDITMETHOD variable can be overwrote by web and user preferences
In forms to create new topics such as the one in the Sandbox add 2 line for the variable
EDITMETHOD
<form action='%SCRIPTURLPATH{"edit"}%/%WEB%/'>
%ICON{"newtopic"}% %MAKETEXT{"Create a new document by name:"}% %MAKETEXT{"(Use a topic name in TWiki.WikiNotation)"}% <br />
<input class="twikiInputField" type="text" name="topic" size="32" /> <input type="submit" class="twikiSubmit" value='%MAKETEXT{"Create by Name"}%' />
<input type="hidden" name="onlywikiname" value="on" />
<input type="hidden" name="onlynewtopic" value="on" />
<input type="hidden" name="nowysiwyg" value='%IF{ "$ EDITMETHOD='wysiwyg'" then="0" else="1" }%' />
</form>
<form action='%SCRIPTURLPATH{"edit"}%/%BASEWEB%/TestTopicAUTOINC0' name="createNewTestTopic">
%ICON{"newtopic"}% %MAKETEXT{"Create a new auto-numbered test topic:"}%
<input type="hidden" name="t" value="%SERVERTIME{$hou$min$sec}%" />
<input type="hidden" name="nowysiwyg" value='%IF{ "$ EDITMETHOD='wysiwyg'" then="0" else="1" }%' />
<input type="submit" class="twikiSubmit" value='%MAKETEXT{"Create <nop>TestTopic###"}%' />
</form>
--
PeterJones - 2009-08-04
Thanks
PeterJones for working on this-I have created
Item6295
to checkin this code/topic content.
Expect me to checkin tomorrow my time.
--
SopanShewale - 2009-08-06
This feature is implemented but not documented, e.g. it is not obvious for end users how to set the editor to one or the other method.
--
PeterThoeny - 2010-06-06
It looks like one of the requred changes did not make it into the 5.0.0 package. I had to change the following file to get the twiki to use the EDITMETHOD setting:
enshosca.central:highway[1837]% diff viewtopicactionbuttons.tmpl*
7c7
< %TMPL:DEF{"edit_topic_link"}%<span><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%;nowysiwyg=%IF{ "$ EDITMETHOD='wysiwyg'" then="0" else="1" }%' rel='nofollow' %MAKETEXT{"title='Edit this topic text' accesskey='e'>[_1] &Edit" args="<img src='%ICONURLPATH{uweb-o}%' width='16' height='16' border='0' alt='' />"}%</a></span>%TMPL:END%
---
> %TMPL:DEF{"edit_topic_link"}%<span><a href='%SCRIPTURL{"edit"}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%%IF{"context TinyMCEPluginEnabled" then="" else=";nowysiwyg=1"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text' accesskey='e'>[_1] &Edit" args="<img src='%ICONURLPATH{uweb-o}%' width='16' height='16' border='0' alt='' />"}%</a></span>%TMPL:END%
enshosca.central:highway[1838]% pwd
/ph/pkgs/twiki/twiki5/templates
--
JohnGage - 2010-06-14
Thank you reporting this issue. Tracked in
TWikibug:Item6491
--
PeterThoeny - 2010-06-14
This is now fixed in
SVN trunk and TWiki-5.0 branch.
--
PeterThoeny - 2010-11-05
What has to be done to enable this feature in 5.0.1?
--
SteveKelem - 2011-03-16
See
TWikibug:Item6491
and changes
TWikirev:19179
,
TWikirev:19764
. Also add the EDITMETHOD setting to the user template page as in
SVN:TWikiUserMappingContrib/data/TWiki/NewUserTemplate.txt
--
PeterThoeny - 2011-03-17
Thank you for implementing this! However, I would love to see the actual SET statement documented since I can't figure it out on my own.
--
EmmaDvora - 2012-11-13
Emma, see EDITMETHOD setting in your profile page
EmmaDvora. You can toggle the value for you in your profile page, or you can copy & paste the setting to a web's
WebPreferences or a topic for web-level- or topic-level scope affecting all users, respectively.
--
PeterThoeny - 2012-11-13
Thank you very, very much for the info and for responding so quickly. This will make my twiki tribe so happy!!
--
EmmaDvora - 2012-11-14
Naive question: Can I suppose that all this is available OOTB in TWiki-6.0?
--
Dirk Hoffmann - 2014-05-19
The status is "merged to core". See EDITMETHOD setting in your profile page.
--
Peter Thoeny - 2014-05-19