RealRaven2000 / SmartTemplates

Thunderbird Add-on: SmartTemplates
http://smarttemplates.quickfolders.org/
Other
25 stars 15 forks source link

Add flavor parameter to %clipboard()% #330

Closed RealRaven2000 closed 2 weeks ago

RealRaven2000 commented 1 month ago

When reading the clipboard we can have multiple formats, e.g. when copying an email address from an open Composer from the editor we can end up creating a string like this:

<html><body>
<!--StartFragment-->thunderbirddaily@gmail.com<!--EndFragment-->
</body>
</html>

Therefore we we need a way to force %clipboard% to return the plain text value instead. At the moment the order of preference is: ["text/html","text/unicode","text/plain"];

Instead I propose adding an optional parameter: "html", "unicode" or "plain" / "text" which would force reading that flavor expolicitely.

RealRaven2000 commented 1 month ago

New parameters that are supported:

plain, text, rtf, unicode, html

for example:%clipboard(text)%

this will make sure that just the visible text is inserted from the clipboard even if there are multiple formats in the clipboard. Without the parameter, the old behavior will try to show the formats in this order or priority:

"text/html", "text/unicode", "text/plain"

This is to ensure background compatibility and to easily support the *clipboard* inline text when you are using it in a layout snippet, because you may want to have html injected inside this syntax. If the requested flavor in the passed parameter is not available, SmartTemplates will try to retrieve the next one as fallback. So in the case of using

%clipboard(rtf,text,plain)%

it will try for the flavor "text/rtf" first, then "text/univoce", then "text/plain" and then "text/html". It returns the clipboard data wherever it finds content first.

RealRaven2000 commented 1 month ago

Preview version:

smartTemplate-fx-4.9pre84.zip


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

RealRaven2000 commented 2 weeks ago

Implemented in 4.9 - published 11/11/2024