Merge pull request #389 from ONLYOFFICE/feature/editor-edit-button
Web: Editor: Added edit editor button.
This commit is contained in:
commit
801c5ff561
@ -221,6 +221,11 @@ const Editor = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const convertDocumentUrl = async () => {
|
||||
const convert = await convertFile(fileId, true);
|
||||
return convert[0].result.webUrl;
|
||||
};
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
if (!fileId) return;
|
||||
@ -255,17 +260,14 @@ const Editor = () => {
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (successAuth) {
|
||||
try {
|
||||
fileInfo = await getFileInfo(fileId);
|
||||
|
||||
if (url.indexOf("#message/") > -1) {
|
||||
const needConvert = canConvert(fileInfo.fileExst);
|
||||
|
||||
if (needConvert) {
|
||||
const convert = await convertFile(fileId, true);
|
||||
location.href = convert[0].result.webUrl;
|
||||
if (canConvert(fileInfo.fileExst)) {
|
||||
const url = await convertDocumentUrl();
|
||||
history.pushState({}, null, url);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
@ -296,7 +298,7 @@ const Editor = () => {
|
||||
|
||||
isSharingAccess = fileInfo && fileInfo.canShare;
|
||||
|
||||
if (url.indexOf("action=view") !== -1) {
|
||||
if (view) {
|
||||
config.editorConfig.mode = "view";
|
||||
}
|
||||
|
||||
@ -488,6 +490,7 @@ const Editor = () => {
|
||||
onRequestSaveAs,
|
||||
onRequestMailMergeRecipients,
|
||||
onRequestCompareFile,
|
||||
onRequestEditRights: onSDKRequestEditRights,
|
||||
},
|
||||
};
|
||||
|
||||
@ -518,6 +521,22 @@ const Editor = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const onSDKRequestEditRights = async () => {
|
||||
console.log("ONLYOFFICE Document Editor requests editing rights");
|
||||
const index = url.indexOf("&action=view");
|
||||
|
||||
if (index) {
|
||||
let convertUrl = url.substring(0, index);
|
||||
|
||||
if (canConvert(fileInfo.fileExst)) {
|
||||
convertUrl = await convertDocumentUrl();
|
||||
}
|
||||
|
||||
history.pushState({}, null, convertUrl);
|
||||
document.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const [isFileDialogVisible, setIsFileDialogVisible] = useState(false);
|
||||
const [isFolderDialogVisible, setIsFolderDialogVisible] = useState(false);
|
||||
|
Loading…
Reference in New Issue
Block a user