@schukai/monster 4.154.4 → 4.154.5
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
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","CHANGELOG.md"],"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"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"4.154.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","CHANGELOG.md"],"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"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"4.154.5"}
|
|
@@ -1181,6 +1181,25 @@ function setImageFromData(data, options) {
|
|
|
1181
1181
|
|
|
1182
1182
|
if (isString(data)) {
|
|
1183
1183
|
const trimmed = data.trim();
|
|
1184
|
+
const normalizedContentType = contentType
|
|
1185
|
+
.split(";", 1)[0]
|
|
1186
|
+
.trim()
|
|
1187
|
+
.toLowerCase();
|
|
1188
|
+
const svgMarkup = trimmed.replace(/^<\?xml[\s\S]*?\?>\s*/iu, "");
|
|
1189
|
+
if (
|
|
1190
|
+
normalizedContentType === "image/svg+xml" &&
|
|
1191
|
+
/^<svg(?:\s|>)/iu.test(svgMarkup)
|
|
1192
|
+
) {
|
|
1193
|
+
return loadImageFromSource.call(
|
|
1194
|
+
this,
|
|
1195
|
+
`data:image/svg+xml;charset=utf-8,${encodeURIComponent(trimmed)}`,
|
|
1196
|
+
{
|
|
1197
|
+
storeOriginal,
|
|
1198
|
+
resetAspect: storeOriginal,
|
|
1199
|
+
resetView: storeOriginal,
|
|
1200
|
+
},
|
|
1201
|
+
);
|
|
1202
|
+
}
|
|
1184
1203
|
if (trimmed.startsWith("data:") || trimmed.startsWith("blob:")) {
|
|
1185
1204
|
return loadImageFromSource.call(this, trimmed, {
|
|
1186
1205
|
storeOriginal,
|
|
@@ -109,4 +109,31 @@ describe('ImageEditor', function () {
|
|
|
109
109
|
'<monster-button-bar class="grid-span-full monster-margin-top-2">',
|
|
110
110
|
);
|
|
111
111
|
});
|
|
112
|
+
|
|
113
|
+
it('loads raw SVG markup with its documented content type issue #589', async function () {
|
|
114
|
+
const OriginalImage = globalThis.Image;
|
|
115
|
+
const sources = [];
|
|
116
|
+
|
|
117
|
+
class ImageMock {
|
|
118
|
+
set src(value) {
|
|
119
|
+
sources.push(value);
|
|
120
|
+
queueMicrotask(() => this.onerror?.(new Error('test stop')));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
globalThis.Image = ImageMock;
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const element = document.createElement('monster-image-editor');
|
|
128
|
+
const markup = '<svg xmlns="http://www.w3.org/2000/svg"><rect width="4" height="3"/></svg>';
|
|
129
|
+
|
|
130
|
+
await element.setImage(markup, {contentType: 'image/svg+xml'}).catch(() => {});
|
|
131
|
+
|
|
132
|
+
expect(sources).to.have.length(1);
|
|
133
|
+
expect(sources[0]).to.match(/^data:image\/svg\+xml;charset=utf-8,/);
|
|
134
|
+
expect(decodeURIComponent(sources[0].split(',', 2)[1])).to.equal(markup);
|
|
135
|
+
} finally {
|
|
136
|
+
globalThis.Image = OriginalImage;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
112
139
|
});
|