2023년 1월 1일 오전 11:49
Snippets are pre-configured snippets of text which can be inserted into the editor by clicking the stamp () button on the toolbar and then on the required item.
Snippets can either replace, or be added before and/or after, the selected text in the editor.
Create a snippet
Whilst editing a tiddler
- Click stamp () on the toolbar
- Click "Add your own" at the bottom of the menu
- Type the text for the snippet in the editor
- Enter the caption for the snippet menu item in the
caption
field - Click the Confirm changes to this tiddler button
Manually
- Create a new tiddler by clicking the Create a new tiddler button in the sidebar
- Change the title for the tiddler (from e.g.
New Tiddler 1
). The tiddler title determines the menu item for the stamp if you do not set acaption
field (see below). - Add the tag
$:/tags/TextEditor/Snippet
in thetag name
tag box and clicking Add (or pressing the Enter key) by entering - Enter the snippet content (which you wish to appear in the editor when you click the stamp menu ) in the editor
- Create a field with the name
caption
and value set to the text for the snippet's stamp menu item:- Enter
caption
in the Add new fieldfield name
box - Enter the stamp menu item caption in the
field value
box
- Enter
Re-ordering snippets
Your new snippet will appear at the bottom of the stamp menu by default. To adjust the order of snippets:
- Navigate to a snippet tiddler
- Click the tag pill
- Drag items up and down the menu of snippets
Adding a prefix and/or suffix to a selection Introduced in v5.1.20
By default, the stamp button replaces text you have selected in the editor (let's say selectedText
)with your snippet (let's say $:/my/snippet
).
If instead of replacing selected text, you wish the stamp button to add wikitext before and/or after the selection:
- Create a snippet tiddler (tagged
caption
field set to desired stamp menu item text) using either of the two methods above , with - Create a new tiddler with either
/prefix
or/suffix
appended to the end of the snippet tiddler's title, according to whether you wish the stamp to insert the snippet content before (/prefix
) or after (/suffix
) the text selected in the editor.- Do not tag the tiddler ; the caption field is ignored
- Set the tiddler text to the text you wish to be inserted before or after your selection
Tiddler | Tiddler content | Tag | caption field |
---|---|---|---|
$:/snip/snippet2 | My second stamp menu item | ||
$:/snip/snippet2/prefix | TextIWantPrependedToSelection | ||
$:/snip/snippet2/suffix | TextIWantAppendedToSelection |