Skip to content

Commit

Permalink
[Misc] Office editor disable UI APIs (#6399)
Browse files Browse the repository at this point in the history
Co-authored-by: Kristian Hein <[email protected]>
  • Loading branch information
webviewer-ui and kristianhein committed Mar 15, 2023
1 parent 973689f commit 3f3ddf8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/apis/enableAnnotations.js
Original file line number Diff line number Diff line change
@@ -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]);
};
40 changes: 39 additions & 1 deletion src/helpers/createFeatureAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)();
Expand Down Expand Up @@ -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: () => {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3f3ddf8

Please sign in to comment.