Merge pull request #1618 from ONLYOFFICE/feature/react-refactoring

Refactoring 'EditText'
This commit is contained in:
maxkadushkin 2022-03-14 10:53:17 +03:00 committed by GitHub
commit 8323ac2934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 73 deletions

View file

@ -25,26 +25,10 @@ const PageFonts = props => {
const spriteThumbs = storeTextSettings.spriteThumbs; const spriteThumbs = storeTextSettings.spriteThumbs;
const arrayRecentFonts = storeTextSettings.arrayRecentFonts; const arrayRecentFonts = storeTextSettings.arrayRecentFonts;
useEffect(() => {
setRecent(getImageUri(arrayRecentFonts));
return () => {
}
}, []);
const addRecentStorage = () => { const addRecentStorage = () => {
let arr = [];
arrayRecentFonts.forEach(item => arr.push(item));
setRecent(getImageUri(arrayRecentFonts)); setRecent(getImageUri(arrayRecentFonts));
LocalStorage.setItem('dde-settings-recent-fonts', JSON.stringify(arr)); LocalStorage.setItem('dde-settings-recent-fonts', JSON.stringify(arrayRecentFonts));
} };
const [stateRecent, setRecent] = useState([]);
const [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const getImageUri = fonts => { const getImageUri = fonts => {
return fonts.map(font => { return fonts.map(font => {
@ -55,6 +39,13 @@ const PageFonts = props => {
}); });
}; };
const [stateRecent, setRecent] = useState(() => getImageUri(arrayRecentFonts));
const [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const renderExternal = (vl, vlData) => { const renderExternal = (vl, vlData) => {
setVlFonts((prevState) => { setVlFonts((prevState) => {
let fonts = [...prevState.vlData.items]; let fonts = [...prevState.vlData.items];

View file

@ -209,26 +209,10 @@ const PageFonts = props => {
const spriteThumbs = storeTextSettings.spriteThumbs; const spriteThumbs = storeTextSettings.spriteThumbs;
const arrayRecentFonts = storeTextSettings.arrayRecentFonts; const arrayRecentFonts = storeTextSettings.arrayRecentFonts;
useEffect(() => {
setRecent(getImageUri(arrayRecentFonts));
return () => {
}
}, []);
const addRecentStorage = () => { const addRecentStorage = () => {
let arr = [];
arrayRecentFonts.forEach(item => arr.push(item));
setRecent(getImageUri(arrayRecentFonts)); setRecent(getImageUri(arrayRecentFonts));
LocalStorage.setItem('ppe-settings-recent-fonts', JSON.stringify(arr)); LocalStorage.setItem('ppe-settings-recent-fonts', JSON.stringify(arrayRecentFonts));
} };
const [stateRecent, setRecent] = useState([]);
const [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const getImageUri = fonts => { const getImageUri = fonts => {
return fonts.map(font => { return fonts.map(font => {
@ -239,6 +223,13 @@ const PageFonts = props => {
}); });
}; };
const [stateRecent, setRecent] = useState(() => getImageUri(arrayRecentFonts));
const [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const renderExternal = (vl, vlData) => { const renderExternal = (vl, vlData) => {
setVlFonts((prevState) => { setVlFonts((prevState) => {
let fonts = [...prevState.vlData.items]; let fonts = [...prevState.vlData.items];

View file

@ -156,26 +156,10 @@ const PageFontsCell = props => {
const spriteCols = storeTextSettings.spriteCols; const spriteCols = storeTextSettings.spriteCols;
const spriteThumbs = storeTextSettings.spriteThumbs; const spriteThumbs = storeTextSettings.spriteThumbs;
useEffect(() => {
setRecent(getImageUri(arrayRecentFonts));
return () => {
}
}, []);
const addRecentStorage = () => { const addRecentStorage = () => {
let arr = [];
arrayRecentFonts.forEach(item => arr.push(item));
setRecent(getImageUri(arrayRecentFonts)); setRecent(getImageUri(arrayRecentFonts));
LocalStorage.setItem('sse-settings-recent-fonts', JSON.stringify(arr)); LocalStorage.setItem('sse-settings-recent-fonts', JSON.stringify(arrayRecentFonts));
} };
const [stateRecent, setRecent] = useState([]);
const [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const getImageUri = fonts => { const getImageUri = fonts => {
return fonts.map(font => { return fonts.map(font => {
@ -184,7 +168,14 @@ const PageFontsCell = props => {
return thumbCanvas.toDataURL(); return thumbCanvas.toDataURL();
}); });
}; };
const [stateRecent, setRecent] = useState(() => getImageUri(arrayRecentFonts));
const [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const renderExternal = (vl, vlData) => { const renderExternal = (vl, vlData) => {
setVlFonts((prevState) => { setVlFonts((prevState) => {

View file

@ -109,26 +109,10 @@ const PageFonts = props => {
const spriteThumbs = storeTextSettings.spriteThumbs; const spriteThumbs = storeTextSettings.spriteThumbs;
const arrayRecentFonts = storeTextSettings.arrayRecentFonts; const arrayRecentFonts = storeTextSettings.arrayRecentFonts;
useEffect(() => {
setRecent(getImageUri(arrayRecentFonts));
return () => {
}
}, []);
const addRecentStorage = () => { const addRecentStorage = () => {
let arr = [];
arrayRecentFonts.forEach(item => arr.push(item));
setRecent(getImageUri(arrayRecentFonts)); setRecent(getImageUri(arrayRecentFonts));
LocalStorage.setItem('sse-settings-recent-fonts', JSON.stringify(arr)); LocalStorage.setItem('sse-settings-recent-fonts', JSON.stringify(arrayRecentFonts));
} };
const [stateRecent, setRecent] = useState([]);
const [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const getImageUri = fonts => { const getImageUri = fonts => {
return fonts.map(font => { return fonts.map(font => {
@ -139,6 +123,13 @@ const PageFonts = props => {
}); });
}; };
const [stateRecent, setRecent] = useState(() => getImageUri(arrayRecentFonts));
const [vlFonts, setVlFonts] = useState({
vlData: {
items: [],
}
});
const renderExternal = (vl, vlData) => { const renderExternal = (vl, vlData) => {
setVlFonts((prevState) => { setVlFonts((prevState) => {
let fonts = [...prevState.vlData.items]; let fonts = [...prevState.vlData.items];