@bobfrankston/rmfmail 1.2.126 → 1.2.127

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.
@@ -1043,6 +1043,7 @@ __export(api_client_exports, {
1043
1043
  deleteTask: () => deleteTask,
1044
1044
  drainStoreSync: () => drainStoreSync,
1045
1045
  emptyFolder: () => emptyFolder,
1046
+ fetchImageAsDataUri: () => fetchImageAsDataUri,
1046
1047
  flagSenderOrDomain: () => flagSenderOrDomain,
1047
1048
  formatJsonc: () => formatJsonc,
1048
1049
  getAccounts: () => getAccounts,
@@ -1645,6 +1646,10 @@ function closeComposePopout(id) {
1645
1646
  const fn = ipc().closeComposePopout;
1646
1647
  return fn ? fn(id) : Promise.resolve({ ok: false });
1647
1648
  }
1649
+ function fetchImageAsDataUri(url) {
1650
+ const fn = ipc().fetchImageAsDataUri;
1651
+ return fn ? fn(url) : Promise.resolve({ error: "no bridge" });
1652
+ }
1648
1653
  async function popoutMainWindow(accountId, folderId, name) {
1649
1654
  const fn = ipc().popoutMainWindow;
1650
1655
  if (!fn)
@@ -4786,8 +4791,39 @@ async function saveDraft2() {
4786
4791
  draftSaving = false;
4787
4792
  }
4788
4793
  }
4794
+ function editorBodyEl() {
4795
+ const ne = editor?.nativeEditor;
4796
+ if (ne?.getBody) {
4797
+ try {
4798
+ return ne.getBody();
4799
+ } catch {
4800
+ }
4801
+ }
4802
+ return document.querySelector(".ql-editor") || document.querySelector(".tt-content .tiptap");
4803
+ }
4804
+ var INLINE_CHECKED_ATTR = "data-mailx-inline-checked";
4805
+ async function inlinePastedRemoteImages() {
4806
+ const body = editorBodyEl();
4807
+ if (!body) return;
4808
+ const imgs = Array.from(body.querySelectorAll(`img[src^="http"]:not([${INLINE_CHECKED_ATTR}])`));
4809
+ for (const img of imgs) {
4810
+ img.setAttribute(INLINE_CHECKED_ATTR, "1");
4811
+ const src = img.getAttribute("src") || "";
4812
+ try {
4813
+ const { fetchImageAsDataUri: fetchImageAsDataUri2 } = await Promise.resolve().then(() => (init_api_client(), api_client_exports));
4814
+ const r = await fetchImageAsDataUri2(src);
4815
+ if (r?.dataUri) {
4816
+ img.setAttribute("src", r.dataUri);
4817
+ } else if (r?.error) {
4818
+ img.setAttribute("title", `Remote image kept as a link (${r.error})`);
4819
+ }
4820
+ } catch {
4821
+ }
4822
+ }
4823
+ }
4789
4824
  function scheduleDraftSave() {
4790
4825
  markComposeDirty();
4826
+ void inlinePastedRemoteImages();
4791
4827
  if (draftDebounceTimer) clearTimeout(draftDebounceTimer);
4792
4828
  draftDebounceTimer = setTimeout(() => {
4793
4829
  draftDebounceTimer = null;