diff --git a/plugins/tiddlywiki/markdown/EditorToolbar/link-dropdown.tid b/plugins/tiddlywiki/markdown/EditorToolbar/link-dropdown.tid new file mode 100644 index 000000000..848da32f6 --- /dev/null +++ b/plugins/tiddlywiki/markdown/EditorToolbar/link-dropdown.tid @@ -0,0 +1,73 @@ +title: $:/plugins/tiddlywiki/markdown/EditorToolbar/link-dropdown + +\define lingo-base() $:/language/Buttons/Link/ + +\define add-link-actions() +\whitespace trim +<$action-sendmessage $message="tm-edit-text-operation" $param="make-markdown-link" text={{$(linkTiddler)$}} /> +<$action-deletetiddler $filter="[] [] [] [] []"/> +\end + +\define get-focus-selector() [data-tiddler-title="$(cssEscapedTitle)$"] .tc-create-wikitext-link input + +\define cancel-search-actions-inner() +<$set name="userInput" value={{{ [get[text]] }}}><$list filter="[get[text]!match]" emptyMessage="<$action-deletetiddler $filter='[] [] [] []'/>"><$action-setfield $tiddler=<> text=<>/><$action-setfield $tiddler=<> text="yes"/> +\end + +\define cancel-search-actions() <$list filter="[!has[text]] +[!has[text]]" emptyMessage="<>"><$action-sendmessage $message="tm-edit-text-operation" $param="focus-editor"/> + +\define external-link() +\whitespace trim +<$button class="tc-btn-invisible" style="width: auto; display: inline-block; background-colour: inherit;" actions=<>> +{{$:/core/images/chevron-right}} + +\end + +\define set-next-input-tab(beforeafter:"after") <$macrocall $name="change-input-tab" stateTitle="$:/state/tab/search-results/sidebar" tag="$:/tags/SearchResults" beforeafter="$beforeafter$" defaultState={{$:/config/SearchResults/Default}} actions="<$action-setfield $tiddler='$:/state/search/currentTab' text=<>/>"/> + +\define body(config-title) +\whitespace trim +''<>'' + +<$vars searchTiddler="""$config-title$/search""" linkTiddler="""$config-title$/link""" linktext="" searchListState=<> refreshTitle=<> storeTitle=<>> + +<$vars linkTiddler=<>> +<$keyboard key="((input-tab-right))" actions=<>> +<$keyboard key="((input-tab-left))" actions=<> class="tc-create-wikitext-link"> +<$macrocall $name="keyboard-driven-input" tiddler=<> storeTitle=<> + selectionStateTitle=<> refreshTitle=<> type="search" filterMinLength="1" + tag="input" focus="true" class="tc-popup-handle" inputCancelActions=<> + inputAcceptActions=<> placeholder={{$:/language/Search/Search}} default="" + configTiddlerFilter="[[$:/state/search/currentTab]!is[missing]get[text]] ~[{$:/config/SearchResults/Default}]" /> + + + +<$reveal tag="span" state=<> type="nomatch" text=""> +<> + +<$button class="tc-btn-invisible" style="width: auto; display: inline-block; background-colour: inherit;"> +<><$set name="cssEscapedTitle" value={{{ [escapecss[]] }}}><$action-sendmessage $message="tm-focus-selector" $param=<>/> +{{$:/core/images/close-button}} + + + + +<$reveal tag="div" state=<> type="nomatch" text=""> + +<$linkcatcher actions=<> to=<>> + +<$vars userInput={{{ [get[text]] }}} configTiddler={{{ [[$:/state/search/currentTab]!is[missing]get[text]] ~[{$:/config/SearchResults/Default}] }}}> + +{{$:/core/ui/SearchResults}} + + + + + + + + + +\end + +<$macrocall $name="body" config-title=<>/> diff --git a/plugins/tiddlywiki/markdown/EditorToolbar/link.tid b/plugins/tiddlywiki/markdown/EditorToolbar/link.tid index f1a41317f..009b93802 100755 --- a/plugins/tiddlywiki/markdown/EditorToolbar/link.tid +++ b/plugins/tiddlywiki/markdown/EditorToolbar/link.tid @@ -1,15 +1,11 @@ -caption: {{$:/language/Buttons/Link/Caption}} (Markdown) -condition: [type[text/x-markdown]] [type[text/markdown]] -description: {{$:/language/Buttons/Link/Hint}} -icon: $:/core/images/link -list-after: $:/core/ui/EditorToolbar/link -shortcuts: ((link)) title: $:/plugins/tiddlywiki/markdown/EditorToolbar/link +list-after: $:/core/ui/EditorToolbar/link tags: $:/tags/EditorToolbar +icon: $:/core/images/link +caption: {{$:/language/Buttons/Link/Caption}} +description: {{$:/language/Buttons/Link/Hint}} +condition: [type[text/x-markdown]] [type[text/markdown]] +button-classes: tc-text-editor-toolbar-item-start-group +shortcuts: ((link)) +dropdown: $:/plugins/tiddlywiki/markdown/EditorToolbar/link-dropdown -<$action-sendmessage - $message="tm-edit-text-operation" - $param="wrap-selection" - prefix="[" - suffix="]()" -/> diff --git a/plugins/tiddlywiki/markdown/EditorToolbar/linkify.tid b/plugins/tiddlywiki/markdown/EditorToolbar/linkify.tid new file mode 100755 index 000000000..be842544a --- /dev/null +++ b/plugins/tiddlywiki/markdown/EditorToolbar/linkify.tid @@ -0,0 +1,15 @@ +caption: {{$:/language/Buttons/Linkify/Caption}} (Markdown) +condition: [type[text/x-markdown]] [type[text/markdown]] +description: {{$:/language/Buttons/Linkify/Hint}} +icon: $:/plugins/tiddlywiki/markdown/images/markdown-linkify +list-after: $:/core/ui/EditorToolbar/linkify +shortcuts: ((linkify)) +title: $:/plugins/tiddlywiki/markdown/EditorToolbar/linkify +tags: $:/tags/EditorToolbar + +<$action-sendmessage + $message="tm-edit-text-operation" + $param="wrap-selection" + prefix="[" + suffix="]()" +/> diff --git a/plugins/tiddlywiki/markdown/editor-operations/make-markdown-link.js b/plugins/tiddlywiki/markdown/editor-operations/make-markdown-link.js new file mode 100644 index 000000000..6ab90f883 --- /dev/null +++ b/plugins/tiddlywiki/markdown/editor-operations/make-markdown-link.js @@ -0,0 +1,37 @@ +/*\ +title: $:/plugins/tiddlywiki/markdown/editor-operations/make-markdown-link.js +type: application/javascript +module-type: texteditoroperation + +Text editor operation to make a markdown link + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports["make-markdown-link"] = function(event,operation) { + if(operation.selection) { + if(event.paramObject.text.includes("://")) { + operation.replacement = "[" + operation.selection + "](" + event.paramObject.text + ")"; + } else { + operation.replacement = "[" + operation.selection + "](#" + event.paramObject.text.replaceAll(" ", "%20") + ")"; + } + operation.cutStart = operation.selStart; + operation.cutEnd = operation.selEnd; + } else { + if(event.paramObject.text.includes("://")) { + operation.replacement = "<" + event.paramObject.text + ">"; + } else { + operation.replacement = "[](#" + event.paramObject.text.replaceAll(" ", "%20") + ")"; + } + operation.cutStart = operation.selStart; + operation.cutEnd = operation.selEnd; + } + operation.newSelStart = operation.selStart + operation.replacement.length; + operation.newSelEnd = operation.newSelStart; +}; + +})(); diff --git a/plugins/tiddlywiki/markdown/images/markdown-linkify.tid b/plugins/tiddlywiki/markdown/images/markdown-linkify.tid new file mode 100644 index 000000000..395faf8d9 --- /dev/null +++ b/plugins/tiddlywiki/markdown/images/markdown-linkify.tid @@ -0,0 +1,6 @@ +title: $:/plugins/tiddlywiki/markdown/images/markdown-linkify +tags: $:/tags/Image + + + +