Web: Editor: Added action link.

This commit is contained in:
Tatiana Lopaeva 2021-08-05 14:05:09 +03:00
parent e86124cbdd
commit 3beec799e7

View File

@ -39,6 +39,7 @@ import SharingDialog from "files/SharingDialog";
import { createNewFile, getDefaultFileName, openDocEditor } from "files/utils"; import { createNewFile, getDefaultFileName, openDocEditor } from "files/utils";
import i18n from "./i18n"; import i18n from "./i18n";
import { FolderType } from "@appserver/common/constants"; import { FolderType } from "@appserver/common/constants";
let documentIsReady = false; let documentIsReady = false;
const text = "text"; const text = "text";
@ -362,6 +363,16 @@ const Editor = () => {
goback, 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 onRequestSharingSettings;
let onRequestRename; let onRequestRename;
let onRequestCreateNew; let onRequestCreateNew;
@ -391,6 +402,7 @@ const Editor = () => {
onRequestSharingSettings, onRequestSharingSettings,
onRequestRename, onRequestRename,
onRequestCreateNew, onRequestCreateNew,
onMakeActionLink: onMakeActionLink,
}, },
}; };
@ -449,6 +461,24 @@ const Editor = () => {
updateFile(fileInfo.id, title); 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 = () => { const onCancel = () => {
setIsVisible(false); setIsVisible(false);
}; };