2019-06-13 02:40:58 +08:00
|
|
|
import React, { PureComponent } from 'react';
|
2017-06-04 10:40:14 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2022-04-05 22:49:13 +08:00
|
|
|
import WhiteboardContainer from '/imports/ui/components/whiteboard/container';
|
2018-12-05 19:00:12 +08:00
|
|
|
import { HUNDRED_PERCENT, MAX_PERCENT } from '/imports/utils/slideCalcUtils';
|
2022-08-17 23:23:48 +08:00
|
|
|
import { SPACE } from '/imports/utils/keyCodes';
|
2020-05-26 04:00:13 +08:00
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2020-07-16 00:44:59 +08:00
|
|
|
import { toast } from 'react-toastify';
|
2022-02-05 05:07:57 +08:00
|
|
|
import { Session } from 'meteor/session';
|
2019-02-14 20:03:25 +08:00
|
|
|
import PresentationToolbarContainer from './presentation-toolbar/container';
|
2022-06-12 23:53:43 +08:00
|
|
|
import PresentationMenu from './presentation-menu/container';
|
2023-04-20 19:48:43 +08:00
|
|
|
import DownloadPresentationButton from './download-presentation-button/component';
|
2021-11-09 01:28:22 +08:00
|
|
|
import Styled from './styles';
|
2022-02-15 22:42:02 +08:00
|
|
|
import FullscreenService from '/imports/ui/components/common/fullscreen-button/service';
|
2022-02-15 22:51:51 +08:00
|
|
|
import Icon from '/imports/ui/components/common/icon/component';
|
2021-02-08 19:50:47 +08:00
|
|
|
import PollingContainer from '/imports/ui/components/polling/container';
|
2021-07-17 03:54:23 +08:00
|
|
|
import { ACTIONS, LAYOUT_TYPE } from '../layout/enums';
|
2021-08-04 19:42:38 +08:00
|
|
|
import DEFAULT_VALUES from '../layout/defaultValues';
|
2022-01-26 00:56:52 +08:00
|
|
|
import { colorContentBackground } from '/imports/ui/stylesheets/styled-components/palette';
|
2021-12-06 20:18:23 +08:00
|
|
|
import browserInfo from '/imports/utils/browserInfo';
|
2022-05-24 01:09:50 +08:00
|
|
|
import { addNewAlert } from '../screenreader-alert/service';
|
2023-08-10 00:26:42 +08:00
|
|
|
import { debounce } from '/imports/utils/debounce';
|
2023-12-16 01:39:12 +08:00
|
|
|
import { throttle } from '/imports/utils/throttle';
|
2019-03-12 00:21:12 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
presentationLabel: {
|
|
|
|
id: 'app.presentationUploder.title',
|
|
|
|
description: 'presentation area element label',
|
|
|
|
},
|
2019-05-10 01:57:06 +08:00
|
|
|
changeNotification: {
|
|
|
|
id: 'app.presentation.notificationLabel',
|
|
|
|
description: 'label displayed in toast when presentation switches',
|
|
|
|
},
|
2020-08-10 20:51:06 +08:00
|
|
|
downloadLabel: {
|
2020-09-02 21:30:44 +08:00
|
|
|
id: 'app.presentation.downloadLabel',
|
|
|
|
description: 'label for downloadable presentations',
|
2020-08-28 03:09:07 +08:00
|
|
|
},
|
2020-08-20 09:48:10 +08:00
|
|
|
slideContentStart: {
|
|
|
|
id: 'app.presentation.startSlideContent',
|
|
|
|
description: 'Indicate the slide content start',
|
|
|
|
},
|
|
|
|
slideContentEnd: {
|
|
|
|
id: 'app.presentation.endSlideContent',
|
|
|
|
description: 'Indicate the slide content end',
|
|
|
|
},
|
2022-01-24 01:00:05 +08:00
|
|
|
slideContentChanged: {
|
|
|
|
id: 'app.presentation.changedSlideContent',
|
|
|
|
description: 'Indicate the slide content has changed',
|
|
|
|
},
|
2020-08-20 09:48:10 +08:00
|
|
|
noSlideContent: {
|
|
|
|
id: 'app.presentation.emptySlideContent',
|
|
|
|
description: 'No content available for slide',
|
2020-08-10 20:51:06 +08:00
|
|
|
},
|
2019-03-12 00:21:12 +08:00
|
|
|
});
|
2017-07-29 08:29:40 +08:00
|
|
|
|
2021-12-06 20:18:23 +08:00
|
|
|
const { isSafari } = browserInfo;
|
2023-08-01 10:45:13 +08:00
|
|
|
const FULLSCREEN_CHANGE_EVENT = isSafari
|
2023-08-01 22:01:27 +08:00
|
|
|
? 'webkitfullscreenchange'
|
|
|
|
: 'fullscreenchange';
|
2019-07-24 03:56:39 +08:00
|
|
|
|
2023-12-16 01:39:12 +08:00
|
|
|
const PAN_ZOOM_INTERVAL = Meteor.settings.public.presentation.panZoomInterval || 200;
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const getToolbarHeight = () => {
|
|
|
|
let height = 0;
|
|
|
|
const toolbarEl = document.getElementById('presentationToolbarWrapper');
|
|
|
|
if (toolbarEl) {
|
|
|
|
const { clientHeight } = toolbarEl;
|
|
|
|
height = clientHeight;
|
|
|
|
}
|
|
|
|
return height;
|
|
|
|
};
|
|
|
|
|
2021-06-09 21:49:59 +08:00
|
|
|
class Presentation extends PureComponent {
|
2017-07-29 08:29:40 +08:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
2017-03-24 05:52:36 +08:00
|
|
|
this.state = {
|
2021-06-09 21:49:59 +08:00
|
|
|
presentationWidth: 0,
|
|
|
|
presentationHeight: 0,
|
2018-08-23 01:53:04 +08:00
|
|
|
zoom: 100,
|
2019-07-27 00:48:51 +08:00
|
|
|
isFullscreen: false,
|
2022-05-16 10:35:17 +08:00
|
|
|
tldrawAPI: null,
|
2022-08-15 06:49:39 +08:00
|
|
|
isPanning: false,
|
2022-11-23 23:05:57 +08:00
|
|
|
tldrawIsMounting: true,
|
2023-04-19 02:03:22 +08:00
|
|
|
isToolbarVisible: true,
|
2023-05-09 21:58:40 +08:00
|
|
|
hadPresentation: false,
|
2017-03-24 05:52:36 +08:00
|
|
|
};
|
2017-07-29 08:29:40 +08:00
|
|
|
|
2020-03-24 10:21:09 +08:00
|
|
|
this.currentPresentationToastId = null;
|
|
|
|
|
2017-07-29 08:29:40 +08:00
|
|
|
this.getSvgRef = this.getSvgRef.bind(this);
|
2023-08-10 00:26:42 +08:00
|
|
|
this.zoomChanger = debounce(this.zoomChanger.bind(this), 200);
|
2019-07-18 08:30:28 +08:00
|
|
|
this.updateLocalPosition = this.updateLocalPosition.bind(this);
|
2023-12-16 01:39:12 +08:00
|
|
|
this.panAndZoomChanger = throttle(this.panAndZoomChanger.bind(this), PAN_ZOOM_INTERVAL);
|
2018-09-25 20:47:49 +08:00
|
|
|
this.fitToWidthHandler = this.fitToWidthHandler.bind(this);
|
2019-07-27 00:48:51 +08:00
|
|
|
this.onFullscreenChange = this.onFullscreenChange.bind(this);
|
2020-06-20 13:46:10 +08:00
|
|
|
this.getPresentationSizesAvailable = this.getPresentationSizesAvailable.bind(this);
|
2023-08-10 00:26:42 +08:00
|
|
|
this.handleResize = debounce(this.handleResize.bind(this), 200);
|
2022-05-16 10:35:17 +08:00
|
|
|
this.setTldrawAPI = this.setTldrawAPI.bind(this);
|
2022-08-23 00:55:44 +08:00
|
|
|
this.setIsPanning = this.setIsPanning.bind(this);
|
2023-04-19 02:03:22 +08:00
|
|
|
this.setIsToolbarVisible = this.setIsToolbarVisible.bind(this);
|
2022-08-23 00:55:44 +08:00
|
|
|
this.handlePanShortcut = this.handlePanShortcut.bind(this);
|
2022-06-12 23:53:43 +08:00
|
|
|
this.renderPresentationMenu = this.renderPresentationMenu.bind(this);
|
2020-06-20 13:46:10 +08:00
|
|
|
|
2019-07-30 23:03:29 +08:00
|
|
|
this.onResize = () => setTimeout(this.handleResize.bind(this), 0);
|
2023-10-28 04:29:36 +08:00
|
|
|
this.renderCurrentPresentationToast = this.renderCurrentPresentationToast.bind(this);
|
2021-08-24 05:04:16 +08:00
|
|
|
this.setPresentationRef = this.setPresentationRef.bind(this);
|
2022-11-23 23:05:57 +08:00
|
|
|
this.setTldrawIsMounting = this.setTldrawIsMounting.bind(this);
|
2022-02-05 05:07:57 +08:00
|
|
|
Session.set('componentPresentationWillUnmount', false);
|
2017-07-29 08:29:40 +08:00
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
static getDerivedStateFromProps(props, state) {
|
|
|
|
const { prevProps } = state;
|
|
|
|
const stateChange = { prevProps: props };
|
2019-05-10 01:44:54 +08:00
|
|
|
|
2023-08-01 10:45:13 +08:00
|
|
|
if (
|
2023-10-28 04:29:36 +08:00
|
|
|
props.userIsPresenter
|
|
|
|
&& (!prevProps || !prevProps.userIsPresenter)
|
|
|
|
&& props.currentSlide
|
|
|
|
&& props.slidePosition
|
2023-08-01 10:45:13 +08:00
|
|
|
) {
|
2023-10-28 04:29:36 +08:00
|
|
|
let potentialZoom = 100 / (props.slidePosition.viewBoxWidth / props.slidePosition.width);
|
2023-08-01 10:45:13 +08:00
|
|
|
potentialZoom = Math.max(
|
|
|
|
HUNDRED_PERCENT,
|
2023-10-28 04:29:36 +08:00
|
|
|
Math.min(MAX_PERCENT, potentialZoom),
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
2019-07-18 08:30:28 +08:00
|
|
|
stateChange.zoom = potentialZoom;
|
2019-05-10 01:44:54 +08:00
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
if (!prevProps) return stateChange;
|
|
|
|
|
|
|
|
// When presenter is changed or slide changed we reset localPosition
|
2023-08-01 10:45:13 +08:00
|
|
|
if (
|
2023-10-28 04:29:36 +08:00
|
|
|
prevProps.currentSlide?.id !== props.currentSlide?.id
|
|
|
|
|| prevProps.userIsPresenter !== props.userIsPresenter
|
2023-08-01 10:45:13 +08:00
|
|
|
) {
|
2019-07-18 08:30:28 +08:00
|
|
|
stateChange.localPosition = undefined;
|
2019-03-20 03:50:08 +08:00
|
|
|
}
|
2019-07-18 08:30:28 +08:00
|
|
|
|
|
|
|
return stateChange;
|
2019-03-20 03:50:08 +08:00
|
|
|
}
|
|
|
|
|
2019-06-13 02:40:58 +08:00
|
|
|
componentDidMount() {
|
|
|
|
this.getInitialPresentationSizes();
|
2023-08-01 10:45:13 +08:00
|
|
|
this.refPresentationContainer.addEventListener(
|
2023-08-01 22:01:27 +08:00
|
|
|
'keydown',
|
2023-10-28 04:29:36 +08:00
|
|
|
this.handlePanShortcut,
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
|
|
|
this.refPresentationContainer.addEventListener(
|
2023-08-01 22:01:27 +08:00
|
|
|
'keyup',
|
2023-10-28 04:29:36 +08:00
|
|
|
this.handlePanShortcut,
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
|
|
|
this.refPresentationContainer.addEventListener(
|
|
|
|
FULLSCREEN_CHANGE_EVENT,
|
2023-10-28 04:29:36 +08:00
|
|
|
this.onFullscreenChange,
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
2020-04-23 22:07:44 +08:00
|
|
|
window.addEventListener('resize', this.onResize, false);
|
2020-01-17 21:20:03 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const {
|
2023-08-01 10:45:13 +08:00
|
|
|
currentSlide,
|
|
|
|
slidePosition,
|
2023-10-18 00:35:48 +08:00
|
|
|
totalPages,
|
2023-08-01 10:45:13 +08:00
|
|
|
layoutContextDispatch,
|
|
|
|
currentPresentationId,
|
2021-05-18 04:25:07 +08:00
|
|
|
} = this.props;
|
2020-09-02 21:30:44 +08:00
|
|
|
|
2023-05-09 21:58:40 +08:00
|
|
|
if (currentPresentationId) {
|
|
|
|
this.setState({
|
2023-08-01 10:45:13 +08:00
|
|
|
hadPresentation: true,
|
2023-05-09 21:58:40 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-08-24 05:04:16 +08:00
|
|
|
if (currentSlide) {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_NUM_CURRENT_SLIDE,
|
|
|
|
value: currentSlide.num,
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_CURRENT_SLIDE_SIZE,
|
|
|
|
value: {
|
|
|
|
width: slidePosition.width,
|
|
|
|
height: slidePosition.height,
|
|
|
|
},
|
|
|
|
});
|
2023-04-05 23:37:56 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_SLIDES_LENGTH,
|
2023-10-18 00:35:48 +08:00
|
|
|
value: totalPages,
|
2023-04-13 21:56:54 +08:00
|
|
|
});
|
2021-08-24 05:04:16 +08:00
|
|
|
}
|
2019-06-13 02:40:58 +08:00
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
componentDidUpdate(prevProps) {
|
2020-01-17 21:20:03 +08:00
|
|
|
const {
|
|
|
|
slidePosition,
|
2022-02-11 22:30:35 +08:00
|
|
|
presentationIsOpen,
|
2020-05-12 20:58:14 +08:00
|
|
|
currentSlide,
|
|
|
|
publishedPoll,
|
2022-02-11 22:30:35 +08:00
|
|
|
setPresentationIsOpen,
|
2020-05-12 20:58:14 +08:00
|
|
|
restoreOnUpdate,
|
2020-04-23 22:07:44 +08:00
|
|
|
layoutContextDispatch,
|
2020-08-10 20:51:06 +08:00
|
|
|
userIsPresenter,
|
2021-05-25 02:35:37 +08:00
|
|
|
presentationBounds,
|
2021-08-05 15:26:03 +08:00
|
|
|
numCameras,
|
2022-01-24 01:00:05 +08:00
|
|
|
intl,
|
2023-10-18 00:35:48 +08:00
|
|
|
totalPages,
|
2023-04-13 21:56:54 +08:00
|
|
|
currentPresentationId,
|
2023-08-05 00:41:42 +08:00
|
|
|
fitToWidth,
|
2023-10-03 21:24:38 +08:00
|
|
|
isDefaultPresentation,
|
2023-10-03 03:16:46 +08:00
|
|
|
presentationIsDownloadable,
|
2020-01-17 21:20:03 +08:00
|
|
|
} = this.props;
|
2023-03-10 19:30:46 +08:00
|
|
|
const {
|
2023-08-01 10:45:13 +08:00
|
|
|
presentationWidth,
|
|
|
|
presentationHeight,
|
|
|
|
zoom,
|
|
|
|
isPanning,
|
|
|
|
presentationId,
|
|
|
|
hadPresentation,
|
2023-03-10 19:30:46 +08:00
|
|
|
} = this.state;
|
2021-05-25 02:35:37 +08:00
|
|
|
const {
|
2021-08-05 15:26:03 +08:00
|
|
|
numCameras: prevNumCameras,
|
2021-05-25 02:35:37 +08:00
|
|
|
presentationBounds: prevPresentationBounds,
|
|
|
|
} = prevProps;
|
2020-06-09 11:09:46 +08:00
|
|
|
|
2021-08-05 15:26:03 +08:00
|
|
|
if (numCameras !== prevNumCameras) {
|
2020-06-09 11:09:46 +08:00
|
|
|
this.onResize();
|
|
|
|
}
|
2020-03-25 20:52:23 +08:00
|
|
|
|
2023-10-18 00:35:48 +08:00
|
|
|
if (totalPages !== prevProps.totalPages) {
|
2023-04-05 23:37:56 +08:00
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_SLIDES_LENGTH,
|
2023-10-18 00:35:48 +08:00
|
|
|
value: totalPages,
|
2023-04-13 21:56:54 +08:00
|
|
|
});
|
2023-04-05 23:37:56 +08:00
|
|
|
}
|
|
|
|
|
2022-01-25 01:52:24 +08:00
|
|
|
if (
|
2023-10-28 04:29:36 +08:00
|
|
|
currentSlide?.num != null
|
|
|
|
&& prevProps?.currentSlide?.num != null
|
|
|
|
&& currentSlide?.num !== prevProps.currentSlide?.num
|
2022-01-25 01:52:24 +08:00
|
|
|
) {
|
2023-08-01 10:45:13 +08:00
|
|
|
addNewAlert(
|
|
|
|
intl.formatMessage(intlMessages.slideContentChanged, {
|
|
|
|
0: currentSlide.num,
|
2023-10-28 04:29:36 +08:00
|
|
|
}),
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
2022-01-24 01:00:05 +08:00
|
|
|
}
|
|
|
|
|
2023-10-03 03:16:46 +08:00
|
|
|
if (currentPresentationId) {
|
|
|
|
const downloadableOn = !prevProps?.presentationIsDownloadable && presentationIsDownloadable;
|
2021-05-18 04:25:07 +08:00
|
|
|
|
2023-08-01 10:45:13 +08:00
|
|
|
const shouldCloseToast = !(
|
2023-10-03 03:16:46 +08:00
|
|
|
presentationIsDownloadable && !userIsPresenter
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
2021-05-18 04:25:07 +08:00
|
|
|
|
|
|
|
if (
|
2023-10-03 03:16:46 +08:00
|
|
|
prevProps?.currentPresentationId !== currentPresentationId
|
2023-10-28 04:29:36 +08:00
|
|
|
|| (downloadableOn && !userIsPresenter)
|
2021-05-18 04:25:07 +08:00
|
|
|
) {
|
|
|
|
if (this.currentPresentationToastId) {
|
|
|
|
toast.update(this.currentPresentationToastId, {
|
|
|
|
autoClose: shouldCloseToast,
|
|
|
|
render: this.renderCurrentPresentationToast(),
|
|
|
|
});
|
|
|
|
} else {
|
2023-08-01 10:45:13 +08:00
|
|
|
this.currentPresentationToastId = toast(
|
|
|
|
this.renderCurrentPresentationToast(),
|
|
|
|
{
|
|
|
|
onClose: () => {
|
|
|
|
this.currentPresentationToastId = null;
|
|
|
|
},
|
|
|
|
autoClose: shouldCloseToast,
|
2023-08-01 22:01:27 +08:00
|
|
|
className: 'actionToast currentPresentationToast',
|
2023-10-28 04:29:36 +08:00
|
|
|
},
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
2021-05-18 04:25:07 +08:00
|
|
|
}
|
|
|
|
}
|
2020-08-10 20:51:06 +08:00
|
|
|
|
2023-10-03 03:16:46 +08:00
|
|
|
const downloadableOff = prevProps?.presentationIsDownloadable && !presentationIsDownloadable;
|
2020-08-10 20:51:06 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
if (this.currentPresentationToastId && downloadableOff) {
|
2020-08-10 20:51:06 +08:00
|
|
|
toast.update(this.currentPresentationToastId, {
|
2021-05-18 04:25:07 +08:00
|
|
|
autoClose: true,
|
2020-07-16 00:44:59 +08:00
|
|
|
render: this.renderCurrentPresentationToast(),
|
|
|
|
});
|
|
|
|
}
|
2022-03-11 22:57:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (prevProps?.slidePosition && slidePosition) {
|
|
|
|
const { width: prevWidth, height: prevHeight } = prevProps.slidePosition;
|
|
|
|
const { width: currWidth, height: currHeight } = slidePosition;
|
|
|
|
|
|
|
|
if (prevWidth !== currWidth || prevHeight !== currHeight) {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_CURRENT_SLIDE_SIZE,
|
|
|
|
value: {
|
|
|
|
width: currWidth,
|
|
|
|
height: currHeight,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2023-04-14 02:25:31 +08:00
|
|
|
const presentationChanged = presentationId !== currentPresentationId;
|
2020-03-24 10:21:09 +08:00
|
|
|
|
2023-08-01 10:45:13 +08:00
|
|
|
if (
|
2023-10-28 04:29:36 +08:00
|
|
|
!presentationIsOpen
|
|
|
|
&& restoreOnUpdate
|
|
|
|
&& (currentSlide || presentationChanged)
|
2023-08-01 10:45:13 +08:00
|
|
|
) {
|
2021-05-18 04:25:07 +08:00
|
|
|
const slideChanged = currentSlide.id !== prevProps.currentSlide.id;
|
2023-10-28 04:29:36 +08:00
|
|
|
const positionChanged = slidePosition.viewBoxHeight
|
|
|
|
!== prevProps.slidePosition.viewBoxHeight
|
|
|
|
|| slidePosition.viewBoxWidth !== prevProps.slidePosition.viewBoxWidth;
|
2021-05-18 04:25:07 +08:00
|
|
|
const pollPublished = publishedPoll && !prevProps.publishedPoll;
|
2023-08-01 10:45:13 +08:00
|
|
|
if (
|
2023-10-28 04:29:36 +08:00
|
|
|
slideChanged
|
|
|
|
|| positionChanged
|
|
|
|
|| pollPublished
|
|
|
|
|| (presentationChanged && (hadPresentation || !isDefaultPresentation))
|
2023-08-01 10:45:13 +08:00
|
|
|
) {
|
2022-02-11 22:30:35 +08:00
|
|
|
setPresentationIsOpen(layoutContextDispatch, !presentationIsOpen);
|
2021-05-18 04:25:07 +08:00
|
|
|
}
|
2020-05-12 20:58:14 +08:00
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
|
2023-05-09 21:58:40 +08:00
|
|
|
if (presentationChanged) {
|
|
|
|
this.setState({
|
|
|
|
presentationId: currentPresentationId,
|
2023-08-01 10:45:13 +08:00
|
|
|
hadPresentation: true,
|
2023-05-09 21:58:40 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-08-01 10:45:13 +08:00
|
|
|
if (
|
2023-10-28 04:29:36 +08:00
|
|
|
presentationBounds !== prevPresentationBounds
|
|
|
|
|| (!presentationWidth && !presentationHeight)
|
|
|
|
) this.onResize();
|
2022-04-06 21:44:09 +08:00
|
|
|
} else if (slidePosition) {
|
|
|
|
const { width: currWidth, height: currHeight } = slidePosition;
|
|
|
|
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_CURRENT_SLIDE_SIZE,
|
|
|
|
value: {
|
|
|
|
width: currWidth,
|
|
|
|
height: currHeight,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_PRESENTATION_NUM_CURRENT_SLIDE,
|
|
|
|
value: currentSlide.num,
|
|
|
|
});
|
2020-05-12 20:58:14 +08:00
|
|
|
}
|
2022-08-24 02:19:17 +08:00
|
|
|
|
2023-08-01 10:45:13 +08:00
|
|
|
if (
|
2023-10-28 04:29:36 +08:00
|
|
|
(zoom <= HUNDRED_PERCENT && isPanning && !fitToWidth)
|
|
|
|
|| (!userIsPresenter && prevProps.userIsPresenter)
|
2023-08-01 10:45:13 +08:00
|
|
|
) {
|
2022-08-24 02:19:17 +08:00
|
|
|
this.setIsPanning();
|
|
|
|
}
|
2019-03-20 03:50:08 +08:00
|
|
|
}
|
|
|
|
|
2017-03-24 05:52:36 +08:00
|
|
|
componentWillUnmount() {
|
2022-02-05 05:07:57 +08:00
|
|
|
Session.set('componentPresentationWillUnmount', true);
|
2021-08-12 00:19:24 +08:00
|
|
|
const { fullscreenContext, layoutContextDispatch } = this.props;
|
|
|
|
|
2020-04-23 22:07:44 +08:00
|
|
|
window.removeEventListener('resize', this.onResize, false);
|
2023-08-01 10:45:13 +08:00
|
|
|
this.refPresentationContainer.removeEventListener(
|
|
|
|
FULLSCREEN_CHANGE_EVENT,
|
2023-10-28 04:29:36 +08:00
|
|
|
this.onFullscreenChange,
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
|
|
|
this.refPresentationContainer.removeEventListener(
|
2023-08-01 22:01:27 +08:00
|
|
|
'keydown',
|
2023-10-28 04:29:36 +08:00
|
|
|
this.handlePanShortcut,
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
|
|
|
this.refPresentationContainer.removeEventListener(
|
2023-08-01 22:01:27 +08:00
|
|
|
'keyup',
|
2023-10-28 04:29:36 +08:00
|
|
|
this.handlePanShortcut,
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
2021-08-12 00:19:24 +08:00
|
|
|
|
|
|
|
if (fullscreenContext) {
|
|
|
|
layoutContextDispatch({
|
|
|
|
type: ACTIONS.SET_FULLSCREEN_ELEMENT,
|
|
|
|
value: {
|
|
|
|
element: '',
|
|
|
|
group: '',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2017-03-24 05:52:36 +08:00
|
|
|
}
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
handlePanShortcut(e) {
|
|
|
|
const { userIsPresenter } = this.props;
|
|
|
|
const { isPanning } = this.state;
|
|
|
|
if (e.keyCode === SPACE && userIsPresenter) {
|
|
|
|
switch (e.type) {
|
|
|
|
case 'keyup':
|
|
|
|
return isPanning && this.setIsPanning();
|
|
|
|
case 'keydown':
|
|
|
|
return !isPanning && this.setIsPanning();
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2022-05-16 10:35:17 +08:00
|
|
|
}
|
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
handleResize() {
|
|
|
|
const presentationSizes = this.getPresentationSizesAvailable();
|
|
|
|
if (Object.keys(presentationSizes).length > 0) {
|
|
|
|
// updating the size of the space available for the slide
|
2022-02-05 05:07:57 +08:00
|
|
|
if (!Session.get('componentPresentationWillUnmount')) {
|
|
|
|
this.setState({
|
|
|
|
presentationHeight: presentationSizes.presentationHeight,
|
|
|
|
presentationWidth: presentationSizes.presentationWidth,
|
|
|
|
});
|
|
|
|
}
|
2021-05-18 04:25:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-27 00:48:51 +08:00
|
|
|
onFullscreenChange() {
|
|
|
|
const { isFullscreen } = this.state;
|
2023-08-01 10:45:13 +08:00
|
|
|
const newIsFullscreen = FullscreenService.isFullScreen(
|
2023-10-28 04:29:36 +08:00
|
|
|
this.refPresentationContainer,
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
2019-07-27 00:48:51 +08:00
|
|
|
if (isFullscreen !== newIsFullscreen) {
|
|
|
|
this.setState({ isFullscreen: newIsFullscreen });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
setTldrawAPI(api) {
|
|
|
|
this.setState({
|
|
|
|
tldrawAPI: api,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setTldrawIsMounting(value) {
|
|
|
|
this.setState({ tldrawIsMounting: value });
|
|
|
|
}
|
|
|
|
|
|
|
|
setIsPanning() {
|
|
|
|
this.setState((prevState) => ({
|
|
|
|
isPanning: !prevState.isPanning,
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2023-04-19 02:03:22 +08:00
|
|
|
setIsToolbarVisible(isVisible) {
|
|
|
|
this.setState({
|
|
|
|
isToolbarVisible: isVisible,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-08-24 05:04:16 +08:00
|
|
|
setPresentationRef(ref) {
|
|
|
|
this.refPresentationContainer = ref;
|
|
|
|
}
|
|
|
|
|
2017-07-29 08:29:40 +08:00
|
|
|
// returns a ref to the svg element, which is required by a WhiteboardOverlay
|
|
|
|
// to transform screen coordinates to svg coordinate system
|
|
|
|
getSvgRef() {
|
|
|
|
return this.svggroup;
|
|
|
|
}
|
2017-04-28 06:18:53 +08:00
|
|
|
|
2017-09-18 09:58:37 +08:00
|
|
|
getPresentationSizesAvailable() {
|
2021-05-25 02:35:37 +08:00
|
|
|
const {
|
|
|
|
presentationBounds,
|
2021-06-09 21:49:59 +08:00
|
|
|
presentationAreaSize: newPresentationAreaSize,
|
2021-05-25 02:35:37 +08:00
|
|
|
} = this.props;
|
2020-06-20 13:46:10 +08:00
|
|
|
const presentationSizes = {
|
2021-06-09 21:49:59 +08:00
|
|
|
presentationWidth: 0,
|
|
|
|
presentationHeight: 0,
|
2020-06-20 13:46:10 +08:00
|
|
|
};
|
2020-07-16 00:44:59 +08:00
|
|
|
|
2021-08-05 12:22:07 +08:00
|
|
|
if (newPresentationAreaSize) {
|
2023-10-28 04:29:36 +08:00
|
|
|
presentationSizes.presentationWidth = newPresentationAreaSize.presentationAreaWidth;
|
|
|
|
presentationSizes.presentationHeight = newPresentationAreaSize.presentationAreaHeight
|
|
|
|
- (getToolbarHeight() || 0);
|
2021-06-09 21:49:59 +08:00
|
|
|
return presentationSizes;
|
|
|
|
}
|
2021-05-25 02:35:37 +08:00
|
|
|
|
2021-06-09 21:49:59 +08:00
|
|
|
presentationSizes.presentationWidth = presentationBounds.width;
|
|
|
|
presentationSizes.presentationHeight = presentationBounds.height;
|
2017-09-18 09:58:37 +08:00
|
|
|
return presentationSizes;
|
2017-09-06 09:36:15 +08:00
|
|
|
}
|
|
|
|
|
2017-09-18 09:58:37 +08:00
|
|
|
getInitialPresentationSizes() {
|
2021-06-09 21:49:59 +08:00
|
|
|
// determining the presentationWidth and presentationHeight (available
|
2019-07-18 08:30:28 +08:00
|
|
|
// space for the svg) on the initial load
|
2018-10-19 01:03:11 +08:00
|
|
|
|
2017-09-18 09:58:37 +08:00
|
|
|
const presentationSizes = this.getPresentationSizesAvailable();
|
|
|
|
if (Object.keys(presentationSizes).length > 0) {
|
|
|
|
// setting the state of the available space for the svg
|
2017-10-26 07:11:06 +08:00
|
|
|
this.setState({
|
2021-06-09 21:49:59 +08:00
|
|
|
presentationHeight: presentationSizes.presentationHeight,
|
|
|
|
presentationWidth: presentationSizes.presentationWidth,
|
2017-10-26 07:11:06 +08:00
|
|
|
});
|
2017-09-06 09:36:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
zoomChanger(zoom) {
|
2023-11-10 21:51:29 +08:00
|
|
|
let boundZoom = parseInt(zoom);
|
|
|
|
if (boundZoom < HUNDRED_PERCENT) {
|
|
|
|
boundZoom = HUNDRED_PERCENT
|
|
|
|
} else if (boundZoom > MAX_PERCENT) {
|
|
|
|
boundZoom = MAX_PERCENT
|
|
|
|
}
|
|
|
|
this.setState({ zoom: boundZoom });
|
2023-03-10 19:30:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fitToWidthHandler() {
|
2023-08-05 00:41:42 +08:00
|
|
|
const { setPresentationFitToWidth, fitToWidth } = this.props;
|
2023-10-28 04:29:36 +08:00
|
|
|
setPresentationFitToWidth(!fitToWidth);
|
2023-03-10 19:30:46 +08:00
|
|
|
this.setState({
|
|
|
|
zoom: HUNDRED_PERCENT,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
updateLocalPosition(x, y, width, height, zoom) {
|
|
|
|
this.setState({
|
|
|
|
localPosition: {
|
2023-08-01 10:45:13 +08:00
|
|
|
x,
|
|
|
|
y,
|
|
|
|
width,
|
|
|
|
height,
|
2023-03-10 19:30:46 +08:00
|
|
|
},
|
|
|
|
zoom,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
calculateSize(viewBoxDimensions) {
|
2023-08-05 00:41:42 +08:00
|
|
|
const { presentationHeight, presentationWidth } = this.state;
|
2019-07-18 08:30:28 +08:00
|
|
|
|
2023-10-28 04:29:36 +08:00
|
|
|
const {
|
|
|
|
userIsPresenter, currentSlide, slidePosition, fitToWidth,
|
|
|
|
} = this.props;
|
2019-07-18 08:30:28 +08:00
|
|
|
|
2019-08-01 03:10:41 +08:00
|
|
|
if (!currentSlide || !slidePosition) {
|
2019-07-18 08:30:28 +08:00
|
|
|
return { width: 0, height: 0 };
|
2019-03-28 04:48:20 +08:00
|
|
|
}
|
|
|
|
|
2019-08-01 03:10:41 +08:00
|
|
|
const originalWidth = slidePosition.width;
|
|
|
|
const originalHeight = slidePosition.height;
|
2019-07-18 08:30:28 +08:00
|
|
|
const viewBoxWidth = viewBoxDimensions.width;
|
|
|
|
const viewBoxHeight = viewBoxDimensions.height;
|
|
|
|
|
|
|
|
let svgWidth;
|
|
|
|
let svgHeight;
|
|
|
|
|
|
|
|
if (!userIsPresenter) {
|
2021-06-09 21:49:59 +08:00
|
|
|
svgWidth = (presentationHeight * viewBoxWidth) / viewBoxHeight;
|
|
|
|
if (presentationWidth < svgWidth) {
|
|
|
|
svgHeight = (presentationHeight * presentationWidth) / svgWidth;
|
|
|
|
svgWidth = presentationWidth;
|
2019-07-18 08:30:28 +08:00
|
|
|
} else {
|
2021-06-09 21:49:59 +08:00
|
|
|
svgHeight = presentationHeight;
|
2019-07-18 08:30:28 +08:00
|
|
|
}
|
|
|
|
} else if (!fitToWidth) {
|
2021-06-09 21:49:59 +08:00
|
|
|
svgWidth = (presentationHeight * originalWidth) / originalHeight;
|
|
|
|
if (presentationWidth < svgWidth) {
|
|
|
|
svgHeight = (presentationHeight * presentationWidth) / svgWidth;
|
|
|
|
svgWidth = presentationWidth;
|
2017-03-24 05:52:36 +08:00
|
|
|
} else {
|
2021-06-09 21:49:59 +08:00
|
|
|
svgHeight = presentationHeight;
|
2017-03-24 05:52:36 +08:00
|
|
|
}
|
2019-03-20 03:50:08 +08:00
|
|
|
} else {
|
2021-06-09 21:49:59 +08:00
|
|
|
svgWidth = presentationWidth;
|
2019-07-18 08:30:28 +08:00
|
|
|
svgHeight = (svgWidth * originalHeight) / originalWidth;
|
2021-06-09 21:49:59 +08:00
|
|
|
if (svgHeight > presentationHeight) svgHeight = presentationHeight;
|
2017-03-24 05:52:36 +08:00
|
|
|
}
|
2019-07-18 08:30:28 +08:00
|
|
|
|
2021-03-04 02:59:34 +08:00
|
|
|
if (typeof svgHeight !== 'number' || typeof svgWidth !== 'number') {
|
|
|
|
return { width: 0, height: 0 };
|
|
|
|
}
|
|
|
|
|
2017-03-24 05:52:36 +08:00
|
|
|
return {
|
2019-07-18 08:30:28 +08:00
|
|
|
width: svgWidth,
|
|
|
|
height: svgHeight,
|
2017-03-24 05:52:36 +08:00
|
|
|
};
|
|
|
|
}
|
2018-12-10 10:12:42 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
panAndZoomChanger(w, h, x, y) {
|
2023-12-16 01:39:12 +08:00
|
|
|
const { zoomSlide } = this.props;
|
|
|
|
zoomSlide(w, h, x, y);
|
2019-07-18 08:30:28 +08:00
|
|
|
}
|
|
|
|
|
2022-05-16 10:35:17 +08:00
|
|
|
renderPresentationToolbar(svgWidth = 0) {
|
2017-09-19 07:54:52 +08:00
|
|
|
const {
|
2019-02-12 21:35:52 +08:00
|
|
|
currentSlide,
|
2021-08-04 19:42:38 +08:00
|
|
|
isMobile,
|
2021-08-12 22:02:13 +08:00
|
|
|
layoutType,
|
|
|
|
numCameras,
|
2021-10-07 22:09:05 +08:00
|
|
|
fullscreenElementId,
|
|
|
|
fullscreenContext,
|
|
|
|
layoutContextDispatch,
|
2022-02-11 22:30:35 +08:00
|
|
|
presentationIsOpen,
|
2022-06-07 04:30:34 +08:00
|
|
|
slidePosition,
|
2023-03-10 19:30:46 +08:00
|
|
|
addWhiteboardGlobalAccess,
|
|
|
|
removeWhiteboardGlobalAccess,
|
|
|
|
multiUserSize,
|
|
|
|
multiUser,
|
2023-08-05 00:41:42 +08:00
|
|
|
fitToWidth,
|
2023-10-18 00:35:48 +08:00
|
|
|
totalPages,
|
2023-11-23 04:01:18 +08:00
|
|
|
userIsPresenter,
|
2019-02-12 21:35:52 +08:00
|
|
|
} = this.props;
|
2023-08-05 00:41:42 +08:00
|
|
|
const { zoom, isPanning } = this.state;
|
2019-01-08 02:12:28 +08:00
|
|
|
|
2020-08-18 01:03:23 +08:00
|
|
|
if (!currentSlide) return null;
|
2017-09-19 08:18:20 +08:00
|
|
|
|
2021-08-04 19:42:38 +08:00
|
|
|
const { presentationToolbarMinWidth } = DEFAULT_VALUES;
|
|
|
|
|
2023-10-28 04:29:36 +08:00
|
|
|
const toolbarWidth = (this.refWhiteboardArea && svgWidth > presentationToolbarMinWidth)
|
|
|
|
|| isMobile
|
|
|
|
|| (layoutType === LAYOUT_TYPE.VIDEO_FOCUS && numCameras > 0)
|
|
|
|
? svgWidth
|
|
|
|
: presentationToolbarMinWidth;
|
2017-09-19 08:18:20 +08:00
|
|
|
return (
|
|
|
|
<PresentationToolbarContainer
|
2019-03-11 01:21:48 +08:00
|
|
|
{...{
|
|
|
|
fitToWidth,
|
|
|
|
zoom,
|
2020-01-11 04:18:43 +08:00
|
|
|
currentSlide,
|
2022-06-07 04:30:34 +08:00
|
|
|
slidePosition,
|
2021-08-04 19:42:38 +08:00
|
|
|
toolbarWidth,
|
2021-10-07 22:09:05 +08:00
|
|
|
fullscreenElementId,
|
|
|
|
layoutContextDispatch,
|
2022-02-11 22:30:35 +08:00
|
|
|
presentationIsOpen,
|
2023-11-23 04:01:18 +08:00
|
|
|
userIsPresenter,
|
2019-03-11 01:21:48 +08:00
|
|
|
}}
|
2022-08-15 06:49:39 +08:00
|
|
|
setIsPanning={this.setIsPanning}
|
2023-03-10 19:30:46 +08:00
|
|
|
isPanning={isPanning}
|
2019-02-08 01:47:28 +08:00
|
|
|
currentSlideNum={currentSlide.num}
|
|
|
|
presentationId={currentSlide.presentationId}
|
2018-08-23 01:53:04 +08:00
|
|
|
zoomChanger={this.zoomChanger}
|
2018-09-25 20:47:49 +08:00
|
|
|
fitToWidthHandler={this.fitToWidthHandler}
|
2021-10-07 22:09:05 +08:00
|
|
|
isFullscreen={fullscreenContext}
|
|
|
|
fullscreenAction={ACTIONS.SET_FULLSCREEN_ELEMENT}
|
2022-02-04 21:57:54 +08:00
|
|
|
fullscreenRef={this.refPresentationContainer}
|
2023-03-10 19:30:46 +08:00
|
|
|
addWhiteboardGlobalAccess={addWhiteboardGlobalAccess}
|
|
|
|
removeWhiteboardGlobalAccess={removeWhiteboardGlobalAccess}
|
|
|
|
multiUserSize={multiUserSize}
|
|
|
|
multiUser={multiUser}
|
2022-05-26 07:25:53 +08:00
|
|
|
whiteboardId={currentSlide?.id}
|
2023-10-18 00:35:48 +08:00
|
|
|
numberOfSlides={totalPages}
|
2017-09-19 08:18:20 +08:00
|
|
|
/>
|
|
|
|
);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
|
2020-03-24 10:21:09 +08:00
|
|
|
renderCurrentPresentationToast() {
|
2020-08-10 20:51:06 +08:00
|
|
|
const {
|
2023-08-01 10:45:13 +08:00
|
|
|
intl,
|
|
|
|
userIsPresenter,
|
|
|
|
downloadPresentationUri,
|
2023-10-03 03:16:46 +08:00
|
|
|
presentationIsDownloadable,
|
|
|
|
presentationName,
|
2020-08-10 20:51:06 +08:00
|
|
|
} = this.props;
|
2020-03-24 10:21:09 +08:00
|
|
|
|
|
|
|
return (
|
2023-10-28 04:29:36 +08:00
|
|
|
<Styled.InnerToastWrapper data-test="currentPresentationToast">
|
2021-11-09 01:28:22 +08:00
|
|
|
<Styled.ToastIcon>
|
|
|
|
<Styled.IconWrapper>
|
2023-10-28 04:29:36 +08:00
|
|
|
<Icon iconName="presentation" />
|
2021-11-09 01:28:22 +08:00
|
|
|
</Styled.IconWrapper>
|
|
|
|
</Styled.ToastIcon>
|
2020-08-10 20:51:06 +08:00
|
|
|
|
2023-10-28 04:29:36 +08:00
|
|
|
<Styled.ToastTextContent data-test="toastSmallMsg">
|
2020-03-24 10:21:09 +08:00
|
|
|
<div>{`${intl.formatMessage(intlMessages.changeNotification)}`}</div>
|
2023-10-03 03:16:46 +08:00
|
|
|
<Styled.PresentationName>{`${presentationName}`}</Styled.PresentationName>
|
2021-11-09 01:28:22 +08:00
|
|
|
</Styled.ToastTextContent>
|
2020-08-10 20:51:06 +08:00
|
|
|
|
2023-10-03 03:16:46 +08:00
|
|
|
{presentationIsDownloadable && !userIsPresenter ? (
|
2023-08-01 10:45:13 +08:00
|
|
|
<Styled.ToastDownload>
|
|
|
|
<Styled.ToastSeparator />
|
|
|
|
<a
|
2023-10-28 04:29:36 +08:00
|
|
|
data-test="toastDownload"
|
2023-08-01 10:45:13 +08:00
|
|
|
aria-label={`${intl.formatMessage(intlMessages.downloadLabel)} ${
|
2023-10-03 03:16:46 +08:00
|
|
|
presentationName
|
2023-08-01 10:45:13 +08:00
|
|
|
}`}
|
|
|
|
href={downloadPresentationUri}
|
2023-10-28 04:29:36 +08:00
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
2023-08-01 10:45:13 +08:00
|
|
|
>
|
|
|
|
{intl.formatMessage(intlMessages.downloadLabel)}
|
|
|
|
</a>
|
|
|
|
</Styled.ToastDownload>
|
|
|
|
) : null}
|
2021-11-09 01:28:22 +08:00
|
|
|
</Styled.InnerToastWrapper>
|
2020-03-24 10:21:09 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-04-20 19:48:43 +08:00
|
|
|
renderPresentationDownload() {
|
|
|
|
const { presentationIsDownloadable, downloadPresentationUri } = this.props;
|
|
|
|
|
|
|
|
if (!presentationIsDownloadable || !downloadPresentationUri) return null;
|
|
|
|
|
|
|
|
const handleDownloadPresentation = () => {
|
|
|
|
window.open(downloadPresentationUri);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<DownloadPresentationButton
|
|
|
|
handleDownloadPresentation={handleDownloadPresentation}
|
|
|
|
dark
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-06-12 23:53:43 +08:00
|
|
|
renderPresentationMenu() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
fullscreenElementId,
|
|
|
|
layoutContextDispatch,
|
2023-10-13 02:05:49 +08:00
|
|
|
userIsPresenter,
|
2023-12-06 02:15:25 +08:00
|
|
|
currentSlide,
|
|
|
|
currentUser,
|
2022-06-12 23:53:43 +08:00
|
|
|
} = this.props;
|
2023-04-19 02:03:22 +08:00
|
|
|
const { tldrawAPI, isToolbarVisible } = this.state;
|
2022-06-12 23:53:43 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PresentationMenu
|
|
|
|
fullscreenRef={this.refPresentationContainer}
|
2023-03-10 19:30:46 +08:00
|
|
|
tldrawAPI={tldrawAPI}
|
2022-06-12 23:53:43 +08:00
|
|
|
elementName={intl.formatMessage(intlMessages.presentationLabel)}
|
|
|
|
elementId={fullscreenElementId}
|
|
|
|
layoutContextDispatch={layoutContextDispatch}
|
2023-04-19 02:03:22 +08:00
|
|
|
setIsToolbarVisible={this.setIsToolbarVisible}
|
|
|
|
isToolbarVisible={isToolbarVisible}
|
2023-10-13 02:05:49 +08:00
|
|
|
amIPresenter={userIsPresenter}
|
2023-12-06 02:15:25 +08:00
|
|
|
slideNum={currentSlide?.num}
|
|
|
|
currentUser={currentUser}
|
|
|
|
whiteboardId={currentSlide?.id}
|
2022-06-12 23:53:43 +08:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-02 07:37:51 +08:00
|
|
|
render() {
|
2019-03-12 00:21:12 +08:00
|
|
|
const {
|
|
|
|
userIsPresenter,
|
2022-05-07 00:37:43 +08:00
|
|
|
currentSlide,
|
2019-08-01 03:10:41 +08:00
|
|
|
slidePosition,
|
2021-05-25 01:05:39 +08:00
|
|
|
presentationBounds,
|
2021-06-25 02:42:45 +08:00
|
|
|
fullscreenContext,
|
2021-08-04 19:42:38 +08:00
|
|
|
isMobile,
|
2021-08-12 22:02:13 +08:00
|
|
|
layoutType,
|
|
|
|
numCameras,
|
2023-10-03 03:16:46 +08:00
|
|
|
currentPresentationId,
|
2022-06-01 03:40:31 +08:00
|
|
|
intl,
|
2022-06-12 23:53:43 +08:00
|
|
|
fullscreenElementId,
|
|
|
|
layoutContextDispatch,
|
2022-08-16 20:12:43 +08:00
|
|
|
presentationIsOpen,
|
2023-02-14 11:28:36 +08:00
|
|
|
darkTheme,
|
2023-06-06 04:02:06 +08:00
|
|
|
isViewersAnnotationsLocked,
|
2023-08-05 00:41:42 +08:00
|
|
|
fitToWidth,
|
2019-03-12 00:21:12 +08:00
|
|
|
} = this.props;
|
2019-07-18 08:30:28 +08:00
|
|
|
|
2019-03-12 21:56:05 +08:00
|
|
|
const {
|
2021-02-08 19:50:47 +08:00
|
|
|
isFullscreen,
|
2019-07-18 08:30:28 +08:00
|
|
|
localPosition,
|
2022-08-16 20:12:43 +08:00
|
|
|
zoom,
|
2022-11-23 23:05:57 +08:00
|
|
|
tldrawIsMounting,
|
2023-03-10 19:30:46 +08:00
|
|
|
isPanning,
|
2023-03-13 20:17:14 +08:00
|
|
|
tldrawAPI,
|
2023-04-19 02:03:22 +08:00
|
|
|
isToolbarVisible,
|
2019-03-12 21:56:05 +08:00
|
|
|
} = this.state;
|
2019-02-08 01:47:28 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
let viewBoxDimensions;
|
|
|
|
|
|
|
|
if (userIsPresenter && localPosition) {
|
|
|
|
viewBoxDimensions = {
|
|
|
|
width: localPosition.width,
|
|
|
|
height: localPosition.height,
|
|
|
|
};
|
2019-08-02 01:50:39 +08:00
|
|
|
} else if (slidePosition) {
|
2019-07-18 08:30:28 +08:00
|
|
|
viewBoxDimensions = {
|
2019-08-01 03:10:41 +08:00
|
|
|
width: slidePosition.viewBoxWidth,
|
|
|
|
height: slidePosition.viewBoxHeight,
|
2019-07-18 08:30:28 +08:00
|
|
|
};
|
2019-08-02 01:50:39 +08:00
|
|
|
} else {
|
|
|
|
viewBoxDimensions = {
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
};
|
2019-07-18 08:30:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const svgDimensions = this.calculateSize(viewBoxDimensions);
|
|
|
|
const svgHeight = svgDimensions.height;
|
|
|
|
const svgWidth = svgDimensions.width;
|
2019-02-19 20:27:54 +08:00
|
|
|
|
2023-03-10 19:30:46 +08:00
|
|
|
const toolbarHeight = getToolbarHeight();
|
2019-02-19 20:27:54 +08:00
|
|
|
|
2021-08-04 19:42:38 +08:00
|
|
|
const { presentationToolbarMinWidth } = DEFAULT_VALUES;
|
|
|
|
|
2023-10-28 04:29:36 +08:00
|
|
|
const isLargePresentation = (svgWidth > presentationToolbarMinWidth || isMobile)
|
|
|
|
&& !(
|
|
|
|
layoutType === LAYOUT_TYPE.VIDEO_FOCUS
|
|
|
|
&& numCameras > 0
|
|
|
|
&& !fullscreenContext
|
2023-08-01 10:45:13 +08:00
|
|
|
);
|
2021-08-12 22:02:13 +08:00
|
|
|
|
|
|
|
const containerWidth = isLargePresentation
|
2021-08-04 19:42:38 +08:00
|
|
|
? svgWidth
|
|
|
|
: presentationToolbarMinWidth;
|
|
|
|
|
2023-08-01 10:45:13 +08:00
|
|
|
const slideContent = currentSlide?.content
|
|
|
|
? `${intl.formatMessage(intlMessages.slideContentStart)}
|
2022-08-16 20:12:43 +08:00
|
|
|
${currentSlide.content}
|
2023-08-01 10:45:13 +08:00
|
|
|
${intl.formatMessage(intlMessages.slideContentEnd)}`
|
|
|
|
: intl.formatMessage(intlMessages.noSlideContent);
|
2022-08-16 20:12:43 +08:00
|
|
|
|
2023-06-29 03:06:19 +08:00
|
|
|
const isVideoFocus = layoutType === LAYOUT_TYPE.VIDEO_FOCUS;
|
|
|
|
const presentationZIndex = fullscreenContext ? presentationBounds.zIndex : undefined;
|
|
|
|
|
2022-04-05 22:49:13 +08:00
|
|
|
return (
|
2022-06-12 23:53:43 +08:00
|
|
|
<>
|
2022-04-05 22:49:13 +08:00
|
|
|
<Styled.PresentationContainer
|
2023-10-28 04:29:36 +08:00
|
|
|
role="region"
|
|
|
|
data-test="presentationContainer"
|
2023-08-01 10:45:13 +08:00
|
|
|
ref={(ref) => {
|
|
|
|
this.refPresentationContainer = ref;
|
|
|
|
}}
|
2022-04-05 22:49:13 +08:00
|
|
|
style={{
|
|
|
|
top: presentationBounds.top,
|
|
|
|
left: presentationBounds.left,
|
|
|
|
right: presentationBounds.right,
|
|
|
|
width: presentationBounds.width,
|
|
|
|
height: presentationBounds.height,
|
2023-01-24 21:05:49 +08:00
|
|
|
display: !presentationIsOpen ? 'none' : 'flex',
|
2022-04-05 22:49:13 +08:00
|
|
|
overflow: 'hidden',
|
2023-06-29 03:06:19 +08:00
|
|
|
zIndex: !isVideoFocus ? presentationZIndex : 0,
|
2023-03-10 19:30:46 +08:00
|
|
|
background:
|
2023-06-29 03:06:19 +08:00
|
|
|
layoutType === isVideoFocus && !fullscreenContext
|
2023-03-10 19:30:46 +08:00
|
|
|
? colorContentBackground
|
|
|
|
: null,
|
2022-04-05 22:49:13 +08:00
|
|
|
}}
|
|
|
|
>
|
2023-08-01 10:45:13 +08:00
|
|
|
<Styled.Presentation
|
|
|
|
ref={(ref) => {
|
|
|
|
this.refPresentation = ref;
|
|
|
|
}}
|
|
|
|
>
|
2022-08-16 20:12:43 +08:00
|
|
|
<Styled.SvgContainer
|
|
|
|
style={{
|
|
|
|
height: svgHeight + toolbarHeight,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
width: svgDimensions.width < 0 ? 0 : svgDimensions.width,
|
|
|
|
height: svgDimensions.height < 0 ? 0 : svgDimensions.height,
|
|
|
|
textAlign: 'center',
|
|
|
|
display: !presentationIsOpen ? 'none' : 'block',
|
2024-02-06 00:43:25 +08:00
|
|
|
zIndex: 1,
|
2022-08-16 20:12:43 +08:00
|
|
|
}}
|
2023-10-28 04:29:36 +08:00
|
|
|
id="presentationInnerWrapper"
|
2022-08-16 20:12:43 +08:00
|
|
|
>
|
2023-04-20 19:48:43 +08:00
|
|
|
{this.renderPresentationDownload()}
|
2023-10-28 04:29:36 +08:00
|
|
|
<Styled.VisuallyHidden id="currentSlideText">
|
2023-08-01 10:45:13 +08:00
|
|
|
{slideContent}
|
|
|
|
</Styled.VisuallyHidden>
|
2023-10-28 04:29:36 +08:00
|
|
|
{!tldrawIsMounting
|
|
|
|
&& currentSlide
|
|
|
|
&& this.renderPresentationMenu()}
|
2022-08-16 20:12:43 +08:00
|
|
|
<WhiteboardContainer
|
|
|
|
whiteboardId={currentSlide?.id}
|
|
|
|
slidePosition={slidePosition}
|
|
|
|
getSvgRef={this.getSvgRef}
|
2023-03-13 20:17:14 +08:00
|
|
|
tldrawAPI={tldrawAPI}
|
2022-08-16 20:12:43 +08:00
|
|
|
setTldrawAPI={this.setTldrawAPI}
|
2023-02-28 00:05:29 +08:00
|
|
|
curPageId={currentSlide?.num.toString() || '0'}
|
2022-08-16 20:12:43 +08:00
|
|
|
svgUri={currentSlide?.svgUri}
|
|
|
|
intl={intl}
|
|
|
|
presentationWidth={svgWidth}
|
|
|
|
presentationHeight={svgHeight}
|
2023-01-26 02:49:09 +08:00
|
|
|
presentationAreaHeight={presentationBounds?.height}
|
|
|
|
presentationAreaWidth={presentationBounds?.width}
|
2023-03-10 19:30:46 +08:00
|
|
|
isPanning={isPanning}
|
2022-08-16 20:12:43 +08:00
|
|
|
zoomChanger={this.zoomChanger}
|
|
|
|
fitToWidth={fitToWidth}
|
|
|
|
zoomValue={zoom}
|
2022-11-23 23:05:57 +08:00
|
|
|
setTldrawIsMounting={this.setTldrawIsMounting}
|
2023-08-01 10:45:13 +08:00
|
|
|
setIsToolbarVisible={this.setIsToolbarVisible}
|
2023-02-06 21:37:34 +08:00
|
|
|
isFullscreen={isFullscreen}
|
|
|
|
fullscreenAction={ACTIONS.SET_FULLSCREEN_ELEMENT}
|
|
|
|
fullscreenElementId={fullscreenElementId}
|
|
|
|
layoutContextDispatch={layoutContextDispatch}
|
|
|
|
fullscreenRef={this.refPresentationContainer}
|
2023-10-03 03:16:46 +08:00
|
|
|
presentationId={currentPresentationId}
|
2023-02-14 11:28:36 +08:00
|
|
|
darkTheme={darkTheme}
|
2023-04-19 02:03:22 +08:00
|
|
|
isToolbarVisible={isToolbarVisible}
|
2023-06-06 04:02:06 +08:00
|
|
|
isViewersAnnotationsLocked={isViewersAnnotationsLocked}
|
2022-08-16 20:12:43 +08:00
|
|
|
/>
|
|
|
|
{isFullscreen && <PollingContainer />}
|
|
|
|
</div>
|
2022-11-23 23:05:57 +08:00
|
|
|
{!tldrawIsMounting && (
|
|
|
|
<Styled.PresentationToolbar
|
2023-08-01 10:45:13 +08:00
|
|
|
ref={(ref) => {
|
|
|
|
this.refPresentationToolbar = ref;
|
|
|
|
}}
|
|
|
|
style={{
|
|
|
|
width: containerWidth,
|
|
|
|
}}
|
2022-11-23 23:05:57 +08:00
|
|
|
>
|
|
|
|
{this.renderPresentationToolbar(svgWidth)}
|
|
|
|
</Styled.PresentationToolbar>
|
|
|
|
)}
|
2022-08-16 20:12:43 +08:00
|
|
|
</Styled.SvgContainer>
|
|
|
|
</Styled.Presentation>
|
2023-03-10 19:30:46 +08:00
|
|
|
</Styled.PresentationContainer>
|
2022-06-02 23:00:28 +08:00
|
|
|
</>
|
2016-05-31 06:07:02 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-05 15:26:03 +08:00
|
|
|
export default injectIntl(Presentation);
|
2019-02-07 05:12:59 +08:00
|
|
|
|
2021-06-09 21:49:59 +08:00
|
|
|
Presentation.propTypes = {
|
2017-07-29 08:29:40 +08:00
|
|
|
// Defines a boolean value to detect whether a current user is a presenter
|
2024-02-17 04:25:43 +08:00
|
|
|
userIsPresenter: PropTypes.bool,
|
2017-07-29 08:29:40 +08:00
|
|
|
currentSlide: PropTypes.shape({
|
|
|
|
presentationId: PropTypes.string.isRequired,
|
2017-08-17 10:24:59 +08:00
|
|
|
current: PropTypes.bool.isRequired,
|
|
|
|
num: PropTypes.number.isRequired,
|
|
|
|
id: PropTypes.string.isRequired,
|
2019-08-01 03:10:41 +08:00
|
|
|
imageUri: PropTypes.string.isRequired,
|
2023-03-10 19:30:46 +08:00
|
|
|
curPageId: PropTypes.string,
|
|
|
|
svgUri: PropTypes.string.isRequired,
|
|
|
|
content: PropTypes.string.isRequired,
|
2019-08-01 03:10:41 +08:00
|
|
|
}),
|
|
|
|
slidePosition: PropTypes.shape({
|
|
|
|
x: PropTypes.number.isRequired,
|
|
|
|
y: PropTypes.number.isRequired,
|
|
|
|
height: PropTypes.number.isRequired,
|
|
|
|
width: PropTypes.number.isRequired,
|
|
|
|
viewBoxWidth: PropTypes.number.isRequired,
|
|
|
|
viewBoxHeight: PropTypes.number.isRequired,
|
2017-07-29 08:29:40 +08:00
|
|
|
}),
|
2017-08-15 08:15:11 +08:00
|
|
|
// current multi-user status
|
|
|
|
multiUser: PropTypes.bool.isRequired,
|
2023-01-24 21:05:49 +08:00
|
|
|
setPresentationIsOpen: PropTypes.func.isRequired,
|
2023-03-10 19:30:46 +08:00
|
|
|
layoutContextDispatch: PropTypes.func.isRequired,
|
2024-02-17 04:25:43 +08:00
|
|
|
presentationIsDownloadable: PropTypes.bool,
|
|
|
|
presentationName: PropTypes.string,
|
|
|
|
currentPresentationId: PropTypes.string,
|
2023-03-10 19:30:46 +08:00
|
|
|
presentationIsOpen: PropTypes.bool.isRequired,
|
2023-10-18 00:35:48 +08:00
|
|
|
totalPages: PropTypes.number.isRequired,
|
2023-03-10 19:30:46 +08:00
|
|
|
publishedPoll: PropTypes.bool.isRequired,
|
|
|
|
presentationBounds: PropTypes.shape({
|
|
|
|
top: PropTypes.number,
|
|
|
|
left: PropTypes.number,
|
|
|
|
right: PropTypes.number,
|
|
|
|
width: PropTypes.number,
|
|
|
|
height: PropTypes.number,
|
|
|
|
zIndex: PropTypes.number,
|
|
|
|
}),
|
|
|
|
restoreOnUpdate: PropTypes.bool.isRequired,
|
|
|
|
numCameras: PropTypes.number.isRequired,
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
isMobile: PropTypes.bool.isRequired,
|
|
|
|
fullscreenContext: PropTypes.bool.isRequired,
|
|
|
|
presentationAreaSize: PropTypes.shape({
|
|
|
|
presentationAreaWidth: PropTypes.number.isRequired,
|
|
|
|
presentationAreaHeight: PropTypes.number.isRequired,
|
|
|
|
}),
|
|
|
|
zoomSlide: PropTypes.func.isRequired,
|
|
|
|
addWhiteboardGlobalAccess: PropTypes.func.isRequired,
|
|
|
|
removeWhiteboardGlobalAccess: PropTypes.func.isRequired,
|
|
|
|
multiUserSize: PropTypes.number.isRequired,
|
|
|
|
layoutType: PropTypes.string.isRequired,
|
|
|
|
fullscreenElementId: PropTypes.string.isRequired,
|
|
|
|
downloadPresentationUri: PropTypes.string,
|
|
|
|
darkTheme: PropTypes.bool.isRequired,
|
2016-05-31 06:07:02 +08:00
|
|
|
};
|
2017-08-19 10:47:31 +08:00
|
|
|
|
2021-06-09 21:49:59 +08:00
|
|
|
Presentation.defaultProps = {
|
2017-08-19 10:47:31 +08:00
|
|
|
currentSlide: undefined,
|
2019-08-01 03:10:41 +08:00
|
|
|
slidePosition: undefined,
|
2023-03-10 19:30:46 +08:00
|
|
|
presentationAreaSize: undefined,
|
|
|
|
presentationBounds: undefined,
|
|
|
|
downloadPresentationUri: undefined,
|
2024-02-17 04:25:43 +08:00
|
|
|
userIsPresenter: false,
|
|
|
|
presentationIsDownloadable: false,
|
|
|
|
currentPresentationId: '',
|
|
|
|
presentationName: '',
|
2022-05-07 00:37:43 +08:00
|
|
|
};
|