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

public.js « src - github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 754d76f5e6454e3d891fb1244b606383ebd84c99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { documentReady } from './helpers/index.js'
import {
	FilesWorkspacePlugin,
	registerFileActionFallback,
	registerFileCreate,
} from './helpers/files.js'
import { openMimetypes } from './helpers/mime.js'
import { loadState } from '@nextcloud/initial-state'
import store from './store.js'

__webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line
__webpack_public_path__ = OC.linkTo('text', 'js/') // eslint-disable-line

documentReady(() => {
	const dir = document.getElementById('dir').value
	const mimetype = document.getElementById('mimetype').value
	const sharingToken = document.getElementById('sharingToken') ? document.getElementById('sharingToken').value : null

	if (!sharingToken) {
		return
	}

	if (dir !== '') {
		OC.Plugins.register('OCA.Files.FileList', FilesWorkspacePlugin)
		registerFileActionFallback()
		registerFileCreate()
	} else {
		// single file share
		const container = document.createElement('div')
		container.id = 'texteditor'
		const body = document.getElementById('app-content')
		body.appendChild(container)

		if (openMimetypes.indexOf(mimetype) !== -1) {
			Promise.all([
				import(/* webpackChunkName: "vendor" */'vue'),
				import(/* webpackChunkName: "editor" */'./components/EditorWrapper.vue'),
			]).then((imports) => {
				const Vue = imports[0].default
				Vue.prototype.t = window.t
				Vue.prototype.OCA = window.OCA
				const Editor = imports[1].default
				const vm = new Vue({
					render: h => h(Editor, {
						props: {
							active: true,
							shareToken: sharingToken,
							mime: mimetype,
						},
					}),
					store,
				})
				vm.$mount(document.getElementById('preview'))
			})
		}
	}
})

OCA.Text = {
	RichWorkspaceEnabled: loadState('text', 'workspace_available'),
}