From 22286aa569ae1c829285c84c158bf018808cfe72 Mon Sep 17 00:00:00 2001 From: Leilei332 Date: Wed, 31 Jul 2024 20:38:25 +0800 Subject: [PATCH] Add image toolbar dropdown to markdown plugin (#8459) * Add image toolbar dropdown to markdown plugin * Escape special characters --- .../EditorToolbar/picture-dropdown.tid | 24 +++++++++++++++++++ .../markdown/EditorToolbar/picture.tid | 10 ++++++++ 2 files changed, 34 insertions(+) create mode 100644 plugins/tiddlywiki/markdown/EditorToolbar/picture-dropdown.tid create mode 100644 plugins/tiddlywiki/markdown/EditorToolbar/picture.tid diff --git a/plugins/tiddlywiki/markdown/EditorToolbar/picture-dropdown.tid b/plugins/tiddlywiki/markdown/EditorToolbar/picture-dropdown.tid new file mode 100644 index 000000000..966c991fd --- /dev/null +++ b/plugins/tiddlywiki/markdown/EditorToolbar/picture-dropdown.tid @@ -0,0 +1,24 @@ +title: $:/plugins/tiddlywiki/markdown/EditorToolbar/picture-dropdown + +\define replacement-text() +![](<#$(escaped-text)$>) +\end + +\define escapetitle() [()<>\\] + +''{{$:/language/Buttons/Picture/Hint}}'' + +<$macrocall $name="image-picker" actions=""" + +<$let escaped-text={{{ [search-replace:g:regexp,[\$&]] }}}> +<$action-sendmessage + $message="tm-edit-text-operation" + $param="replace-selection" + text=<> +/> + +<$action-deletetiddler + $tiddler=<> +/> + +"""/> diff --git a/plugins/tiddlywiki/markdown/EditorToolbar/picture.tid b/plugins/tiddlywiki/markdown/EditorToolbar/picture.tid new file mode 100644 index 000000000..27e108c81 --- /dev/null +++ b/plugins/tiddlywiki/markdown/EditorToolbar/picture.tid @@ -0,0 +1,10 @@ +title: $:/plugins/tiddlywiki/markdown/EditorToolbar/picture +list-after: $:/core/ui/EditorToolbar/picture +tags: $:/tags/EditorToolbar +icon: $:/core/images/picture +caption: {{$:/language/Buttons/Picture/Caption}} (Markdown) +description: {{$:/language/Buttons/Picture/Hint}} +condition: [type[text/x-markdown]] [type[text/markdown]] +shortcuts: ((picture)) +dropdown: $:/plugins/tiddlywiki/markdown/EditorToolbar/picture-dropdown +