TagSpaces is an offline, open source, document manager with tagging support
add eventID to sendMessageToHost && fix html edit menus (#1874)
Stanimir98b787d28157
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex 935abe305..2dc76e171 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -26,6 +26,7 @@ import React, {} from 'react';import { connect } from 'react-redux';import { bindActionCreators } from 'redux';+import { getUuid } from '@tagspaces/tagspaces-common/utils-io';import { GlobalHotKeys } from 'react-hotkeys';import fscreen from 'fscreen';import Button from '@mui/material/Button';@@ -261,6 +262,7 @@ function EntryContainer(props: Props) {HTMLDivElement>(null);const fileChanged = useRef<boolean>(false);+ const eventID = useRef<string>(getUuid());const firstRender = useFirstRender();useEventListener('message', e => {@@ -268,7 +270,9 @@ function EntryContainer(props: Props) {// console.log(e.data);try {const dataObj = JSON.parse(e.data);- handleMessage(dataObj);+ if (dataObj.eventID === eventID.current) {+ handleMessage(dataObj);+ }} catch (ex) {console.debug('useEventListener message:' + e.data + ' parse error:',@@ -1421,6 +1425,7 @@ function EntryContainer(props: Props) {fileViewerContainer={fileViewerContainer}toggleFullScreen={toggleFullScreen}currentTheme={settings.currentTheme}+ eventID={eventID.current}/></Split>);diff --git a/app/components/FileView.tsx b/app/components/FileView.tsxindex a9b345e30..6918708ad 100644--- a/app/components/FileView.tsx+++ b/app/components/FileView.tsx@@ -38,6 +38,7 @@ interface Props {height?: string;theme: any;currentTheme: string;+ eventID: string;}function FileView(props: Props) {@@ -50,7 +51,8 @@ function FileView(props: Props) {toggleFullScreen,searchQuery,height,- currentTheme+ currentTheme,+ eventID} = props; // .openedFiles[0];useEventListener('toggle-resume', () => {@@ -93,6 +95,7 @@ function FileView(props: Props) {bgndColor.startsWith('#') ? bgndColor : rgbToHex(bgndColor));+ const event = eventID ? '&eventID=' + eventID : '';const extQuery = searchQuery.textQuery? '&query=' + encodeURIComponent(searchQuery.textQuery): '';@@ -108,6 +111,7 @@ function FileView(props: Props) {locale +theming +extQuery ++ event +'&edit=true' +(openedFile.shouldReload === true ? '&t=' + new Date().getTime() : '');// } else if (!currentEntry.isFile) { // TODO needed for loading folder's default html@@ -120,6 +124,7 @@ function FileView(props: Props) {locale +theming +extQuery ++ event +(openedFile.shouldReload === true ? '&t=' + new Date().getTime() : '');}} else {@@ -165,7 +170,7 @@ function FileView(props: Props) {src={fileOpenerURL}allowFullScreensandbox="allow-same-origin allow-scripts allow-modals allow-downloads"- id="FileViewer"+ id={'FileViewer' + eventID}/>)}</div>diff --git a/app/components/dialogs/FilePreviewDialog.tsx b/app/components/dialogs/FilePreviewDialog.tsxindex f8e093fcd..8741fd4d2 100644--- a/app/components/dialogs/FilePreviewDialog.tsx+++ b/app/components/dialogs/FilePreviewDialog.tsx@@ -16,7 +16,8 @@**/-import React, { MutableRefObject, useEffect, useRef, useState } from 'react';+import React, { MutableRefObject, useRef } from 'react';+import { getUuid } from '@tagspaces/tagspaces-common/utils-io';import DialogContent from '@mui/material/DialogContent';import DialogTitle from '@mui/material/DialogTitle';import Dialog from '@mui/material/Dialog';@@ -58,6 +59,7 @@ function FilePreviewDialog(props: Props) {const fileViewerContainer: MutableRefObject<HTMLDivElement> = useRef<HTMLDivElement>(null);+ const eventID = useRef<string>(getUuid());const openedFile: OpenedEntry = fsEntry? findExtensionsForEntry(@@ -73,7 +75,9 @@ function FilePreviewDialog(props: Props) {// console.log(e.data);try {const dataObj = JSON.parse(e.data);- handleMessage(dataObj);+ if (dataObj.eventID === eventID.current) {+ handleMessage(dataObj);+ }} catch (ex) {console.debug('useEventListener message:' + e.data + ' parse error:',@@ -202,6 +206,7 @@ function FilePreviewDialog(props: Props) {fileViewerContainer={fileViewerContainer}height={'90%'}currentTheme={props.currentTheme}+ eventID={eventID.current}/></DialogContent></Dialog>diff --git a/app/package.json b/app/package.jsonindex d9a38fc10..9f59a7083 100644--- a/app/package.json+++ b/app/package.json@@ -13,11 +13,11 @@"license": "AGPL-3.0","scripts": {},"webDependencies": {- "@tagspaces/extensions": "1.0.71"+ "@tagspaces/extensions": "1.0.72"},"nodeDependencies": {"@tagspaces/tagspaces-ws": "2.1.18",- "@tagspaces/extensions": "1.0.71",+ "@tagspaces/extensions": "1.0.72","sharp": "0.31.3"}}