♻️ (#2463): remove duplicated code

Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
This commit is contained in:
Vinicius Reis 2022-06-06 18:05:41 -03:00 коммит произвёл Julius Härtl
Родитель 5abdf58b48
Коммит f2c95d14cb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C614C6ED2CDE6DF
3 изменённых файлов: 17 добавлений и 27 удалений

Просмотреть файл

@ -43,6 +43,7 @@
<script>
import { getCurrentUser } from '@nextcloud/auth'
import { showError } from '@nextcloud/dialogs'
import { mimetypesImages as IMAGE_MIMES } from '../helpers/mime.js'
import {
useEditorMixin,
@ -56,18 +57,6 @@ import {
STATE_UPLOADING,
} from './EditorMediaHandler.provider.js'
const IMAGE_MIMES = [
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
'image/x-xbitmap',
'image/x-ms-bmp',
'image/bmp',
'image/svg+xml',
'image/webp',
]
export default {
name: 'EditorMediaHandler',
mixins: [useEditorMixin, useFileMixin, useSyncServiceMixin],

Просмотреть файл

@ -20,6 +20,18 @@
*
*/
const mimetypesImages = [
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
'image/x-xbitmap',
'image/x-ms-bmp',
'image/bmp',
'image/svg+xml',
'image/webp',
]
const openMimetypesMarkdown = [
'text/markdown',
]
@ -55,6 +67,7 @@ if (!window.oc_appswebroots?.richdocuments && !window.oc_appswebroots?.onlyoffic
const openMimetypes = [...openMimetypesMarkdown, ...openMimetypesPlainText]
export {
mimetypesImages,
openMimetypes,
openMimetypesMarkdown,
openMimetypesPlainText,

Просмотреть файл

@ -87,22 +87,11 @@
import { generateUrl } from '@nextcloud/router'
import { NodeViewWrapper } from '@tiptap/vue-2'
import ClickOutside from 'vue-click-outside'
// import TrashCanIcon from 'vue-material-design-icons/TrashCan.vue'
import { Image as ImageIcon, TrashCan } from '../components/icons.js'
import store from './../mixins/store.js'
import { useImageResolver } from './../components/EditorWrapper.provider.js'
const imageMimes = [
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
'image/x-xbitmap',
'image/x-ms-bmp',
'image/bmp',
'image/svg+xml',
'image/webp',
]
import { mimetypesImages as IMAGE_MIMES } from '../helpers/mime.js'
const getQueryVariable = (src, variable) => {
const query = src.split('?')[1]
@ -172,9 +161,8 @@ export default {
return getQueryVariable(this.src, 'fileId')
},
isSupportedImage() {
const mime = getQueryVariable(this.src, 'mimetype')
return typeof mime === 'undefined'
|| imageMimes.indexOf(mime) !== -1
return typeof this.mime === 'undefined'
|| IMAGE_MIMES.indexOf(this.mime) !== -1
},
internalLinkOrImage() {
if (this.imageFileId) {