Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax <max@nextcloud.com>2022-03-01 14:32:54 +0300
committerMax <max@nextcloud.com>2022-03-01 14:32:54 +0300
commit12db90b67665defe740aa1b6a27e90ec03ea7c69 (patch)
treeb58e9653a32687c17548743c0913aa630acca5b8 /src
parent890da34eb0847fb52c8f0af83dd336d4d9b4e31d (diff)
parent7b420e780ea9ffb89f980ca1652aefa3cf0b861e (diff)
Merge branch 'fix/master/image_data_urls' of https://github.com/DerpgonCz/text into DerpgonCz-fix/master/image_data_urls
Diffstat (limited to 'src')
-rw-r--r--src/nodes/ImageView.vue7
-rw-r--r--src/tests/nodes/ImageView.spec.js6
2 files changed, 11 insertions, 2 deletions
diff --git a/src/nodes/ImageView.vue b/src/nodes/ImageView.vue
index ddbf75bcb..b97ee1613 100644
--- a/src/nodes/ImageView.vue
+++ b/src/nodes/ImageView.vue
@@ -173,7 +173,7 @@ export default {
})
}
}
- if (this.isRemoteUrl || this.isPreviewUrl) {
+ if (this.isRemoteUrl || this.isPreviewUrl || this.isDataUrl) {
return this.src
}
if (this.hasPreview && this.mime !== 'image/gif') {
@@ -189,6 +189,9 @@ export default {
return this.src.match(/^(\/index.php)?\/core\/preview/)
|| this.src.match(/^(\/index.php)?\/apps\/files_sharing\/publicpreview\//)
},
+ isDataUrl() {
+ return this.src.startsWith('data:')
+ },
basename() {
return decodeURI(this.src.split('?')[0])
},
@@ -275,7 +278,6 @@ export default {
return
}
const img = new Image()
- img.src = this.imageUrl
img.onload = () => {
this.imageLoaded = true
}
@@ -284,6 +286,7 @@ export default {
this.imageLoaded = false
this.loaded = true
}
+ img.src = this.imageUrl
},
methods: {
updateAlt() {
diff --git a/src/tests/nodes/ImageView.spec.js b/src/tests/nodes/ImageView.spec.js
index fcb4b0c4a..773e4f14c 100644
--- a/src/tests/nodes/ImageView.spec.js
+++ b/src/tests/nodes/ImageView.spec.js
@@ -65,6 +65,12 @@ describe('Image View src attribute based on markdown', () => {
.toBe('https://nextcloud/index.php/apps/files_sharing/publicpreview/CSYoWifBzrsMWeA?file=/deck11-calendar.png&x=1760&y=990&a=true')
})
+ test('data urls are used as is', () => {
+ const src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII='
+ const wrapper = factory({src})
+ expect(wrapper.find('.image__main').attributes('src')).toBe(src)
+ })
+
test('image served by the Text app API', () => {
const wrapper = factory({src: 'text://image?imageFileName=1640709467-a%60a%60a.png'})
expect(wrapper.vm.isSupportedImage).toBe(true)