Power Edit Plugin
The Plugin formerly known as
TWiki:Plugins.PowerEditAddon
The PowerEditPlugin is a plug-in extension to TWiki that supports a Java 1.1 applet text editor. This applet works on most Java-enabled browsers (we haven't tested them
all!).
The applet provides the same editing capabilities as a standard browser text area, and adds some common editor functionality:
- Cut, Copy, Paste - the cut buffer is a static variable in the applet as there is no access to the system cut buffer from an applet. The cut buffer persists over different invocations of PowerEditPlugin, however, and you can always use the cut and paste functions in the browser menus to cut and paste outside the window.
- Undo - undoes up to 100 commands per edit session.
- Do again - repeats the last command.
- Find, Replace - optionally use Emacs style regular expressions as provided by the gnu.regexp library. Replace is currently not smart enough to use field replacement, however.
- Can be invoked in a separate frame.
- Programmable buttons.
- Convertor from HTML to TWiki markup
Usage information
Configuring the Buttons and Hot keys
Buttons and hotkeys are all created by reading a user-defined topic which is set by the %POWEREDIT_CONTROLS% variable (see
TWikiVariables, "Creating Custom Variables"). If the variable is not set, the topic TWiki.PowerEditControls is read instead. This allows administrators to set default buttons and keys for the whole installation, for each web, and users can to set up their own controls for the editor by defining this variable in their personal topics.
If set, the variable must be set to the
full name (including the web) of the topic that contains the control definitions; for example,
* Set POWEREDIT_CONTROLS = Main.AlanTuringControls
The control file contains a set of button panel and macro definitions. For example:
macros
"space" = " "
end
top
"Tele type" = "/cut/=/paste/="
"A Space"="/space/"
end
keys
"^X" = "/cut/"
end
In this example the first button in the top panel will be labelled "Tele type" and will perform the sequence /cut/=/paste/= - which will cut the currently selected text, enter an '=' sign, paste the text and enter another '=' sign. The second button will be labelled "A Space" and will execute the
space
macro, which in turn is defined to insert a ' ' character. The key "Ctrl+X" will be defined to perform the /cut/ command.
- The four button panels are named "top", "bottom", "left" and "right"
- There can be as many "macros" blocks as you like
- In button blocks, the name is used as the label on the button
- Control keys are denoted by a leading ^ character and must be in upper case e.g. ^A not ^a. Note that some browsers may not support key definitions.
- The command string is a mixture of basic editor commands (see below) and text to be inserted.
- The usual 'C' escapes are available in names and macro definitions i.e. prepending the character '\' will cause the next character to be interpreted literally. Note that '\/' will still be interpreted as '/' - to escape a '/' in the text, use a double-slash '//'.
- Single-line comments can be inserted into the file by starting a line with the '<' character. Thus HTML tags on a line of their own will be ignored.
- For some unexplained reason, probably due to synchronous access, it isn't possible to use the PowerEditPlugin on the PowerEditControls file.
The default control definitions for this installation may be viewed
here.
Commands
The following commands are basic to the editor and can be used in button definitions:
Name | Description |
/copy/ | Copy the currently selected text to the internal cut buffer |
/convert/ | Convert the currently selected text from raw HTML to TWiki ML |
/cut/ | Cut the currently selected text to the internal cut buffer |
/find/ | Invoke the find dialog |
/paste/ | Paste the internal cut buffer. Will erase the current selection. |
/undo/ | Undo the last edit |
/redo/ | Repeats the last command executed (does not repeat typing) |
/refind/ | Repeat the last find |
/replace/ | Invoke the replace dialog |
/rereplace/ | Repeat the last replacement |
Applet parameters
Parameter | Values | Description |
useframe | "yes" or "no" | Whether to use a separate window or not |
editboxwidth | Number of columns | If useframe=yes, then defines the number of columns width of the edit area. Ignored if useframe=no. |
editboxheight | Number of rows | If useframe=yes, then defines the number of rows height of the edit area. Ignored if useframe=no. |
text | text | The text to edit. |
controls | text | The control setup |
PowerEditPlugin Global Settings
Plugin settings are stored as preferences variables. To reference a plugin setting write
%<plugin>_<setting>%
, i.e.
%POWEREDITPLUGIN_SHORTDESCRIPTION%
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Extend TWiki with a Java 1.1 Applet based text editor.
- Note The %POWEREDIT_CONTROLS% variable is not a plugin variable but a global variable. As such you have to set it in TWikiPreferences if you want to override the default. See TWikiVariables "Creating Custom Variables".
Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
- Download the ZIP file from the Plugin web (see below). Contents:
File: | Description: |
PowerEditPlugin.xml | Ant build file |
data/TWiki/PowerEditPlugin.txt | Plugin topic |
data/TWiki/PowerEditControls.txt | Sample control configuration |
templates/edit.power.tmpl | Specialised skin. The difference to edit.tmpl are minimal, so deriving a local skin should be trivial. |
templates/applet.power.tmpl | Sub-template use for the applet tag. Done as a sub-skin to short-circuit default TWiki expansions. |
pub/TWiki/PowerEditPlugin/poweredit.jar | JAR file |
lib/TWiki/Plugins/PowerEditPlugin/source.zip | Source and test code |
lib/TWiki/Plugins/PowerEditPlugin.pm | Plugin script |
- Unzip
PowerEditPlugin.zip
in your twiki installation directory.
- A command to invoke the editor can by added to the normal topic view by putting the following line into your
bin/view
template, immediately after the line reading %EDITTOPIC%:
%TMPL:P{"sep"}% <a href="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%WEB%/%TOPIC%?skin=power">PowerEdit</a>
Plugin Info
Related Topics: TWikiPreferences,
TWikiPlugins
Known Problems
Clipboard Access
In order to access the clipboard on the client machine, an applet has to be signed. By default
PowerEdit? is shipped
unsigned. This is because (1) proper certificates cost money and (2) certificates you generate yourself have extremely limited lifetimes. So unless you sign the jar (after adding appropriate security API calls to the code!) you won't get clipboard access. This generally isn't much of a problem on UNIX and Linux because of the middle-button copy and paste capability.
Customisation and Further Development
All the sources and unit tests are provided with the distribution, together with an Ant build file (see
http://www.jakarta.org) should further customisation be required. The source.zip is shipped in the
lib/TWiki/Plugins/PowerEditPlugin
directory and when unzipped creates source, packages and test subdirectories. The
src
directory contains the applet sources, the
test
directory contains JUnit unit tests, and the
packages
directory contains the GNU 'regexp' package, which is used by search and replace, and a stripped-down version of the HTML parser from the Sourceforge HTMLParser project.
It is a condition of use that any useful customisations are fed back to the
TWiki:Plugins.PowerEditPluginDev page at
http://www.twiki.org !
Further development of this plugin is welcomed. The sources are all checked in to the TWiki CVS repository. If you make extensions to the plugin, please, please,
please maintain and extend the tests!
Copyright
This code is a development of the Systems on Chip group of Motorola Inc. and is protected by the following copyrights:
- Copyright (C) 2001-2003 Motorola. All Rights Reserved.
License
As required for the publication of all extensions to TWiki, this
software is published under the terms of the GNU General Public
License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details, published at
http://www.gnu.org/copyleft/gpl.html