@bobfrankston/rmfmail 1.2.147 → 1.2.148

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.
@@ -2137,12 +2137,11 @@ async function createTinyMceEditor(container2, opts = {}) {
2137
2137
  relative_urls: false,
2138
2138
  remove_script_host: false,
2139
2139
  paste_data_images: true,
2140
- // Permissive valid_elements preserve as much of the source
2141
- // formatting as possible. The default is more aggressive about
2142
- // stripping. Empty string for `valid_elements` means accept
2143
- // everything that the schema allows.
2144
- 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]",
2145
- 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",
2140
+ // NOTE: paste_word_valid_elements and paste_retain_style_properties
2141
+ // were REMOVED in TinyMCE 8 (core paste keeps formatting by
2142
+ // default now) passing them only triggered the deprecation
2143
+ // console warning on every compose load. Removed 2026-07-18; if
2144
+ // TinyMCE is ever pinned back to ≤7, restore them from git.
2146
2145
  // Auto-link bare URLs in pasted content. TinyMCE's `autolink`
2147
2146
  // plugin only fires on TYPED space/enter; URLs that arrive via
2148
2147
  // clipboard (browser address bar, terminal copy) come in as
@@ -2203,6 +2202,28 @@ async function createTinyMceEditor(container2, opts = {}) {
2203
2202
  setup: (ed) => {
2204
2203
  if (opts.initialHtml)
2205
2204
  ed.on("init", () => ed.setContent(opts.initialHtml));
2205
+ ed.on("paste", (e) => {
2206
+ const cb = e.clipboardData;
2207
+ if (!cb)
2208
+ return;
2209
+ const imgItem = Array.from(cb.items || []).find((i) => i.kind === "file" && i.type.startsWith("image/"));
2210
+ if (!imgItem)
2211
+ return;
2212
+ if ((cb.getData("text/plain") || "").trim())
2213
+ return;
2214
+ const file = imgItem.getAsFile();
2215
+ if (!file)
2216
+ return;
2217
+ e.preventDefault();
2218
+ const reader = new FileReader();
2219
+ reader.onload = () => {
2220
+ try {
2221
+ ed.insertContent(`<img src="${String(reader.result || "")}" alt="${file.name || "pasted image"}">`);
2222
+ } catch {
2223
+ }
2224
+ };
2225
+ reader.readAsDataURL(file);
2226
+ });
2206
2227
  ed.on("GetContent", (e) => {
2207
2228
  if (!e?.content || typeof e.content !== "string" || !e.content.includes("blob:"))
2208
2229
  return;