render email as plain text in checklist and postinstall
This commit is contained in:
@@ -1,6 +1,26 @@
|
||||
|
||||
import { prettyBinarySize } from '@cloudron/pankow/utils';
|
||||
import { RELAY_PROVIDERS, ISTATES, STORAGE_PROVIDERS } from './constants.js';
|
||||
import { Marked } from 'marked';
|
||||
|
||||
function safeMarked() {
|
||||
const marked = new Marked({
|
||||
renderer: {
|
||||
link({ href, title, text }) {
|
||||
if (href && href.startsWith('mailto:')) return text; // mailto is rendered as text
|
||||
const titleAttr = title ? ` title="${title}"` : '';
|
||||
const isAbsolute = href && (href.startsWith('http://') || href.startsWith('https://') || href.startsWith('//'));
|
||||
const targetAttr = isAbsolute ? ' target="_blank"' : '';
|
||||
return `<a href="${href}"${targetAttr}${titleAttr}>${text}</a>`;
|
||||
}
|
||||
}
|
||||
});
|
||||
return marked;
|
||||
}
|
||||
|
||||
function renderSafeMarkdown(text) {
|
||||
return safeMarked().parse(text);
|
||||
}
|
||||
|
||||
function prettyRelayProviderName(provider) {
|
||||
if (provider === 'noop') return 'Disabled (no email will be sent)';
|
||||
@@ -762,6 +782,7 @@ function parseFullBackupPath(fullPath) {
|
||||
|
||||
// named exports
|
||||
export {
|
||||
renderSafeMarkdown,
|
||||
prettyRelayProviderName,
|
||||
download,
|
||||
mountlike,
|
||||
@@ -784,6 +805,7 @@ export {
|
||||
|
||||
// default export
|
||||
export default {
|
||||
renderSafeMarkdown,
|
||||
prettyRelayProviderName,
|
||||
download,
|
||||
mountlike,
|
||||
|
||||
Reference in New Issue
Block a user