TagSpaces is an offline, open source, document manager with tagging support
improve fullscreen and other fixes (#1541)
Stanimir05181044895a
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex d1d1e73e9..568e530de 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -18,6 +18,7 @@import React, {MutableRefObject,+ useCallback,useEffect,useReducer,useRef,@@ -187,7 +188,7 @@ const EntryContainer = (props: Props) => {const [isPropertiesPanelVisible, setPropertiesPanelVisible] = useState<boolean>(false);- // const [isFullscreen, setFullscreen] = useState<boolean>(false);+ const [isFullscreen, setFullscreen] = useState<boolean>(false);// eslint-disable-next-line no-unused-varsconst [ignored, forceUpdate] = useReducer(x => x + 1, 0);// const [editingSupported, setEditingSupported] = useState<boolean>(true);@@ -229,6 +230,45 @@ const EntryContainer = (props: Props) => {}});+ const handleFullscreenChange = useCallback(e => {+ let change = '';+ if (fscreen.fullscreenElement !== null) {+ change = 'Entered fullscreen mode';+ setFullscreen(true);+ } else {+ change = 'Exited fullscreen mode';+ setFullscreen(false);+ }+ console.log(change, e);+ }, []);++ const handleFullscreenError = useCallback(e => {+ console.log('Fullscreen Error', e);+ }, []);++ const toggleFullScreen = useCallback(() => {+ if (isFullscreen) {+ fscreen.exitFullscreen();+ } else {+ fscreen.requestFullscreen(fileViewerContainer.current);+ }+ }, [isFullscreen]);++ useEffect(() => {+ if (fscreen.fullscreenEnabled) {+ fscreen.addEventListener(+ 'fullscreenchange',+ handleFullscreenChange,+ false+ );+ fscreen.addEventListener('fullscreenerror', handleFullscreenError, false);+ return () => {+ fscreen.removeEventListener('fullscreenchange', handleFullscreenChange);+ fscreen.removeEventListener('fullscreenerror', handleFullscreenError);+ };+ }+ });+useEffect(() => {if (fileViewer &&@@ -465,116 +505,6 @@ const EntryContainer = (props: Props) => {PlatformIO.shareFiles([filePath]);};- fscreen.addEventListener('fullscreenchange', exitFullScreenHandler); // , options);- /* document.addEventListener('fullscreenchange', exitFullScreenHandler);- document.addEventListener('webkitfullscreenchange', exitFullScreenHandler);- document.addEventListener('mozfullscreenchange', exitFullScreenHandler);- document.addEventListener('MSFullscreenChange', exitFullScreenHandler); */-- function exitFullScreenHandler() {- if (- fscreen.fullscreenElement === null- /*! document.fullscreenElement &&- // @ts-ignore- !document.webkitIsFullScreen &&- // @ts-ignore- !document.mozFullScreen &&- // @ts-ignore- !document.msFullscreenElement */- ) {- forceUpdate();- }- }-- const toggleFullScreen = () => {- if (!fscreen.fullscreenEnabled) {- return;- }- // this.fileViewerContainer.addEventListener('onfullscreenchange', () => {- // alert('Fullscreen change');- // if (this.state.isFullscreen) {- // this.setState({ isFullscreen: false });- // } else {- // this.fileViewerContainer.removeEventListener('onfullscreenchange');- // }- // });-- // https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#examples-- if (fscreen.fullscreenElement !== null) {- fscreen- .exitFullscreen()- .then(() => {- console.log('Fullscreen exit successful');- // setFullscreen(false);- forceUpdate();- return true;- })- .catch(e => {- console.log('Error exiting fullscreen', e);- });- } else {- fscreen- .requestFullscreen(fileViewerContainer.current)- .then(() => {- forceUpdate();- return true;- })- .catch(ex => {- console.error('requestFullscreen:', ex);- });- }- /* if (document.fullscreenElement && document.webkitExitFullscreen) {- document.webkitExitFullscreen();- // setFullscreen(false);- forceUpdate();- return;- } */- /* else if (this.state.isFullscreen && document.mozExitFullscreen) {- document.mozExitFullscreen();- this.setState({ isFullscreen: false });- return;- } */- /* if (!document.fullscreenElement && fileViewerContainer) {- if (- fileViewerContainer &&- fileViewerContainer.current.requestFullscreen- ) {- fileViewerContainer.current- .requestFullscreen()- .then(() => {- forceUpdate();- return true;- })- .catch(ex => {- console.error('webkitRequestFullscreen:', ex);- });- // setFullscreen(true);- } else if (- fileViewerContainer &&- // @ts-ignore- fileViewerContainer.current.webkitRequestFullscreen- ) {- try {- // @ts-ignore- fileViewerContainer.current.webkitRequestFullscreen();- } catch (ex) {- console.error('webkitRequestFullscreen:', ex);- }- forceUpdate();- // setFullscreen(true);- } else if (- fileViewerContainer &&- // @ts-ignore- fileViewerContainer.current.mozRequestFullScreen- ) {- // @ts-ignore- fileViewerContainer.current.mozRequestFullScreen();- forceUpdate();- }- } */- };-const setPercent = (p: number | undefined) => {percent.current = p;// console.log('Percent ' + percent.current);@@ -1076,7 +1006,6 @@ const EntryContainer = (props: Props) => {initSize = defaultSplitSize; // '0%';}- const isFullscreen = () => fscreen.fullscreenElement !== null;return (<Splithorizontal@@ -1089,7 +1018,7 @@ const EntryContainer = (props: Props) => {<FileViewkey="FileViewID"openedFile={props.openedFiles[0]}- isFullscreen={isFullscreen()}+ isFullscreen={isFullscreen}fileViewer={fileViewer}fileViewerContainer={fileViewerContainer}toggleFullScreen={toggleFullScreen}diff --git a/app/components/FileView.tsx b/app/components/FileView.tsxindex 6959a685a..36e9afd95 100644--- a/app/components/FileView.tsx+++ b/app/components/FileView.tsx@@ -132,6 +132,7 @@ const FileView = (props: Props) => {const areEqual = (prevProp, nextProp) =>nextProp.openedFile.path === prevProp.openedFile.path &&+ nextProp.openedFile.url === prevProp.openedFile.url &&nextProp.openedFile.editMode === prevProp.openedFile.editMode &&nextProp.openedFile.shouldReload === prevProp.openedFile.shouldReload &&nextProp.isFullscreen === prevProp.isFullscreen;diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 910ac04ec..e62cbe86a 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -555,6 +555,7 @@ export default (state: any = initialState, action: any) => {return entry;}const fileNameTags = entry.isFile ? extractedTags : []; // dirs dont have tags in filename+ // const { url, ...rest } = entry;return {...entry,path: action.newPath, // TODO handle change extension case@@ -1635,13 +1636,13 @@ export const actions = {fsEntry.path,fsEntry.isFile);- if (fsEntry.url) {- entryForOpening.url = fsEntry.url;- } else if (PlatformIO.haveObjectStoreSupport()) {+ if (PlatformIO.haveObjectStoreSupport()) {const cleanedPath = fsEntry.path.startsWith('/')? fsEntry.path.substr(1): fsEntry.path;entryForOpening.url = PlatformIO.getURLforPath(cleanedPath);+ } else if (fsEntry.url) {+ entryForOpening.url = fsEntry.url;}if (fsEntry.perspective) {entryForOpening.perspective = fsEntry.perspective;diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.tsindex 91043774e..87c5f4506 100644--- a/app/reducers/location-index.ts+++ b/app/reducers/location-index.ts@@ -423,25 +423,15 @@ export const actions = {searchResults.forEach((entry: TS.FileSystemEntry) => {if (entry.thumbPath &&- entry.thumbPath.length > 1 // &&+ entry.thumbPath.length > 1// !entry.thumbPath.startsWith('http')) {- /* let pathInLocation = '';- if (currentLocation.path) {- /!* const pathLocationArr = currentLocation.path- .split('/')- .filter(el => el); *!/- const pathArr = entry.path- .split('/')- .filter(el => el);- pathInLocation = pathArr.join('/');- // pathLocationArr.join('/') + '/' + pathArr.join('/');- } else {- pathInLocation = entry.thumbPath;- } */+ const thumbPath = entry.path.startsWith('/')+ ? entry.path.substring(1)+ : entry.path;// eslint-disable-next-line no-param-reassignentry.thumbPath = PlatformIO.getURLforPath(- getThumbFileLocationForFile(entry.path, '/')+ getThumbFileLocationForFile(thumbPath, '/'));}});diff --git a/app/utils/misc.ts b/app/utils/misc.tsindex ae2987d01..167ac413e 100644--- a/app/utils/misc.ts+++ b/app/utils/misc.ts@@ -106,10 +106,13 @@ export function parseTextQuery(textQuery: string, identifier: string) {}export function removeAllTagsFromQuery(query: string) {- if (query) {+ if (!query) {+ return '';+ }+ if (query && query.indexOf('[') > -1) {return query.replace(/([+-?]\S+)/g, '').trim();}- return '';+ return query;}export function mergeWithExtractedTags(diff --git a/package.json b/package.jsonindex da909a457..d209a14bd 100644--- a/package.json+++ b/package.json@@ -22,6 +22,9 @@"email": "[email protected]","url": "https://www.tagspaces.org"},+ "config": {+ "platform": "1.0.59"+ },"scripts": {"browserslist:update": "npx browserslist@latest --update-db","bs": "yarn build && yarn start",@@ -81,11 +84,11 @@"paste-android-linux": "adb shell input text '$(xclip -selection c -o)'","paste-android-macos": "adb shell input text \"'$(pbpaste)'\"","playwright-show-trace": "npx playwright show-trace \"tests/test-reports/TST0813 - Delete file [web,minio,electron].zip\"",- "postinstall-cordova": "cross-env PD_PLATFORM=cordova yarn add @tagspaces/tagspaces-platforms",+ "postinstall-cordova": "cross-env PD_PLATFORM=cordova yarn upgrade @tagspaces/tagspaces-platforms@$npm_package_config_platform","postinstall-cordova-check": "cross-env PD_PLATFORM=cordova node scripts/postinstall.js",- "postinstall-node": "cross-env PD_PLATFORM=node yarn add @tagspaces/tagspaces-platforms",+ "postinstall-node": "cross-env PD_PLATFORM=node yarn upgrade @tagspaces/tagspaces-platforms@$npm_package_config_platform","postinstall-node-check": "cross-env PD_PLATFORM=node node scripts/postinstall.js",- "postinstall-web": "cross-env PD_PLATFORM=web yarn add @tagspaces/tagspaces-platforms",+ "postinstall-web": "cross-env PD_PLATFORM=web yarn upgrade @tagspaces/tagspaces-platforms@$npm_package_config_platform","postinstall-web-check": "cross-env PD_PLATFORM=web node scripts/postinstall.js","precommit": "lint-staged","prepare-cordova": "yarn install-ext-web && yarn postinstall-cordova-check && rimraf cordova/www/dist && rimraf cordova/www/node_modules && shx cp -rL app/node_modules cordova/www && shx cp LICENSE.txt cordova/www",@@ -152,7 +155,7 @@"@material-ui/icons": "^4.11.2","@material-ui/lab": "^4.0.0-alpha.57","@material-ui/pickers": "^3.2.10",- "@tagspaces/tagspaces-platforms": "1.0.56",+ "@tagspaces/tagspaces-platforms": "1.0.59","aws-amplify": "^3.3.27","aws-sdk": "^2.984.0","babel-polyfill": "^6.26.0",diff --git a/yarn.lock b/yarn.lockindex 390a4849f..db8a6e5b5 100644--- a/yarn.lock+++ b/yarn.lock@@ -3389,10 +3389,10 @@dependencies:defer-to-connect "^1.0.1"-"@tagspaces/[email protected]":- version "1.0.56"- resolved "https://registry.yarnpkg.com/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-1.0.56.tgz#f78b4610120a196429de7a959986bd390a687079"- integrity sha512-Xk1zZSOcAAHHuKW6PC8uCLvCHYM3yn//ybMP9J+nXAlBGXrnbfVTDv2lYJXyNKfsnxIKXCKucAE8YDFS02JO/Q==+"@tagspaces/[email protected]":+ version "1.0.59"+ resolved "https://registry.yarnpkg.com/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-1.0.59.tgz#1a5b0119d6fc1f6107d9fe5bc29d3a9602b2e7b9"+ integrity sha512-22gsOAcLzdHwvUhq2sa7eHc1ln2pK/AH9L3SwKOGzIhjSvRGhXfUOK+IBcPWHGF/d97WO5f487AreoMW9C0Xmw=="@testim/chrome-version@^1.0.7":version "1.0.7"