@bobfrankston/rmfmail 1.0.679 → 1.0.680

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -139,6 +139,27 @@ export async function createTinyMceEditor(container, opts = {}) {
139
139
  // everything that the schema allows.
140
140
  paste_word_valid_elements: "@[style|class],-strong/b,-em/i,-u,-s,-sub,-sup,-strike,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-blockquote,-table[border|cellpadding|cellspacing|width|height|class|style],-tr,-td[colspan|rowspan|width|height|class|style|valign|align|background|bgcolor],-th,-thead,-tbody,-tfoot,-pre,-br,-a[href|target|title],-img[src|alt|width|height|style|class]",
141
141
  paste_retain_style_properties: "color background background-color font-family font-size font-weight font-style text-decoration text-align padding padding-top padding-bottom padding-left padding-right margin margin-top margin-bottom margin-left margin-right border border-top border-bottom border-left border-right",
142
+ // Auto-link bare URLs in pasted content. TinyMCE's `autolink`
143
+ // plugin only fires on TYPED space/enter; URLs that arrive via
144
+ // clipboard (browser address bar, terminal copy) come in as
145
+ // plain text and stay un-linked. paste_preprocess runs on the
146
+ // HTML the paste plugin produced.
147
+ //
148
+ // CRITICAL: skip auto-link when the content already contains
149
+ // anchors. Naive regex over the whole content would wrap
150
+ // `<a href="X">X</a>` in ANOTHER anchor (nested anchors are
151
+ // invalid HTML and browsers split them, producing visible
152
+ // junk). For HTML pastes that already have linked URLs (the
153
+ // common case from a browser address bar or another mail
154
+ // client), TinyMCE preserves them — no auto-link pass needed.
155
+ // For plain-text pastes (no anchors present), wrap any bare
156
+ // http(s)://… runs. Trailing sentence punctuation is excluded
157
+ // from the URL.
158
+ paste_preprocess: (_plugin, args) => {
159
+ if (/<a[\s>]/i.test(args.content))
160
+ return;
161
+ args.content = args.content.replace(/(^|[\s(\[])((?:https?|ftp):\/\/[^\s<>"']+[^\s<>"'.,;:!?)\]])/gi, (_m, lead, url) => `${lead}<a href="${url}">${url}</a>`);
162
+ },
142
163
  content_style: "body { font-family: system-ui, sans-serif; font-size: 14px; }",
143
164
  init_instance_callback: (ed) => resolve(ed),
144
165
  setup: (ed) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/rmfmail",
3
- "version": "1.0.679",
3
+ "version": "1.0.680",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",