This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

WidgetMessage: tm-edit-text-operation

30th June 2018 at 7:34am
Messages

A tm-edit-text-operation invokes one of the available operations on a surrounding text editor. Therefore the message has to be dispatched within the editor in order for it to catch it. The following properties on the event object are required:

NameDescription
paramName of the operation to be executed, see below for a list of possible operations
paramObjectHashmap of additional parameters required by the operation top be executed

The tm-edit-text-operation message is usually generated by a ButtonWidget or an ActionWidget and is handled by the surrounding text editor.

Text Operations

At this point the following text operations have been implemented:

NameDescription
excise

Excises the currently selected text into a new tiddler and replaces it with a link, a macro or a transclude of the new tiddler. Parameters include:

NameDescription
titleTitle of the new tiddler the selected content is excised to
typeType of the replacement to be inserted: Can be one of transclude, link or macro
macroIn case type=macro, specifies the name of the macro to be inserted. The title of the new tiddler is provided as the first parameter to the macro. Defaults to the translink macro
tagnewIf 'yes', will tag the new tiddler with the title of the tiddler currently being edited
replace-all

Replaces all contents of the editor with the provided text.

NameDescription
textText to be inserted
replace-selection

Replaces the current selection with the provided text.

NameDescription
textText to be inserted
prefix-lines

Prefixes the currently selected line(s) with the provided character. If a line is already prefixed by the provided prefix, the prefix is removed instead.

NameDescription
characterPrefix character
countNumber of characters that make up the prefix

Example Setting character="!" and count="3" would insert the prefix "!!!", which will resolve to a subheading when parsed as WikiText.

wrap-lines

Surrounds the selected lines with the provided prefix and suffix.

NameDescription
prefixString to be prefixed to the selected lines
suffixSuffix to be inserted after the selected lines
wrap-selection

Surrounds the current selection with the provided prefix and suffix.

NameDescription
prefixString to be prefixed to the selection
suffixSuffix to be inserted after the selection
save-selection

Saves the text of the current selection into the provided tiddler and field.

NameDescription
tiddlerTiddler title to which the selection will be saved
fieldField name (defaults to "text")

Example

An example can be seen in $:/core/ui/EditorToolbar/bold:

<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="wrap-selection"
	prefix="''"
	suffix="''"
/>