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

WidgetMessage: tm-edit-text-operation

9th September 2024 at 8:35am

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
{any other params}Any other parameters are made available as variables within the context of the widget message.

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
trimSelectionNew in v5.3.6 Trim leading and trailing white-space from the selection and move it to the surrounding text. Possible values are: yes, no (default), start and end
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")
make-link

Creates a wiki text link to the tiddler specified in text. If there is a selection, it is used as the text of the link.

NameDescription
textTiddler title to which the link will be created
insert-text

Inserts the text specified in text at the caret position. If there is a selection, it is replaced.

NameDescription
textText to be inserted
focus-editorIntroduced in v5.2.0 Simply focuses the Text Editor

Example

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

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