New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Add support for preheaders #274
Comments
It may also be necessary to add another paremeter for inline styles, such as in the following pattern:
the Example:
(note: I only added line breaks for readability, the command cannot have line breaks in the template) Main problems, the first parameter would currently not be able to support the following tokens |
I propose that we use the class .preheader in the actual renderer HTML email, I believe this will become a standard at some stage. If it gets standardized to a different class name we can add this class to the implementation. If the standards consortiums decide to give it its own HTML5 tag we will have reimplement anyway. if className is optional, should we still process the third parameter (inline rules, in double quotation marks)? I imagine 4 different ways to use the function: %preheader("text content")%
%preheader("text content",className)%
%preheader("text content","inline rules")%
%preheader("text content",className,"inline rules")% We can make sure this is always injected as the very first element within |
I will also propose that we inject style="display:none;", unless a parameter with inline rules has been added |
[issue 274] Add %preheader()% variable for injecting previe
Here is a first preview version, I also added some documentation in the variables tab (not localized yet). A nice-to-have for later to add would be support as a smart snippet, like this: To test the version above, download the zip file, drag the file into Thunderbird Add-ons Manager, do not extract contents or if won't install. |
I also added a footnote on how to include commas in the text (they need to be escaped with a backslash To test the version above, download the zip file, drag the file into Thunderbird Add-ons Manager, do not extract contents or if won't install. |
Added footnote for escaping commas
Improved documentation and implemented support for multiple commas in the text (escape with backslash mandatory) plus a prompt that helps writing the string when clicked from the variables tab: This will convert the contained commas accordingly:
Commas will now also be escaped for similar prompts when clicking To test the version above, download the zip file, drag the file into Thunderbird Add-ons Manager, do not extract contents or if won't install. |
Latest version below. I fixed some problem that cut off the last character of the text, and also added
This will convert the selected text (from the email) into the preheader (and will remove it from screen). In order to keep it on screen you can use the following script instead - note that we use
it is also possible to inject the clipboard contents to a preheader directly, using this simplified syntax:
To test the version above, download the zip file, drag the file into Thunderbird Add-ons Manager, do not extract contents or if won't install. |
Added support for clipboard and *selection* (in fragments) Added documentation Moved gMsgCompose.editor.rootElement to wrapper object ST4.composer
Added documentation and localisation in the variables tab: To test the version above, download the zip file, drag the file into Thunderbird Add-ons Manager, do not extract contents or if won't install. |
Apparently in the changes above there is a regression that breaks my "add shadow to picture" macro, which looks like this: <div style="border: 1px solid rgba(80, 80, 80, 0.3); box-shadow: rgba(80, 80, 80, 0.3) 5px 5px 5px; width:max-content;">*selection*</div> This is designed to add a shadow frame around a selected image . it appears to fail when inserting the modified html into composer, at smartTemplates-fileTemplates.js:1637 }
gMsgCompose.editor.insertHTML(code);
// we should probably place the cursor at the end of the inserted HTML afterwards! the inserted code appears to look correct (line breaks inserted by me for readability): <div style="border: 1px solid rgba(80, 80, 80, 0.3); box-shadow: rgba(80, 80, 80, 0.3) 5px 5px 5px; width:max-content;">
<img src="data:image/png;base64\\,iVBORw0KGgoAA..."
alt=""></div> |
Found the problem in line 1567 if (selectedText && selectedText.length) {
html = html.replace("*selection*", selectedText.replaceAll(",","\\,")); // escape all commas
} else {
html = html.replace("*selection*", "%cursor%");
} This replaces commas in the selected html (and breaks the image) and not in the smart fragment, patched code: if (selectedText && selectedText.length) {
// html = html.replaceAll(",","\\,"); // replacing the commas will only work if snippet has no binary data in it
// should only do this within ".." we need to investigate how...
html = html.replace("*selection*", selectedText);
} else { turns out it is not safe to escape commas indiscriminately (We would need an intelligent parser here that only looks at strings contained in double auotes, which is not trivial to write) Fixed version below: To test this, download the zip file, drag the file into Thunderbird Add-ons Manager, do not extract contents or if won't install. |
Implemented in 4.4 - published 28/03/2024 |
By design, all contents of
<body>
or of the template is wrapped within<div class ="smartTemplate4-template">
However by definition hidden preheader tags need to be the first element of the so they cannot be contained in a parent element. Therefore SmartTemplates should define a simple way to add a preheader element (e.g.
<div class="preheader">
that can be injected before the template body and be recognized by search engines / ISPs that support preheader.)Requirements:
<div>
that is injected as first direct child of<body>
Suggestion:
%preheader("text content",className)%
The text was updated successfully, but these errors were encountered: