From 3f3ddf88203d1ef8043a157a720da704c10b1262 Mon Sep 17 00:00:00 2001 From: webviewer-ui <72055195+webviewer-ui@users.noreply.github.com> Date: Wed, 15 Mar 2023 01:14:02 -0700 Subject: [PATCH] [Misc] Office editor disable UI APIs (#6399) Co-authored-by: Kristian Hein --- src/apis/enableAnnotations.js | 7 +++++- src/helpers/createFeatureAPI.js | 40 ++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/apis/enableAnnotations.js b/src/apis/enableAnnotations.js index 8446e2894..1b4133463 100644 --- a/src/apis/enableAnnotations.js +++ b/src/apis/enableAnnotations.js @@ -1,6 +1,11 @@ import Feature from 'constants/feature'; +import { isOfficeEditorMode } from 'helpers/officeEditor'; import enableFeatures from './enableFeatures'; -export default store => () => { +export default (store) => () => { + if (isOfficeEditorMode()) { + console.warn('Office Editor doesn\'t support annotations'); + return; + } enableFeatures(store)([Feature.Annotations]); }; diff --git a/src/helpers/createFeatureAPI.js b/src/helpers/createFeatureAPI.js index a467bc976..b3f1ce910 100644 --- a/src/helpers/createFeatureAPI.js +++ b/src/helpers/createFeatureAPI.js @@ -12,6 +12,7 @@ import selectors from 'selectors'; import TabManager from 'helpers/TabManager'; import getHashParameters from './getHashParameters'; import DataElements from 'constants/dataElement'; +import { isOfficeEditorMode } from 'helpers/officeEditor'; // a higher order function that creates the enableFeatures and disableFeatures APIs export default (enable, store) => (features, priority = PRIORITY_TWO) => { @@ -65,6 +66,10 @@ export default (enable, store) => (features, priority = PRIORITY_TWO) => { 'toolsOverlay', ], fn: () => { + if (isOfficeEditorMode()) { + console.warn('Office Editor doesn\'t support annotations'); + return; + } if (enable) { core.showAnnotations(core.getAnnotationsList()); enableTools(store)(); @@ -98,12 +103,41 @@ export default (enable, store) => (features, priority = PRIORITY_TWO) => { }, [Feature.NotesPanel]: { dataElements: [ - 'annotationCommentButton', 'notesPanelButton', 'notesPanel', 'toggleNotesButton', ], }, + [Feature.InlineComment]: { + dataElements: [ + DataElements.INLINE_COMMENT_POPUP, + DataElements.INLINE_COMMENT_POPUP_EXPAND_BUTTON, + DataElements.INLINE_COMMENT_POPUP_CLOSE_BUTTON, + ], + fn: () => { + if (enable) { + store.dispatch(actions.setEnableRightClickAnnotationPopup(true)); + } + }, + }, + [Feature.RightClickAnnotationPopup]: { + dataElements: [ + // no elements: enabling this will open the popup on right click + // disabling this will open the popup on left click + ], + fn: () => { + if (enable) { + store.dispatch(actions.setEnableRightClickAnnotationPopup(true)); + } else { + store.dispatch(actions.disableElements([ + DataElements.INLINE_COMMENT_POPUP, + DataElements.INLINE_COMMENT_POPUP_EXPAND_BUTTON, + DataElements.INLINE_COMMENT_POPUP_CLOSE_BUTTON, + ], PRIORITY_TWO)); + store.dispatch(actions.setEnableRightClickAnnotationPopup(false)); + } + }, + }, [Feature.Print]: { dataElements: ['printButton', 'printModal'], fn: () => { @@ -245,6 +279,10 @@ export default (enable, store) => (features, priority = PRIORITY_TWO) => { }, [Feature.MultiTab]: { fn: () => { + if (isOfficeEditorMode()) { + return; + } + if (enable) { const state = store.getState(); // if already in multi-tab mode do not recreate TabManager