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

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-05-20 22:24:39 +0300
committerGitHub <noreply@github.com>2020-05-20 22:24:39 +0300
commitd0eba26c7c54b93329b24907240480ecda44dd78 (patch)
tree674196c532a08caec010ca3a9217b0cf30d8c44b /src
parenteda633dd83820eb02c7feb4a5cd3962b2edd9009 (diff)
parentef3ec7483d52edfa23c61c6389905b620b317cf0 (diff)
Merge pull request #975 from nextcloud/enh/capabiltities
Diffstat (limited to 'src')
-rw-r--r--src/helpers/types.js40
-rw-r--r--src/viewer.js35
2 files changed, 42 insertions, 33 deletions
diff --git a/src/helpers/types.js b/src/helpers/types.js
index 597f7c06..22ec61fb 100644
--- a/src/helpers/types.js
+++ b/src/helpers/types.js
@@ -21,23 +21,11 @@
*
*/
-const getFileType = (document, ooxml) => {
- let documentTypes = {
- document: {
- extension: 'odt',
- mime: 'application/vnd.oasis.opendocument.text'
- },
- spreadsheet: {
- extension: 'ods',
- mime: 'application/vnd.oasis.opendocument.spreadsheet'
- },
- presentation: {
- extension: 'odp',
- mime: 'application/vnd.oasis.opendocument.presentation'
- }
- }
+const ooxml = OC.getCapabilities()['richdocuments']['config']['doc_format'] === 'ooxml'
+
+const getFileTypes = () => {
if (ooxml) {
- documentTypes = {
+ return {
document: {
extension: 'docx',
mime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
@@ -52,9 +40,27 @@ const getFileType = (document, ooxml) => {
}
}
}
- return documentTypes[document]
+ return {
+ document: {
+ extension: 'odt',
+ mime: 'application/vnd.oasis.opendocument.text'
+ },
+ spreadsheet: {
+ extension: 'ods',
+ mime: 'application/vnd.oasis.opendocument.spreadsheet'
+ },
+ presentation: {
+ extension: 'odp',
+ mime: 'application/vnd.oasis.opendocument.presentation'
+ }
+ }
+}
+
+const getFileType = (document) => {
+ return getFileTypes()[document]
}
export default {
+ getFileTypes,
getFileType
}
diff --git a/src/viewer.js b/src/viewer.js
index 4118564f..5c9e2b4d 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -86,9 +86,11 @@ const odfViewer = {
var fileDir = context.dir
var fileId = context.fileId || context.$file.attr('data-id')
var templateId = context.templateId
- context.fileList.setViewerMode(true)
- context.fileList.setPageTitle(fileName)
- context.fileList.showMask()
+ if (context.fileList) {
+ context.fileList.setViewerMode(true)
+ context.fileList.setPageTitle(fileName)
+ context.fileList.showMask()
+ }
}
odfViewer.receivedLoading = false
@@ -216,17 +218,15 @@ const odfViewer = {
FilesAppIntegration.close()
},
- registerFilesMenu: function(response) {
- Config.update('ooxml', response.doc_format === 'ooxml')
+ registerFilesMenu: function() {
const registerFilesMenu = (OCA) => {
OCA.FilesLOMenu = {
attach: function(newFileMenu) {
var self = this
- const ooxml = Config.get('ooxml')
- const document = Types.getFileType('document', ooxml)
- const spreadsheet = Types.getFileType('spreadsheet', ooxml)
- const presentation = Types.getFileType('presentation', ooxml)
+ const document = Types.getFileType('document')
+ const spreadsheet = Types.getFileType('spreadsheet')
+ const presentation = Types.getFileType('presentation')
newFileMenu.addMenuEntry({
id: 'add-' + document.extension,
@@ -409,7 +409,15 @@ const odfViewer = {
}
}
-window.OCA.RichDocuments = {}
+const settings = OC.getCapabilities()['richdocuments']['config'] || {}
+Config.update('ooxml', settings['doc_format'] === 'ooxml')
+
+window.OCA.RichDocuments = {
+ config: {
+ create: Types.getFileTypes()
+ }
+}
+
$(document).ready(function() {
// register file actions and menu
if (typeof OCA !== 'undefined'
@@ -421,12 +429,7 @@ $(document).ready(function() {
odfViewer.supportedMimes.push('text/plain')
}
odfViewer.register()
-
- $.get(OC.filePath('richdocuments', 'ajax', 'settings.php')).done(function(settings) {
- // TODO: move ooxml setting to capabilities so we don't need this request
- odfViewer.registerFilesMenu(settings)
- })
-
+ odfViewer.registerFilesMenu()
}
// Open documents if a public page is opened for a supported mimetype