From d54a5a0656a2165f66f5155620b877cbb3e3ea01 Mon Sep 17 00:00:00 2001 From: AlexeySafronov Date: Tue, 29 Dec 2020 18:43:12 +0300 Subject: [PATCH] Added reqDesktop on DocEditor page --- .../src/components/pages/DocEditor/index.js | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/products/ASC.Files/Client/src/components/pages/DocEditor/index.js b/products/ASC.Files/Client/src/components/pages/DocEditor/index.js index 2f4bf0ba8a..c453d153e7 100644 --- a/products/ASC.Files/Client/src/components/pages/DocEditor/index.js +++ b/products/ASC.Files/Client/src/components/pages/DocEditor/index.js @@ -1,7 +1,8 @@ import React from "react"; import { withRouter } from "react-router"; import { Toast, Box } from "asc-web-components"; -import { utils, api, toastr, Loaders } from "asc-web-common"; +import { utils, api, toastr, Loaders, regDesktop } from "asc-web-common"; + import { isIOS, deviceType } from "react-device-detect"; import { setDocumentTitle } from "../../../helpers/utils"; import { changeTitle, setFavicon, isIPad } from "./utils"; @@ -28,17 +29,19 @@ class PureEditor extends React.Component { const urlParams = getObjectByLocation(window.location); const fileId = urlParams ? urlParams.fileId || null : null; const doc = urlParams ? urlParams.doc || null : null; + const desktop = window["AscDesktopEditor"] !== undefined; this.state = { fileId, doc, isLoading: true, + isDesktop: desktop, }; } async componentDidMount() { try { - const { fileId, doc } = this.state; + const { fileId, doc, isDesktop } = this.state; if (!fileId) return; @@ -61,6 +64,21 @@ class PureEditor extends React.Component { const config = await api.files.openEdit(fileId, doc); + if (isDesktop) { + + const isEncryption = + config.editorConfig["encryptionKeys"] !== undefined; + const user = await api.people.getUser(); + + regDesktop( + user, + isEncryption, + config.editorConfig.encryptionKeys, + (keys) => api.files.setEncryptionKeys(keys), + true + ); + } + this.setState({ isLoading: false }, () => this.loadDocApi(docApiUrl, () => this.onLoad(config)) ); @@ -91,6 +109,9 @@ class PureEditor extends React.Component { onLoad = (config) => { try { + + console.log(config); + docTitle = config.document.title; fileType = config.document.fileType; @@ -111,6 +132,13 @@ class PureEditor extends React.Component { const newConfig = Object.assign(config, events); + const { isDesktop } = this.state; + + if (isDesktop && newConfig.editorConfig["encryptionKeys"] !== undefined) { + newConfig.editorConfig.encryptionKeys.cryptoEngineId = + "{FFF0E1EB-13DB-4678-B67D-FF0A41DBBCEF}"; + } + if (!window.DocsAPI) throw new Error("DocsAPI is not defined"); hideLoader();