From 327ecf8f662ca9814b63dc4a8702cebe8f6fe1e2 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 6 Oct 2023 21:49:02 +0100 Subject: [PATCH] Don't refresh the body editor when switching the preview on and off (#7747) * Don't refresh the body editor when switching the preview on and off * Focus editor when switching the preview on or off --- core/ui/EditTemplate/body/default.tid | 20 ++++++++++++-------- core/ui/EditorToolbar/preview.tid | 6 ++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/core/ui/EditTemplate/body/default.tid b/core/ui/EditTemplate/body/default.tid index a2128efb0..68133d48e 100644 --- a/core/ui/EditTemplate/body/default.tid +++ b/core/ui/EditTemplate/body/default.tid @@ -1,5 +1,9 @@ title: $:/core/ui/EditTemplate/body/default +\function edit-preview-state() +[{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[] +[get[text]] :else[[no]] +\end + \define config-visibility-title() $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$ \end @@ -10,15 +14,16 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$ \whitespace trim <$let - edit-preview-state={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[] }}} importTitle=<> importState=<> > <$dropzone importTitle=<> autoOpenOnImport="no" contentTypesFilter={{$:/config/Editor/ImportContentTypesFilter}} class="tc-dropzone-editor" enable={{{ [{$:/config/DragAndDrop/Enable}match[no]] :else[subfilter{$:/config/Editor/EnableImportFilter}then[yes]else[no]] }}} filesOnly="yes" actions=<> > -<$reveal stateTitle=<> type="match" text="yes" tag="div"> -
+
+
<$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/> +<$list filter="[function[edit-preview-state]match[yes]]" variable="ignore"> +
<$transclude tiddler={{$:/state/editpreviewtype}} mode="inline"> @@ -29,13 +34,12 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
+ +
- -<$reveal stateTitle=<> type="nomatch" text="yes" tag="div"> +
-<$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/> - - + diff --git a/core/ui/EditorToolbar/preview.tid b/core/ui/EditorToolbar/preview.tid index 106b28d3c..3c8cef505 100644 --- a/core/ui/EditorToolbar/preview.tid +++ b/core/ui/EditorToolbar/preview.tid @@ -9,11 +9,17 @@ button-classes: tc-text-editor-toolbar-item-start-group shortcuts: ((preview)) \whitespace trim +<$let + edit-preview-state={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[] }}} +> <$reveal state=<> type="match" text="yes" tag="span"> {{$:/core/images/preview-open}} <$action-setfield $tiddler=<> $value="no"/> +<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/> <$reveal state=<> type="nomatch" text="yes" tag="span"> {{$:/core/images/preview-closed}} <$action-setfield $tiddler=<> $value="yes"/> +<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/> +