@rogieking/figui3 1.5.7 → 1.5.8
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.
- package/fig.js +24 -2
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -1925,8 +1925,30 @@ class FigImage extends HTMLElement {
|
|
|
1925
1925
|
}
|
|
1926
1926
|
});
|
|
1927
1927
|
}
|
|
1928
|
-
handleFileInput(e) {
|
|
1929
|
-
this.
|
|
1928
|
+
async handleFileInput(e) {
|
|
1929
|
+
this.blob = URL.createObjectURL(e.target.files[0]);
|
|
1930
|
+
//set base64 url
|
|
1931
|
+
const reader = new FileReader();
|
|
1932
|
+
reader.readAsDataURL(e.target.files[0]);
|
|
1933
|
+
//await this data url to be set
|
|
1934
|
+
await new Promise((resolve) => {
|
|
1935
|
+
reader.onload = (e) => {
|
|
1936
|
+
this.base64 = e.target.result;
|
|
1937
|
+
resolve();
|
|
1938
|
+
};
|
|
1939
|
+
});
|
|
1940
|
+
//emit event for loaded
|
|
1941
|
+
this.dispatchEvent(
|
|
1942
|
+
new CustomEvent("load", {
|
|
1943
|
+
bubbles: true,
|
|
1944
|
+
cancelable: true,
|
|
1945
|
+
detail: {
|
|
1946
|
+
blob: this.blob,
|
|
1947
|
+
base64: this.base64,
|
|
1948
|
+
},
|
|
1949
|
+
})
|
|
1950
|
+
);
|
|
1951
|
+
this.src = this.blob;
|
|
1930
1952
|
this.setAttribute("src", this.src);
|
|
1931
1953
|
this.chit.setAttribute("src", this.src);
|
|
1932
1954
|
}
|