Skip to content

Commit d7e173e

Browse files
committed
using blob uris to show in-memory images
1 parent ccea329 commit d7e173e

File tree

7 files changed

+30
-5
lines changed

7 files changed

+30
-5
lines changed

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ package miso
1111

1212
packages:
1313
pub/miso/*.cabal
14+
pub/miso/examples/*.cabal
1415

1516
source-repository-package
1617
type: git

ghcjs/miso-functora/dist/miso-functora/post-theme.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ghcjs/miso-functora/js/main.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineCustomElements } from "@ionic/pwa-elements/loader";
22
import { Filesystem, Directory } from "@capacitor/filesystem";
33
import { WebviewPrint } from "capacitor-webview-print";
4+
import { dataUriToBuffer } from "data-uri-to-buffer";
45
import { Preferences } from "@capacitor/preferences";
56
import { Clipboard } from "@capacitor/clipboard";
67
import { Browser } from "@capacitor/browser";
@@ -28,8 +29,14 @@ export async function insertStorage(key, value) {
2829
}
2930

3031
export async function selectClipboard() {
31-
const { value } = await Clipboard.read();
32-
return value;
32+
const { type, value } = await Clipboard.read();
33+
if (type.startsWith("text")) {
34+
return value;
35+
} else {
36+
const { buffer: u8a, typeFull: mime } = dataUriToBuffer(value);
37+
const blob = new Blob([u8a, { type: mime }]);
38+
return URL.createObjectURL(blob);
39+
}
3340
}
3441

3542
export async function openBrowserPage(url) {

ghcjs/miso-functora/js/main.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ghcjs/miso-functora/package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ghcjs/miso-functora/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@capacitor/toast": "^6.0.2",
2020
"@ionic/pwa-elements": "^3.3.0",
2121
"capacitor-webview-print": "^6.0.1",
22+
"data-uri-to-buffer": "^6.0.2",
2223
"file-saver": "^2.0.5",
2324
"html5-qrcode": "^2.3.8"
2425
},

pub/miso/examples/input-bugs/Main.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE LambdaCase #-}
23
{-# LANGUAGE OverloadedStrings #-}
34
{-# LANGUAGE RecordWildCards #-}
45

@@ -11,7 +12,7 @@ module Main where
1112

1213
import Control.Monad.IO.Class
1314
import Miso
14-
import Miso.String (MisoString)
15+
import Miso.String (MisoString, ms)
1516

1617
#ifdef IOS
1718
import Language.Javascript.JSaddle.WKWebView as JSaddle
@@ -76,6 +77,12 @@ viewModel inputs =
7677
)
7778
( zip [0 ..] inputs
7879
)
80+
<> fmap
81+
( img_
82+
. (: mempty)
83+
. src_
84+
)
85+
inputs
7986

8087
updateAt :: Int -> (a -> a) -> [a] -> [a]
8188
updateAt idx f xs

0 commit comments

Comments
 (0)