@schukai/monster 4.42.1 → 4.42.2
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/source/components/content/viewer.mjs +1 -19
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.42.
|
1
|
+
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.42.2"}
|
@@ -483,7 +483,6 @@ class Viewer extends CustomElement {
|
|
483
483
|
let revoke = null;
|
484
484
|
let suggestedName = filename;
|
485
485
|
|
486
|
-
// 1) Datenquelle normalisieren → href + optional revoke
|
487
486
|
if (data instanceof File) {
|
488
487
|
href = URL.createObjectURL(data);
|
489
488
|
suggestedName = data.name || filename;
|
@@ -496,18 +495,14 @@ class Viewer extends CustomElement {
|
|
496
495
|
(isString(data) && /^(data:|blob:|https?:)/.test(data))
|
497
496
|
) {
|
498
497
|
href = data.toString();
|
499
|
-
// Dateiname ggf. aus URL ableiten
|
500
498
|
try {
|
501
499
|
const u = new URL(href, location.href);
|
502
500
|
const last = u.pathname.split("/").pop();
|
503
501
|
if ((!filename || filename === "download") && last) {
|
504
502
|
suggestedName = decodeURIComponent(last);
|
505
503
|
}
|
506
|
-
} catch {
|
507
|
-
/* ignore */
|
508
|
-
}
|
504
|
+
} catch {}
|
509
505
|
} else if (isString(data)) {
|
510
|
-
// Reiner Inhalt → als Datei verpacken
|
511
506
|
const blob = new Blob([data], { type: "application/octet-stream" });
|
512
507
|
href = URL.createObjectURL(blob);
|
513
508
|
revoke = () => URL.revokeObjectURL(href);
|
@@ -517,14 +512,12 @@ class Viewer extends CustomElement {
|
|
517
512
|
throw new Error(msg);
|
518
513
|
}
|
519
514
|
|
520
|
-
// 2) Button rendern
|
521
515
|
const button =
|
522
516
|
`<monster-button data-monster-role="download">` +
|
523
517
|
this.getOption("labels.download") +
|
524
518
|
`</monster-button>`;
|
525
519
|
this.setOption("content", button);
|
526
520
|
|
527
|
-
// 3) Alten Handler entfernen & ggf. alte Object-URL freigeben
|
528
521
|
if (this[downloadHandlerSymbol]) {
|
529
522
|
this.removeEventListener("click", this[downloadHandlerSymbol]);
|
530
523
|
}
|
@@ -534,7 +527,6 @@ class Viewer extends CustomElement {
|
|
534
527
|
} catch {}
|
535
528
|
}
|
536
529
|
|
537
|
-
// 4) Neuen Handler setzen
|
538
530
|
this[downloadHandlerSymbol] = (event) => {
|
539
531
|
const el = findTargetElementFromEvent(
|
540
532
|
event,
|
@@ -543,23 +535,13 @@ class Viewer extends CustomElement {
|
|
543
535
|
);
|
544
536
|
if (el instanceof Button) {
|
545
537
|
const a = document.createElement("a");
|
546
|
-
|
547
|
-
// Cross-Origin Hinweis:
|
548
|
-
// Der download-Attr kann bei fremder Origin ignoriert werden. In dem Fall
|
549
|
-
// öffnet der Browser die URL. Wenn du *erzwingen* willst, dann vorher
|
550
|
-
// per fetch → blob holen (sofern CORS erlaubt) und daraus eine Object-URL bauen.
|
551
|
-
|
552
538
|
a.href = href;
|
553
539
|
a.download = suggestedName;
|
554
540
|
a.rel = "noopener";
|
555
541
|
a.style.display = "none";
|
556
|
-
|
557
542
|
document.body.appendChild(a);
|
558
543
|
a.click();
|
559
544
|
document.body.removeChild(a);
|
560
|
-
|
561
|
-
// Object-URL nach dem Klick freigeben
|
562
|
-
if (revoke) setTimeout(revoke, 0);
|
563
545
|
}
|
564
546
|
};
|
565
547
|
this[downloadRevokeSymbol] = revoke;
|