Skip to content

Commit

Permalink
wip: Refactor documents related components #904
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Dec 8, 2024
1 parent c093074 commit 1f6dbbc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/client/components/document/KBrowser.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="fit column bg-black">
<div class="fit column">
<div class="full-width row justify-between items-center">
<div
v-if="document"
Expand Down
17 changes: 13 additions & 4 deletions core/client/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ export const Document = {
jpeg: 'document/KImage',
'image/jpeg': 'document/KImage',
png: 'document/KImage',
'image/png': 'document/KImage'
'image/png': 'document/KImage',
apng: 'document/KImage',
'image/apng': 'document/KImage',
gif: 'document/KImage',
'image/gif': 'document/KImage',
webp: 'document/KImage',
'image/webp': 'document/KImage',
svg: 'document/KImage',
'image/svg+xml': 'document/KImage'
},
htmlSanitizer: {
allowedTags: sanitize.defaults.allowedTags.concat(['img'])
Expand All @@ -30,12 +38,13 @@ export const Document = {
})
logger.debug('[KDK] Configuring documents with options:', this.options)
},
register (mimeTypes, viewer) {
if (!_.isArray(mimeTypes)) mimeTypes = [mimeTypes]
_.forEach(mimeTypes, mimeType => {
register (type, viewer) {
if (!_.isArray(type)) type = [type]
_.forEach(type, mimeType => {
_.set(this.options, `viewers.${mimeType}`, viewer)
})
},

sanitizeHtml (html) {
if (_.isNil(html)) return null
return sanitize(html, this.options.htmlSanitizer)
Expand Down

0 comments on commit 1f6dbbc

Please sign in to comment.