From 3beec799e7359e4d932d852c132f8a830bec7b70 Mon Sep 17 00:00:00 2001 From: TatianaLopaeva Date: Thu, 5 Aug 2021 14:05:09 +0300 Subject: [PATCH] Web: Editor: Added action link. --- web/ASC.Web.Editor/src/Editor.jsx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/web/ASC.Web.Editor/src/Editor.jsx b/web/ASC.Web.Editor/src/Editor.jsx index 5fdd70baec..271cf633ff 100644 --- a/web/ASC.Web.Editor/src/Editor.jsx +++ b/web/ASC.Web.Editor/src/Editor.jsx @@ -39,6 +39,7 @@ import SharingDialog from "files/SharingDialog"; import { createNewFile, getDefaultFileName, openDocEditor } from "files/utils"; import i18n from "./i18n"; import { FolderType } from "@appserver/common/constants"; + let documentIsReady = false; const text = "text"; @@ -362,6 +363,16 @@ const Editor = () => { goback, }; + if (url.indexOf("anchor") !== -1) { + const splitUrl = url.split("anchor="); + const decodeURI = decodeURIComponent(splitUrl[1]); + const obj = JSON.parse(decodeURI); + + config.editorConfig.actionLink = { + action: obj.action, + }; + } + let onRequestSharingSettings; let onRequestRename; let onRequestCreateNew; @@ -391,6 +402,7 @@ const Editor = () => { onRequestSharingSettings, onRequestRename, onRequestCreateNew, + onMakeActionLink: onMakeActionLink, }, }; @@ -449,6 +461,24 @@ const Editor = () => { updateFile(fileInfo.id, title); }; + const onMakeActionLink = (event) => { + var ACTION_DATA = event.data; + + const link = generateLink(ACTION_DATA); + + const urlFormation = !config.editorConfig.actionLink + ? url + : url.split("&anchor=")[0]; + + const linkFormation = `${urlFormation}&anchor=${link}`; + + docEditor.setActionLink(linkFormation); + }; + + const generateLink = (actionData) => { + return encodeURIComponent(JSON.stringify(actionData)); + }; + const onCancel = () => { setIsVisible(false); };