@slithy/prim-interface 0.2.8 → 0.2.9
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/dist/index.js +16 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113,8 +113,15 @@ async function saveRasterFromVector(svgString, width, height, format = "png", qu
|
|
|
113
113
|
saveRaster(canvas, format, quality, options);
|
|
114
114
|
}
|
|
115
115
|
async function copyRasterFromVector(svgString, width, height) {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
await navigator.clipboard.write([
|
|
117
|
+
new ClipboardItem({
|
|
118
|
+
"image/png": svgToCanvas(svgString, width, height).then(
|
|
119
|
+
(canvas) => new Promise(
|
|
120
|
+
(resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed")))
|
|
121
|
+
)
|
|
122
|
+
)
|
|
123
|
+
})
|
|
124
|
+
]);
|
|
118
125
|
}
|
|
119
126
|
async function shareFromVector(svgString, width, height, options) {
|
|
120
127
|
const canvas = await svgToCanvas(svgString, width, height);
|
|
@@ -130,8 +137,13 @@ async function copyVector(svgString) {
|
|
|
130
137
|
await navigator.clipboard.writeText(svgString);
|
|
131
138
|
}
|
|
132
139
|
async function copyRaster(canvas) {
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
await navigator.clipboard.write([
|
|
141
|
+
new ClipboardItem({
|
|
142
|
+
"image/png": new Promise(
|
|
143
|
+
(resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed")))
|
|
144
|
+
)
|
|
145
|
+
})
|
|
146
|
+
]);
|
|
135
147
|
}
|
|
136
148
|
async function share(canvas, options) {
|
|
137
149
|
const blob = await new Promise((resolve, reject) => canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed"))));
|