Merge branch 'hotfix/v0.0.4' of https://github.com/ONLYOFFICE/CommunityServer-AspNetCore into hotfix/v0.0.4

This commit is contained in:
Nikita Gopienko 2020-12-21 15:28:43 +03:00
commit f4cd82f6f0
11 changed files with 118 additions and 11 deletions

View File

@ -12,7 +12,7 @@
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link id="favicon" rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!-- Tell the browser it's a PWA -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -2,9 +2,25 @@ import React from "react";
import { withRouter } from "react-router";
import { Toast, Box } from "asc-web-components";
import { utils, api, toastr, Loaders } from "asc-web-common";
import { isIOS, deviceType } from "react-device-detect";
import { setDocumentTitle } from "../../../helpers/utils";
import { changeTitle, setFavicon, isIPad } from "./utils";
import throttle from "lodash/throttle";
const { getObjectByLocation, showLoader, hideLoader, tryRedirectTo } = utils;
let documentIsReady = false;
let docTitle = null;
let fileType = null;
let docSaved = null;
const throttledChangeTitle = throttle(
() => changeTitle(docSaved, docTitle),
500
);
class PureEditor extends React.Component {
constructor(props) {
super(props);
@ -28,8 +44,10 @@ class PureEditor extends React.Component {
console.log("PureEditor componentDidMount", fileId, doc);
const vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty("--vh", `${vh}px`);
if (isIPad()) {
const vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty("--vh", `${vh}px`);
}
showLoader();
@ -73,23 +91,62 @@ class PureEditor extends React.Component {
onLoad = (config) => {
try {
docTitle = config.document.title;
fileType = config.document.fileType;
setFavicon(fileType);
setDocumentTitle(docTitle);
if (window.innerWidth < 720) {
config.type = "mobile";
}
const events = {
events: {
onDocumentStateChange: this.onDocumentStateChange,
onMetaChange: this.onMetaChange,
onDocumentReady: this.onDocumentReady,
},
};
const newConfig = Object.assign(config, events);
if (!window.DocsAPI) throw new Error("DocsAPI is not defined");
hideLoader();
window.DocsAPI.DocEditor("editor", config);
window.DocsAPI.DocEditor("editor", newConfig);
} catch (error) {
console.log(error);
toastr.error(error.message, null, 0, true);
}
};
onDocumentStateChange = (event) => {
if (!documentIsReady) return;
docSaved = !event.data;
throttledChangeTitle();
};
onDocumentReady = () => {
documentIsReady = true;
};
onMetaChange = (event) => {
const newTitle = event.data.title;
if (newTitle && newTitle !== docTitle) {
setDocumentTitle(newTitle);
docTitle = newTitle;
}
};
render() {
return (
<Box widthProp="100vw" heightProp="100vh">
<Box
widthProp="100vw"
heightProp={isIPad() ? "calc(var(--vh, 1vh) * 100)" : "100vh"}
>
<Toast />
{!this.state.isLoading ? (

View File

@ -0,0 +1,34 @@
import { setDocumentTitle } from "../../../helpers/utils";
import { isIOS, deviceType } from "react-device-detect";
import textIcon from "./icons/text.ico";
import presentationIcon from "./icons/presentation.ico";
import spreadsheetIcon from "./icons/spreadsheet.ico";
export const changeTitle = (docSaved, docTitle) => {
docSaved ? setDocumentTitle(docTitle) : setDocumentTitle(`*${docTitle}`);
};
export const setFavicon = (fileType) => {
const favicon = document.getElementById("favicon");
if (!favicon) return;
switch (fileType) {
case "docx":
favicon.href = textIcon;
break;
case "pptx":
favicon.href = presentationIcon;
break;
case "xlsx":
favicon.href = spreadsheetIcon;
break;
default:
break;
}
};
export const isIPad = () => {
return isIOS && deviceType === "tablet";
};

View File

@ -170,7 +170,10 @@ class FilesRowContent extends React.PureComponent {
const itemId = e.currentTarget.dataset.itemid;
if (itemTitle.trim() === "") return this.completeAction(itemId);
if (itemTitle.trim() === "") {
toastr.warning(this.props.t("CreateWithEmptyTitle"));
return this.completeAction(itemId);
}
let tab = item.fileExst
? window.open("/products/files/doceditor", "_blank")
@ -222,7 +225,14 @@ class FilesRowContent extends React.PureComponent {
}
renameTitle = (e) => {
this.setState({ itemTitle: e.target.value });
let title = e.target.value;
//const chars = '*+:"<>?|/'; TODO: think how to solve problem with interpolation escape values in i18n translate
const regexp = new RegExp('[*+:"<>?|\\\\/]', "gim");
if (title.match(regexp)) {
toastr.warning(this.props.t("ContainsSpecCharacter"));
}
title = title.replace(regexp, "_");
return this.setState({ itemTitle: title });
};
cancelUpdateItem = (e) => {

View File

@ -116,5 +116,7 @@
"MoveItem": "<strong>{{title}}</strong> moved",
"MoveItems": "<strong>{{qty}}</strong> elements has been moved",
"CopyItem": "<strong>{{title}}</strong> copied",
"CopyItems": "<strong>{{qty}}</strong> elements copied"
"CopyItems": "<strong>{{qty}}</strong> elements copied",
"ContainsSpecCharacter": "The title cannot contain any of the following characters: *+:\"<>?|/",
"CreateWithEmptyTitle": "Can't create folder or file with empty title"
}

View File

@ -116,5 +116,7 @@
"MoveItem": "<strong>{{title}}</strong> перемещен",
"MoveItems": "Перемещено элементов: <strong>{{qty}}</strong>",
"CopyItem": "<strong>{{title}}</strong> скопирован",
"CopyItems": "Скопировано элементов: <strong>{{qty}}</strong>"
"CopyItems": "Скопировано элементов: <strong>{{qty}}</strong>",
"ContainsSpecCharacter": "Название не должно содержать следующих символов: *+:\"<>?|/",
"CreateWithEmptyTitle": "Нельзя создать папку или файл с пустым названием"
}

View File

@ -1164,8 +1164,10 @@ namespace ASC.Files.Core.Data
public Dictionary<string, string> GetBunchObjectIDs(List<int> folderIDs)
{
var folderSIds = folderIDs.Select(r => r.ToString()).ToList();
return Query(FilesDbContext.BunchObjects)
.Where(r => folderIDs.Any(a => a.ToString() == r.LeftNode))
.Where(r => folderSIds.Any(a => a == r.LeftNode))
.ToDictionary(r => r.LeftNode, r => r.RightNode);
}

View File

@ -588,7 +588,7 @@ namespace ASC.Files.Core.Security
foreach (var e in filteredEntries)
{
var adapter = findedAdapters[e.RootFolderId.ToString()];
findedAdapters.TryGetValue(e.RootFolderId.ToString(), out var adapter);
if (adapter == null) continue;