How do we Create an External Pretty Link Button

Hello forum,

I created a button and tagged the tiddler with $:/tags/EditorToolbar:

<$button>
  <$action-sendmessage $message="tm-edit-text-operation"
    $param="wrap-selection"
    prefix="[ext[https://www.homepage.com/"
    suffix="]]"
  />
  Add Link
</$button>

When I select a text - eg. Test - and click the button, an external link will be generted:

How can the url be suppressed that I only see the link of the text - like grafik ?

Thanks,
Stefan

Have a closer look at the External links at: Linking in Wikitext using a pretty-link

eg: [[Test|https://example.com/Text]]

My Cheatsheet Plugin, which can be installed in every wiki from a bookmark toolbar (no restart needed) could help you with that.

And how do I generate this pretty-link just by selecting a text and clicking on Add Link - button?

I think, there is no pretty-link button in the editor atm. But IMO it’s worth a feature request at GH. (I’ll create one)

There are some questions?

  1. Do you select the pretty link text and add the link - or
  2. Do you select the URL address and want to insert a new pretty link text

Question for everyone. 1) or 2)

Sorry I did not see your code.

<$action-sendmessage
	$message="tm-edit-text-operation"
	$param="wrap-selection"
	prefix="[["
	suffix="|https://www.homepage.com/]]"
	trimSelection="yes"
/>

I personally would want to get a dropdown, which allows more freedom with the URL … So the GH issue should be still valid


The How to create dynamic editor toolbar buttons tiddler contains an interactive example, which gives you an example “bold” button with all needed fields. …

I solved like this:

At the end I use always the same url like a präfix + selected text. (see my examples)
(select text and click button or better use shortcut for the button - with a dropdown I have to do a lot more clicks)

Thanks,
Stefan

Could it be smart? If the selection is identifiable as a URL, then prompt for the pretty link. Otherwise assume it’s already the final text and just needs a target added. Could this behavior even be rolled into the existing “Create wikitext link” button? (It would be a behavior change for it which I understand would be offputting, but if a URL is never selected then it would behave the same as it always has - and the current behavior isn’t friendly to anyone wanting to turn an existing URL in the text into a link, so I’d wonder if it’s ever used that way?)