1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-29 12:59:56 +00:00

Fix per-tiddler previews (#7900)

* Initial commit

* Put SVG back into a span

Needed in case this is targeted in CSS; DOM structure should not be changed.

* Fix the fix

Do it once, do it right.
This commit is contained in:
yaisog 2023-12-21 11:36:08 +01:00 committed by GitHub
parent e2d4388c48
commit 95e270a8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 20 deletions

View File

@ -1,9 +1,5 @@
title: $:/core/ui/EditTemplate/body/default title: $:/core/ui/EditTemplate/body/default
\function edit-preview-state()
[{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] +[get[text]] :else[[no]]
\end
\define config-visibility-title() \define config-visibility-title()
$:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
\end \end
@ -14,15 +10,16 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
\whitespace trim \whitespace trim
<$let <$let
editPreviewStateTiddler={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] }}}
importTitle=<<qualify $:/ImportImage>> importTitle=<<qualify $:/ImportImage>>
importState=<<qualify $:/state/ImportImage>> > importState=<<qualify $:/state/ImportImage>> >
<$dropzone importTitle=<<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=<<importFileActions>> > <$dropzone importTitle=<<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=<<importFileActions>> >
<div> <div>
<div class={{{ [function[edit-preview-state]match[yes]then[tc-tiddler-preview]else[tc-tiddler-preview-hidden]] [[tc-tiddler-editor]] +[join[ ]] }}}> <div class={{{ [<editPreviewStateTiddler>get[text]match[yes]then[tc-tiddler-preview]else[tc-tiddler-preview-hidden]] [[tc-tiddler-editor]] +[join[ ]] }}}>
<$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/> <$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/>
<$list filter="[function[edit-preview-state]match[yes]]" variable="ignore"> <$list filter="[<editPreviewStateTiddler>get[text]match[yes]]" variable="ignore">
<div class="tc-tiddler-preview-preview" data-tiddler-title={{!!draft.title}} data-tags={{!!tags}}> <div class="tc-tiddler-preview-preview" data-tiddler-title={{!!draft.title}} data-tags={{!!tags}}>

View File

@ -9,17 +9,8 @@ button-classes: tc-text-editor-toolbar-item-start-group
shortcuts: ((preview)) shortcuts: ((preview))
\whitespace trim \whitespace trim
<$let <span>
edit-preview-state={{{ [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualify "$:/state/showeditpreview">] }}} <$transclude $tiddler={{{ [<editPreviewStateTiddler>get[text]match[yes]then[$:/core/images/preview-open]else[$:/core/images/preview-closed]] }}} />
> </span>
<$reveal state=<<edit-preview-state>> type="match" text="yes" tag="span"> <$action-setfield $tiddler=<<editPreviewStateTiddler>> $value={{{ [<editPreviewStateTiddler>get[text]toggle[yes],[no]] }}} />
{{$:/core/images/preview-open}}
<$action-setfield $tiddler=<<edit-preview-state>> $value="no"/>
<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/> <$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/>
</$reveal>
<$reveal state=<<edit-preview-state>> type="nomatch" text="yes" tag="span">
{{$:/core/images/preview-closed}}
<$action-setfield $tiddler=<<edit-preview-state>> $value="yes"/>
<$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/>
</$reveal>
</$let>