aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/reference-files.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/src/reference-files.ts')
-rw-r--r--apps/files/src/reference-files.ts43
1 files changed, 43 insertions, 0 deletions
diff --git a/apps/files/src/reference-files.ts b/apps/files/src/reference-files.ts
new file mode 100644
index 00000000000..3d089fe93c4
--- /dev/null
+++ b/apps/files/src/reference-files.ts
@@ -0,0 +1,43 @@
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import Vue from 'vue'
+import { t } from '@nextcloud/l10n'
+
+import { registerWidget, registerCustomPickerElement, NcCustomPickerRenderResult } from '@nextcloud/vue/components/NcRichText'
+
+import FileWidget from './views/ReferenceFileWidget.vue'
+import FileReferencePickerElement from './views/FileReferencePickerElement.vue'
+
+Vue.mixin({
+ methods: {
+ t,
+ },
+})
+
+registerWidget('file', (el, { richObjectType, richObject, accessible, interactive }) => {
+ const Widget = Vue.extend(FileWidget)
+ new Widget({
+ propsData: {
+ richObjectType,
+ richObject,
+ accessible,
+ interactive,
+ },
+ }).$mount(el)
+}, () => {}, { hasInteractiveView: true })
+
+registerCustomPickerElement('files', (el, { providerId, accessible }) => {
+ const Element = Vue.extend(FileReferencePickerElement)
+ const vueElement = new Element({
+ propsData: {
+ providerId,
+ accessible,
+ },
+ }).$mount(el)
+ return new NcCustomPickerRenderResult(vueElement.$el, vueElement)
+}, (el, renderResult) => {
+ renderResult.object.$destroy()
+})