Skip to content

Commit cbf702a

Browse files
committed
feat: added SaveTiddlerAndContinue original version
1 parent 042a485 commit cbf702a

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: $:/config/ShortcutInfo/save-tiddler-and-continue
2+
3+
save and continue editing
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: $:/config/shortcuts/save-tiddler-and-continue
2+
3+
alt-S
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
title: $:/plugins/sq/save-tiddler-and-continue/editor-tool
2+
condition: [<targetTiddler>]
3+
tags: $:/tags/EditorTools
4+
5+
6+
7+
\function originalTiddler() [<targetTiddler>get[draft.of]trim[]]
8+
9+
\function fields.to.copy() [fields[]] -[[title]] -[[draft.title]] -[[draft.of]] -[[created]] -[[modified]] -[[bag]]
10+
11+
\procedure save-actions()
12+
<!-- replace the original tiddler with the draft tiddler -->
13+
<$genesis $type="$action-createtiddler" $$basetitle=<<originalTiddler>> $$overwrite="yes" $names="[<targetTiddler>fields.to.copy[]]" $values="[<targetTiddler>fields.to.copy[]] :map[<targetTiddler>get<currentTiddler>]">
14+
<!-- handle unsaved tag -->
15+
<%if [<newTagNameTiddler>get[text]!is[blank]] %>
16+
<$action-listops $tiddler=<<originalTiddler>> $tags=<<condition>>/>
17+
<%endif%>
18+
<!-- handle unsaved field -->
19+
<%if [<newFieldNameTiddler>get[text]!is[blank]] %>
20+
<$action-setfield $tiddler=<<originalTiddler>> $field=<<condition>> $value={{{ [<condition>] :map[subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
21+
<%endif%>
22+
<!-- focus editor -->
23+
<$action-sendmessage
24+
$message="tm-edit-text-operation"
25+
$param=""
26+
prefix="''"
27+
suffix="''"
28+
/>
29+
</$genesis>
30+
\end
31+
32+
33+
\procedure save-tiddler-button()
34+
<$button
35+
tooltip="save & continue"
36+
aria-label="save & continue"
37+
class=<<tv-config-toolbar-class>>
38+
actions=<<save-actions>>
39+
style.margin-left="2em"
40+
>
41+
<span data-tw-keyboard-shortcut="((save-tiddler-and-continue))"></span>
42+
<%if [<tv-config-toolbar-icons>match[yes]] %>
43+
<svg class="tc-image-button" width="22pt" height="22pt" viewBox="0 0 1100 1099"><path d="M396 376L765 7q7-7 17.5-7T800 7l139 139q7 8 7 18.5t-7 17.5L414 707q-7 8-17.5 8t-17.5-8L87 416q-7-8-7-18t7-18l139-139q8-7 18.5-7t17.5 7zM50 799h1000q21 0 35.5 14.5T1100 849v250H0V849q0-21 14.5-35.5T50 799zm850 100v50h100v-50H900z"/></svg>
44+
<%endif%>
45+
<%if [<tv-config-toolbar-text>match[yes]] %>
46+
<span class="tc-btn-text"><$text text={{$:/language/Buttons/Save/Caption}}/></span>
47+
<%endif%>
48+
</$button>
49+
\end
50+
51+
<<save-tiddler-button>>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"title": "$:/plugins/sq/save-tiddler-and-continue",
3+
"name": "Save tiddler and continue editing",
4+
"list": "readme",
5+
"version": "1.0.0"
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
title: $:/plugins/sq/save-tiddler-and-continue/readme
2+
3+
@@color:red;''Experimental plugin - no support available. Use at your own risk.''@@
4+
5+
Adds a button and a keyboard shortcut to the editor toolbar that can be used to save the tiddler and continue editing without losing your place.
6+
7+
''Keyboard shortcut:'' //save-tiddler-and-continue//
8+
9+
<$edit-shortcut tiddler="$:/config/shortcuts/save-tiddler-and-continue" placeholder={{$:/language/ControlPanel/KeyboardShortcuts/Add/Prompt}} style="width:auto;"/>
10+
<!--
11+
<$macrocall $name="displayshortcuts" $output="text/html" shortcuts={{$:/config/shortcuts/save-tiddler-and-continue}} prefix="<kbd>" separator="</kbd> <kbd>" suffix="</kbd>"/>
12+
-->
13+
14+
''Caveats:''
15+
16+
* The keyboard shortcut only works when the cursor is in the text area for editing the text field.
17+
* Renaming the tiddler requires a normal save for now.

0 commit comments

Comments
 (0)