diff --git a/core/ui/EditorToolbar/file-import.tid b/core/ui/EditorToolbar/file-import.tid index 20cff547d42..0fd5e08a512 100644 --- a/core/ui/EditorToolbar/file-import.tid +++ b/core/ui/EditorToolbar/file-import.tid @@ -1,20 +1,30 @@ title: $:/core/ui/EditorToolbar/file-import tags: $:/tags/EditorTools -condition: [!has[type]] [type[text/vnd.tiddlywiki]] +condition: [filter{$:/config/Editor/EnableImportFilter}] -\define lingo-base() $:/language/Import/ +\procedure lingo-base() $:/language/Import/ -\define closePopupActions() +\procedure closePopupActions() <$action-deletetiddler $filter="[title] [title]"/> -\end +\end closePopupActions -\define replacement-text-image() [img[$title$]] +\procedure tw5-ImageTemplate() [img[$(currentTiddler)$]] +\procedure tw5-FileTemplate() [[$(currentTiddler)$]] -\define replacement-text-file() [[$title$]] + +\function escape.title() [search-replace:g:regexp[\(|\)|<|>|\\],[\$&]] +\procedure markdown-ImageTemplate() ![](<#${ [escape.title[]] }$>) +\procedure markdown-FileTemplate() [](<#${ [escape.title[]] }$>) -\define postImportActions() +\function is.markdown.tiddler() [all[]type[text/x-markdown]] [all[]type[text/markdown]] +\function is.image() [get[type]prefix[image]] +\function get.markdown.link() [is.image[]thenelse] +\function get.tw5.link() [is.image[]thenelse] +\function get.link.template() [is.markdown.tiddler[]thenelse] + +\procedure postImportActions() \whitespace trim -<$list filter="[links[]] :reduce[get[type]prefix[image]thenelsesearch-replace[$title$],addprefix]" variable="imageTitle"> +<$list filter="[links[]] :reduce[get.link.template[]substitute[]addprefix]" variable="imageTitle"> <$action-sendmessage $message="tm-edit-text-operation" $param="insert-text" @@ -22,14 +32,14 @@ condition: [!has[type]] [type[text/vnd.tiddlywiki] /> <> -\end +\end postImportActions -\define buttons() +\procedure buttons() \whitespace trim <$button class="tc-btn-invisible" actions=<> ><> <$button class="tc-btn-invisible" message="tm-perform-import" param=<> actions=<> ><> -\end +\end buttons \whitespace trim <$reveal type="popup" state=<> tag="div" class="tc-editor-importpopup"> @@ -42,4 +52,4 @@ condition: [!has[type]] [type[text/vnd.tiddlywiki] - + \ No newline at end of file diff --git a/core/wiki/config/EditorEnableImportFilter.tid b/core/wiki/config/EditorEnableImportFilter.tid index 55d068e120c..805ad72f0b0 100644 --- a/core/wiki/config/EditorEnableImportFilter.tid +++ b/core/wiki/config/EditorEnableImportFilter.tid @@ -1,4 +1,4 @@ title: $:/config/Editor/EnableImportFilter type: text/vnd.tiddlywiki -[all[current]type[text/vnd.tiddlywiki]] [all[current]!has[type]] \ No newline at end of file +[all[current]type[text/vnd.tiddlywiki]] [all[current]!has[type]] [all[current]type[text/markdown]] [all[current]type[text/x-markdown]] \ No newline at end of file