diff --git a/packages/asc-web-common/api/files/index.js b/packages/asc-web-common/api/files/index.js index f80ca42939..39e882abbb 100644 --- a/packages/asc-web-common/api/files/index.js +++ b/packages/asc-web-common/api/files/index.js @@ -536,10 +536,13 @@ export function getNewFiles(folderId) { }); } -export function convertFile(fileId) { +export function convertFile(fileId, sync = false) { + const data = { sync }; + return request({ method: "put", url: `/files/file/${fileId}/checkconversion`, + data, }); } diff --git a/products/ASC.Files/Client/src/helpers/utils.js b/products/ASC.Files/Client/src/helpers/utils.js index de8aa0d12a..def770f945 100644 --- a/products/ASC.Files/Client/src/helpers/utils.js +++ b/products/ASC.Files/Client/src/helpers/utils.js @@ -2,12 +2,12 @@ import authStore from "@appserver/common/store/AuthStore"; import { AppServerConfig } from "@appserver/common/constants"; import config from "../../package.json"; import { combineUrl, toUrlParams } from "@appserver/common/utils"; -import { - addFileToRecentlyViewed, -} from "@appserver/common/api/files"; +import { addFileToRecentlyViewed } from "@appserver/common/api/files"; import i18n from "./i18n"; import { request } from "@appserver/common/api/client"; +import docserviceStore from "../store/DocserviceStore"; + export const setDocumentTitle = (subTitle = null) => { const { isAuthenticated, settingsStore, product: currentModule } = authStore; const { organizationName } = settingsStore; @@ -98,3 +98,9 @@ export const SaveAs = (title, url, folderId, openNewTab) => { "_blank" ); }; + +export const canConvert = (fileExst) => { + const { canConvert } = docserviceStore; + + return canConvert(fileExst); +}; diff --git a/web/ASC.Web.Editor/src/Editor.jsx b/web/ASC.Web.Editor/src/Editor.jsx index 1988bb24d2..49e04d9b27 100644 --- a/web/ASC.Web.Editor/src/Editor.jsx +++ b/web/ASC.Web.Editor/src/Editor.jsx @@ -26,6 +26,7 @@ import { removeFromFavorite, markAsFavorite, getPresignedUri, + convertFile, } from "@appserver/common/api/files"; import { checkIsAuthenticated } from "@appserver/common/api/user"; import { getUser } from "@appserver/common/api/people"; @@ -37,7 +38,7 @@ import { homepage } from "../package.json"; import { AppServerConfig } from "@appserver/common/constants"; import SharingDialog from "files/SharingDialog"; -import { getDefaultFileName, SaveAs } from "files/utils"; +import { getDefaultFileName, SaveAs, canConvert } from "files/utils"; import SelectFileDialog from "files/SelectFileDialog"; import SelectFolderDialog from "files/SelectFolderDialog"; import { StyledSelectFolder, StyledSelectFile } from "./StyledEditor"; @@ -150,6 +151,15 @@ const Editor = () => { if (successAuth) { try { fileInfo = await getFileInfo(fileId); + + if (url.indexOf("#message/")) { + const needConvert = canConvert(fileInfo.fileExst); + + if (needConvert) { + const convert = await convertFile(fileId, true); + location.href = convert[0].result.webUrl; + } + } } catch (err) { console.error(err); }