Web: Doceditor: applied hooks
This commit is contained in:
parent
923eeb8f5a
commit
663fad253b
@ -19,6 +19,8 @@ import { EditorWrapper } from "./StyledEditor";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import useSharingDialog from "./helpers/useSharingDialog";
|
import useSharingDialog from "./helpers/useSharingDialog";
|
||||||
import useSelectFileDialog from "./helpers/useSelectFileDialog";
|
import useSelectFileDialog from "./helpers/useSelectFileDialog";
|
||||||
|
import useSelectFolderDialog from "./helpers/useSelectFolderDialog";
|
||||||
|
import useFilesUtils from "./helpers/useFilesUtils";
|
||||||
|
|
||||||
const LoaderComponent = (
|
const LoaderComponent = (
|
||||||
<Loader
|
<Loader
|
||||||
@ -102,7 +104,6 @@ let docEditor;
|
|||||||
|
|
||||||
function Editor({
|
function Editor({
|
||||||
fileInfo,
|
fileInfo,
|
||||||
docApiUrl,
|
|
||||||
config,
|
config,
|
||||||
personal,
|
personal,
|
||||||
successAuth,
|
successAuth,
|
||||||
@ -114,15 +115,10 @@ function Editor({
|
|||||||
actionLink,
|
actionLink,
|
||||||
error,
|
error,
|
||||||
needLoader,
|
needLoader,
|
||||||
...rest
|
|
||||||
}) {
|
}) {
|
||||||
const [titleSelectorFolder, setTitleSelectorFolder] = useState("");
|
|
||||||
const [urlSelectorFolder, setUrlSelectorFolder] = useState("");
|
|
||||||
const [extension, setExtension] = useState();
|
|
||||||
const [isFolderDialogVisible, setIsFolderDialogVisible] = useState(false);
|
|
||||||
const [isLoaded, setIsLoaded] = useState(false);
|
const [isLoaded, setIsLoaded] = useState(false);
|
||||||
const [documentTitle, setNewDocumentTitle] = useState("Loading...");
|
const [documentTitle, setNewDocumentTitle] = useState("Loading...");
|
||||||
|
useFilesUtils();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [
|
const [
|
||||||
@ -139,6 +135,8 @@ function Editor({
|
|||||||
onSDKRequestCompareFile,
|
onSDKRequestCompareFile,
|
||||||
] = useSelectFileDialog(docEditor, t);
|
] = useSelectFileDialog(docEditor, t);
|
||||||
|
|
||||||
|
const [selectFolderDialog, onSDKRequestSaveAs] = useSelectFolderDialog(t);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) {
|
if (error) {
|
||||||
error?.unAuthorized &&
|
error?.unAuthorized &&
|
||||||
@ -389,13 +387,6 @@ function Editor({
|
|||||||
throttledChangeTitle();
|
throttledChangeTitle();
|
||||||
}; //+++
|
}; //+++
|
||||||
|
|
||||||
const onSDKRequestSaveAs = (event) => {
|
|
||||||
setTitleSelectorFolder(event.data.title);
|
|
||||||
setUrlSelectorFolder(event.data.url);
|
|
||||||
setExtension(event.data.title.split(".").pop());
|
|
||||||
setIsFolderDialogVisible(true);
|
|
||||||
}; // +++
|
|
||||||
|
|
||||||
const onSDKAppReady = () => {
|
const onSDKAppReady = () => {
|
||||||
console.log("ONLYOFFICE Document Editor is ready");
|
console.log("ONLYOFFICE Document Editor is ready");
|
||||||
|
|
||||||
@ -552,6 +543,7 @@ function Editor({
|
|||||||
)}
|
)}
|
||||||
{sharingDialog}
|
{sharingDialog}
|
||||||
{selectFileDialog}
|
{selectFileDialog}
|
||||||
|
{selectFolderDialog}
|
||||||
</EditorWrapper>
|
</EditorWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user