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';
|
2017-05-02 05:34:24 +08:00
|
|
|
import WhiteboardOverlayContainer from '/imports/ui/components/whiteboard/whiteboard-overlay/container';
|
2017-04-19 08:54:51 +08:00
|
|
|
import WhiteboardToolbarContainer from '/imports/ui/components/whiteboard/whiteboard-toolbar/container';
|
2018-12-05 19:00:12 +08:00
|
|
|
import { HUNDRED_PERCENT, MAX_PERCENT } from '/imports/utils/slideCalcUtils';
|
2019-03-12 00:21:12 +08:00
|
|
|
import { defineMessages, injectIntl, intlShape } from 'react-intl';
|
2019-02-14 20:03:25 +08:00
|
|
|
import PresentationToolbarContainer from './presentation-toolbar/container';
|
2017-08-15 08:15:11 +08:00
|
|
|
import CursorWrapperContainer from './cursor/cursor-wrapper-container/container';
|
2017-07-27 20:35:55 +08:00
|
|
|
import AnnotationGroupContainer from '../whiteboard/annotation-group/container';
|
2017-07-29 08:29:40 +08:00
|
|
|
import PresentationOverlayContainer from './presentation-overlay/container';
|
|
|
|
import Slide from './slide/component';
|
2018-01-08 14:17:18 +08:00
|
|
|
import { styles } from './styles.scss';
|
2019-02-08 01:47:28 +08:00
|
|
|
import MediaService, { shouldEnableSwapLayout } from '../media/service';
|
2018-12-15 04:16:15 +08:00
|
|
|
import PresentationCloseButton from './presentation-close-button/component';
|
2019-03-08 03:00:01 +08:00
|
|
|
import DownloadPresentationButton from './download-presentation-button/component';
|
2019-07-27 00:48:51 +08:00
|
|
|
import FullscreenService from '../fullscreen-button/service';
|
2019-07-23 00:59:34 +08:00
|
|
|
import FullscreenButtonContainer from '../fullscreen-button/container';
|
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',
|
|
|
|
},
|
2019-03-12 00:21:12 +08:00
|
|
|
});
|
2017-07-29 08:29:40 +08:00
|
|
|
|
2019-07-24 03:56:39 +08:00
|
|
|
const ALLOW_FULLSCREEN = Meteor.settings.public.app.allowFullscreen;
|
|
|
|
|
2019-06-13 02:40:58 +08:00
|
|
|
class PresentationArea extends PureComponent {
|
2017-07-29 08:29:40 +08:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
2017-03-24 05:52:36 +08:00
|
|
|
this.state = {
|
2019-07-18 08:30:28 +08:00
|
|
|
presentationAreaWidth: 0,
|
|
|
|
presentationAreaHeight: 0,
|
2017-03-24 05:52:36 +08:00
|
|
|
showSlide: false,
|
2018-08-23 01:53:04 +08:00
|
|
|
zoom: 100,
|
2018-09-25 20:47:49 +08:00
|
|
|
fitToWidth: false,
|
2019-07-27 00:48:51 +08:00
|
|
|
isFullscreen: false,
|
2017-03-24 05:52:36 +08:00
|
|
|
};
|
2017-07-29 08:29:40 +08:00
|
|
|
|
|
|
|
this.getSvgRef = this.getSvgRef.bind(this);
|
2019-07-24 03:56:39 +08:00
|
|
|
this.setFitToWidth = this.setFitToWidth.bind(this);
|
2018-08-23 01:53:04 +08:00
|
|
|
this.zoomChanger = this.zoomChanger.bind(this);
|
2019-07-18 08:30:28 +08:00
|
|
|
this.updateLocalPosition = this.updateLocalPosition.bind(this);
|
|
|
|
this.panAndZoomChanger = this.panAndZoomChanger.bind(this);
|
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);
|
2019-07-30 23:03:29 +08:00
|
|
|
this.onResize = () => setTimeout(this.handleResize.bind(this), 0);
|
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
|
|
|
|
2019-08-01 03:10:41 +08:00
|
|
|
if (props.userIsPresenter
|
|
|
|
&& (!prevProps || !prevProps.userIsPresenter)
|
|
|
|
&& props.currentSlide
|
|
|
|
&& props.slidePosition) {
|
|
|
|
let potentialZoom = 100 / (props.slidePosition.viewBoxWidth / props.slidePosition.width);
|
|
|
|
potentialZoom = Math.max(HUNDRED_PERCENT, Math.min(MAX_PERCENT, potentialZoom));
|
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
|
|
|
|
if (prevProps.currentSlide.id !== props.currentSlide.id
|
|
|
|
|| prevProps.userIsPresenter !== props.userIsPresenter) {
|
|
|
|
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() {
|
|
|
|
// adding an event listener to scale the whiteboard on 'resize' events sent by chat/userlist etc
|
2019-07-30 23:03:29 +08:00
|
|
|
window.addEventListener('resize', this.onResize);
|
2019-06-13 02:40:58 +08:00
|
|
|
this.getInitialPresentationSizes();
|
2019-07-30 23:03:29 +08:00
|
|
|
this.refPresentationContainer.addEventListener('fullscreenchange', this.onFullscreenChange);
|
2019-06-13 02:40:58 +08:00
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
componentDidUpdate(prevProps) {
|
2020-05-12 20:58:14 +08:00
|
|
|
const {
|
|
|
|
currentPresentation,
|
|
|
|
notify,
|
|
|
|
intl,
|
|
|
|
layoutSwapped,
|
|
|
|
currentSlide,
|
|
|
|
slidePosition,
|
|
|
|
publishedPoll,
|
|
|
|
isViewer,
|
|
|
|
toggleSwapLayout,
|
|
|
|
restoreOnUpdate,
|
|
|
|
} = this.props;
|
2019-05-10 01:44:54 +08:00
|
|
|
|
|
|
|
if (prevProps.currentPresentation.name !== currentPresentation.name) {
|
|
|
|
notify(
|
2019-05-10 01:57:06 +08:00
|
|
|
`${intl.formatMessage(intlMessages.changeNotification)} ${currentPresentation.name}`,
|
2019-05-10 01:44:54 +08:00
|
|
|
'info',
|
2019-05-10 01:57:06 +08:00
|
|
|
'presentation',
|
2019-05-10 01:44:54 +08:00
|
|
|
);
|
|
|
|
}
|
2020-05-12 20:58:14 +08:00
|
|
|
|
|
|
|
if (layoutSwapped && restoreOnUpdate && isViewer && currentSlide) {
|
|
|
|
const slideChanged = currentSlide.id !== prevProps.currentSlide.id;
|
|
|
|
const positionChanged = slidePosition.viewBoxHeight !== prevProps.slidePosition.viewBoxHeight
|
|
|
|
|| slidePosition.viewBoxWidth !== prevProps.slidePosition.viewBoxWidth;
|
|
|
|
const pollPublished = publishedPoll && !prevProps.publishedPoll;
|
|
|
|
if (slideChanged || positionChanged || pollPublished) {
|
|
|
|
toggleSwapLayout();
|
|
|
|
}
|
|
|
|
}
|
2019-03-20 03:50:08 +08:00
|
|
|
}
|
|
|
|
|
2017-03-24 05:52:36 +08:00
|
|
|
componentWillUnmount() {
|
2019-07-30 23:03:29 +08:00
|
|
|
window.removeEventListener('resize', this.onResize);
|
|
|
|
this.refPresentationContainer.removeEventListener('fullscreenchange', this.onFullscreenChange);
|
2017-03-24 05:52:36 +08:00
|
|
|
}
|
|
|
|
|
2019-07-27 00:48:51 +08:00
|
|
|
onFullscreenChange() {
|
|
|
|
const { isFullscreen } = this.state;
|
|
|
|
const newIsFullscreen = FullscreenService.isFullScreen(this.refPresentationContainer);
|
|
|
|
if (isFullscreen !== newIsFullscreen) {
|
|
|
|
this.setState({ isFullscreen: newIsFullscreen });
|
|
|
|
window.dispatchEvent(new Event('resize'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-02-14 20:03:25 +08:00
|
|
|
getToolbarHeight() {
|
|
|
|
const { refPresentationToolbar } = this;
|
|
|
|
let height = 0;
|
|
|
|
if (refPresentationToolbar) {
|
|
|
|
const { clientHeight } = refPresentationToolbar;
|
|
|
|
height = clientHeight;
|
|
|
|
}
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2017-09-18 09:58:37 +08:00
|
|
|
getPresentationSizesAvailable() {
|
2019-02-12 21:35:52 +08:00
|
|
|
const { userIsPresenter, multiUser } = this.props;
|
2017-09-18 09:58:37 +08:00
|
|
|
const { refPresentationArea, refWhiteboardArea } = this;
|
|
|
|
const presentationSizes = {};
|
2017-07-29 08:29:40 +08:00
|
|
|
|
2017-09-18 09:58:37 +08:00
|
|
|
if (refPresentationArea && refWhiteboardArea) {
|
|
|
|
// By default presentation sizes are equal to the sizes of the refPresentationArea
|
|
|
|
// direct parent of the svg wrapper
|
2017-10-26 07:11:06 +08:00
|
|
|
let { clientWidth, clientHeight } = refPresentationArea;
|
2017-09-18 09:58:37 +08:00
|
|
|
|
|
|
|
// if a user is a presenter - this means there is a whiteboard toolbar on the right
|
|
|
|
// and we have to get the width/height of the refWhiteboardArea
|
2017-08-26 06:45:06 +08:00
|
|
|
// (inner hidden div with absolute position)
|
2019-02-08 01:47:28 +08:00
|
|
|
if (userIsPresenter || multiUser) {
|
2017-10-26 07:11:06 +08:00
|
|
|
({ clientWidth, clientHeight } = refWhiteboardArea);
|
2017-08-26 06:45:06 +08:00
|
|
|
}
|
2017-04-28 06:18:53 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
presentationSizes.presentationAreaHeight = clientHeight - this.getToolbarHeight();
|
|
|
|
presentationSizes.presentationAreaWidth = clientWidth;
|
2017-09-06 09:36:15 +08:00
|
|
|
}
|
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() {
|
2019-07-18 08:30:28 +08:00
|
|
|
// determining the presentationAreaWidth and presentationAreaHeight (available
|
|
|
|
// 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-09-06 09:36:15 +08:00
|
|
|
// and set the showSlide to true to start rendering the slide
|
2017-10-26 07:11:06 +08:00
|
|
|
this.setState({
|
2019-07-18 08:30:28 +08:00
|
|
|
presentationAreaHeight: presentationSizes.presentationAreaHeight,
|
|
|
|
presentationAreaWidth: presentationSizes.presentationAreaWidth,
|
2017-10-26 07:11:06 +08:00
|
|
|
showSlide: true,
|
|
|
|
});
|
2017-09-06 09:36:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-24 03:56:39 +08:00
|
|
|
setFitToWidth(fitToWidth) {
|
|
|
|
this.setState({ fitToWidth });
|
|
|
|
}
|
|
|
|
|
2017-09-06 09:36:15 +08:00
|
|
|
handleResize() {
|
2017-09-18 09:58:37 +08:00
|
|
|
const presentationSizes = this.getPresentationSizesAvailable();
|
|
|
|
if (Object.keys(presentationSizes).length > 0) {
|
2017-08-26 06:45:06 +08:00
|
|
|
// updating the size of the space available for the slide
|
2019-03-12 21:56:05 +08:00
|
|
|
this.setState({
|
2019-07-18 08:30:28 +08:00
|
|
|
presentationAreaHeight: presentationSizes.presentationAreaHeight,
|
|
|
|
presentationAreaWidth: presentationSizes.presentationAreaWidth,
|
2019-03-12 21:56:05 +08:00
|
|
|
});
|
2017-08-26 06:45:06 +08:00
|
|
|
}
|
2017-03-24 05:52:36 +08:00
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
calculateSize(viewBoxDimensions) {
|
|
|
|
const {
|
|
|
|
presentationAreaHeight,
|
|
|
|
presentationAreaWidth,
|
|
|
|
fitToWidth,
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
const {
|
|
|
|
userIsPresenter,
|
|
|
|
currentSlide,
|
2019-08-01 03:10:41 +08:00
|
|
|
slidePosition,
|
2019-07-18 08:30:28 +08:00
|
|
|
} = this.props;
|
|
|
|
|
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) {
|
|
|
|
svgWidth = (presentationAreaHeight * viewBoxWidth) / viewBoxHeight;
|
|
|
|
if (presentationAreaWidth < svgWidth) {
|
|
|
|
svgHeight = (presentationAreaHeight * presentationAreaWidth) / svgWidth;
|
|
|
|
svgWidth = presentationAreaWidth;
|
|
|
|
} else {
|
|
|
|
svgHeight = presentationAreaHeight;
|
|
|
|
}
|
|
|
|
} else if (!fitToWidth) {
|
|
|
|
svgWidth = (presentationAreaHeight * originalWidth) / originalHeight;
|
|
|
|
if (presentationAreaWidth < svgWidth) {
|
|
|
|
svgHeight = (presentationAreaHeight * presentationAreaWidth) / svgWidth;
|
|
|
|
svgWidth = presentationAreaWidth;
|
2017-03-24 05:52:36 +08:00
|
|
|
} else {
|
2019-07-18 08:30:28 +08:00
|
|
|
svgHeight = presentationAreaHeight;
|
2017-03-24 05:52:36 +08:00
|
|
|
}
|
2019-03-20 03:50:08 +08:00
|
|
|
} else {
|
2019-07-18 08:30:28 +08:00
|
|
|
svgWidth = presentationAreaWidth;
|
|
|
|
svgHeight = (svgWidth * originalHeight) / originalWidth;
|
|
|
|
if (svgHeight > presentationAreaHeight) svgHeight = presentationAreaHeight;
|
2017-03-24 05:52:36 +08:00
|
|
|
}
|
2019-07-18 08:30:28 +08:00
|
|
|
|
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
|
|
|
zoomChanger(incomingZoom) {
|
2019-05-10 01:44:54 +08:00
|
|
|
const {
|
2019-07-18 08:30:28 +08:00
|
|
|
zoom,
|
|
|
|
} = this.state;
|
2019-03-20 03:50:08 +08:00
|
|
|
|
2019-02-08 01:47:28 +08:00
|
|
|
let newZoom = incomingZoom;
|
2017-03-24 05:52:36 +08:00
|
|
|
|
2018-08-23 01:53:04 +08:00
|
|
|
if (newZoom <= HUNDRED_PERCENT) {
|
|
|
|
newZoom = HUNDRED_PERCENT;
|
2019-02-08 01:47:28 +08:00
|
|
|
} else if (incomingZoom >= MAX_PERCENT) {
|
2018-08-23 01:53:04 +08:00
|
|
|
newZoom = MAX_PERCENT;
|
|
|
|
}
|
2018-12-10 10:12:42 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
if (newZoom !== zoom) this.setState({ zoom: newZoom });
|
2018-09-18 02:02:52 +08:00
|
|
|
}
|
2018-12-10 10:12:42 +08:00
|
|
|
|
2018-09-25 20:47:49 +08:00
|
|
|
fitToWidthHandler() {
|
2019-07-18 08:30:28 +08:00
|
|
|
const {
|
|
|
|
fitToWidth,
|
|
|
|
} = this.state;
|
|
|
|
|
2019-02-12 21:35:52 +08:00
|
|
|
this.setState({
|
|
|
|
fitToWidth: !fitToWidth,
|
2019-07-18 08:30:28 +08:00
|
|
|
zoom: HUNDRED_PERCENT,
|
2019-02-12 21:35:52 +08:00
|
|
|
});
|
2019-02-08 01:47:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
isPresentationAccessible() {
|
2019-08-01 03:10:41 +08:00
|
|
|
const {
|
|
|
|
currentSlide,
|
|
|
|
slidePosition,
|
|
|
|
} = this.props;
|
|
|
|
// sometimes tomcat publishes the slide url, but the actual file is not accessible
|
|
|
|
return currentSlide && slidePosition;
|
2018-09-25 20:47:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
updateLocalPosition(x, y, width, height, zoom) {
|
|
|
|
this.setState({
|
|
|
|
localPosition: {
|
|
|
|
x, y, width, height,
|
|
|
|
},
|
|
|
|
zoom,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
panAndZoomChanger(w, h, x, y) {
|
|
|
|
const {
|
|
|
|
currentSlide,
|
|
|
|
podId,
|
|
|
|
zoomSlide,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
zoomSlide(currentSlide.num, podId, w, h, x, y);
|
|
|
|
}
|
|
|
|
|
2019-02-12 21:35:52 +08:00
|
|
|
renderPresentationClose() {
|
2019-07-27 00:48:51 +08:00
|
|
|
const { isFullscreen } = this.state;
|
2019-02-12 21:35:52 +08:00
|
|
|
if (!shouldEnableSwapLayout() || isFullscreen) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return <PresentationCloseButton toggleSwapLayout={MediaService.toggleSwapLayout} />;
|
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
renderOverlays(slideObj, svgDimensions, viewBoxPosition, viewBoxDimensions, physicalDimensions) {
|
2019-02-12 21:35:52 +08:00
|
|
|
const {
|
|
|
|
userIsPresenter,
|
|
|
|
multiUser,
|
|
|
|
podId,
|
|
|
|
currentSlide,
|
2019-08-01 03:10:41 +08:00
|
|
|
slidePosition,
|
2019-02-12 21:35:52 +08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
zoom,
|
|
|
|
fitToWidth,
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
if (!userIsPresenter && !multiUser) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// retrieving the pre-calculated data from the slide object
|
|
|
|
const {
|
|
|
|
width,
|
|
|
|
height,
|
2019-08-01 03:10:41 +08:00
|
|
|
} = slidePosition;
|
2019-02-12 21:35:52 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PresentationOverlayContainer
|
|
|
|
podId={podId}
|
2019-07-18 08:30:28 +08:00
|
|
|
userIsPresenter={userIsPresenter}
|
2019-02-12 21:35:52 +08:00
|
|
|
currentSlideNum={currentSlide.num}
|
|
|
|
slide={slideObj}
|
|
|
|
slideWidth={width}
|
|
|
|
slideHeight={height}
|
2019-07-18 08:30:28 +08:00
|
|
|
viewBoxX={viewBoxPosition.x}
|
|
|
|
viewBoxY={viewBoxPosition.y}
|
|
|
|
viewBoxWidth={viewBoxDimensions.width}
|
|
|
|
viewBoxHeight={viewBoxDimensions.height}
|
|
|
|
physicalSlideWidth={physicalDimensions.width}
|
|
|
|
physicalSlideHeight={physicalDimensions.height}
|
|
|
|
svgWidth={svgDimensions.width}
|
|
|
|
svgHeight={svgDimensions.height}
|
2019-02-12 21:35:52 +08:00
|
|
|
zoom={zoom}
|
|
|
|
zoomChanger={this.zoomChanger}
|
2019-07-18 08:30:28 +08:00
|
|
|
updateLocalPosition={this.updateLocalPosition}
|
|
|
|
panAndZoomChanger={this.panAndZoomChanger}
|
2019-02-12 21:35:52 +08:00
|
|
|
getSvgRef={this.getSvgRef}
|
|
|
|
fitToWidth={fitToWidth}
|
|
|
|
>
|
|
|
|
<WhiteboardOverlayContainer
|
|
|
|
getSvgRef={this.getSvgRef}
|
2019-07-18 08:30:28 +08:00
|
|
|
userIsPresenter={userIsPresenter}
|
2019-02-12 21:35:52 +08:00
|
|
|
whiteboardId={slideObj.id}
|
2019-07-18 08:30:28 +08:00
|
|
|
slide={slideObj}
|
2019-02-12 21:35:52 +08:00
|
|
|
slideWidth={width}
|
|
|
|
slideHeight={height}
|
2019-07-18 08:30:28 +08:00
|
|
|
viewBoxX={viewBoxPosition.x}
|
|
|
|
viewBoxY={viewBoxPosition.y}
|
|
|
|
viewBoxWidth={viewBoxDimensions.width}
|
|
|
|
viewBoxHeight={viewBoxDimensions.height}
|
|
|
|
physicalSlideWidth={physicalDimensions.width}
|
|
|
|
physicalSlideHeight={physicalDimensions.height}
|
2019-02-12 21:35:52 +08:00
|
|
|
zoom={zoom}
|
|
|
|
zoomChanger={this.zoomChanger}
|
|
|
|
/>
|
|
|
|
</PresentationOverlayContainer>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-07-29 08:29:40 +08:00
|
|
|
// renders the whole presentation area
|
2019-07-18 08:30:28 +08:00
|
|
|
renderPresentationArea(svgDimensions, viewBoxDimensions) {
|
|
|
|
const {
|
|
|
|
podId,
|
|
|
|
currentSlide,
|
2019-08-01 03:10:41 +08:00
|
|
|
slidePosition,
|
2019-07-18 08:30:28 +08:00
|
|
|
userIsPresenter,
|
|
|
|
} = this.props;
|
2019-02-08 01:47:28 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
const {
|
|
|
|
localPosition,
|
|
|
|
} = this.state;
|
2019-02-14 20:03:25 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
if (!this.isPresentationAccessible()) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-04-28 06:18:53 +08:00
|
|
|
|
2017-10-26 07:11:06 +08:00
|
|
|
// retrieving the pre-calculated data from the slide object
|
2017-09-22 05:02:50 +08:00
|
|
|
const {
|
2017-10-26 07:11:06 +08:00
|
|
|
width,
|
|
|
|
height,
|
2019-08-01 03:10:41 +08:00
|
|
|
} = slidePosition;
|
|
|
|
|
|
|
|
const {
|
2017-10-26 07:11:06 +08:00
|
|
|
imageUri,
|
2019-08-01 03:10:41 +08:00
|
|
|
} = currentSlide;
|
2019-02-12 21:35:52 +08:00
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
let viewBoxPosition;
|
|
|
|
|
|
|
|
if (userIsPresenter && localPosition) {
|
|
|
|
viewBoxPosition = {
|
|
|
|
x: localPosition.x,
|
|
|
|
y: localPosition.y,
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
viewBoxPosition = {
|
2019-08-01 03:10:41 +08:00
|
|
|
x: slidePosition.x,
|
|
|
|
y: slidePosition.y,
|
2019-02-12 21:35:52 +08:00
|
|
|
};
|
2019-07-18 08:30:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const widthRatio = viewBoxDimensions.width / width;
|
|
|
|
const heightRatio = viewBoxDimensions.height / height;
|
|
|
|
|
|
|
|
const physicalDimensions = {
|
|
|
|
width: (svgDimensions.width / widthRatio),
|
|
|
|
height: (svgDimensions.height / heightRatio),
|
|
|
|
};
|
|
|
|
|
|
|
|
const svgViewBox = `${viewBoxPosition.x} ${viewBoxPosition.y} `
|
2020-04-28 01:25:22 +08:00
|
|
|
+ `${viewBoxDimensions.width} ${Number.isNaN(viewBoxDimensions.height) ? 0 : viewBoxDimensions.height}`;
|
2019-02-12 21:35:52 +08:00
|
|
|
|
2017-09-22 05:02:50 +08:00
|
|
|
return (
|
|
|
|
<div
|
2019-07-18 08:30:28 +08:00
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
width: svgDimensions.width,
|
|
|
|
height: svgDimensions.height,
|
|
|
|
textAlign: 'center',
|
|
|
|
}}
|
2017-09-22 05:02:50 +08:00
|
|
|
>
|
2019-03-08 03:00:01 +08:00
|
|
|
{this.renderPresentationClose()}
|
|
|
|
{this.renderPresentationDownload()}
|
2019-07-24 03:56:39 +08:00
|
|
|
{this.renderPresentationFullscreen()}
|
2019-07-18 08:30:28 +08:00
|
|
|
<svg
|
|
|
|
key={currentSlide.id}
|
|
|
|
data-test="whiteboard"
|
|
|
|
width={svgDimensions.width}
|
|
|
|
height={svgDimensions.height}
|
|
|
|
ref={(ref) => { if (ref != null) { this.svggroup = ref; } }}
|
|
|
|
viewBox={svgViewBox}
|
|
|
|
version="1.1"
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
className={styles.svgStyles}
|
|
|
|
>
|
|
|
|
<defs>
|
|
|
|
<clipPath id="viewBox">
|
|
|
|
<rect x={viewBoxPosition.x} y={viewBoxPosition.y} width="100%" height="100%" fill="none" />
|
|
|
|
</clipPath>
|
|
|
|
</defs>
|
|
|
|
<g clipPath="url(#viewBox)">
|
|
|
|
<Slide
|
|
|
|
imageUri={imageUri}
|
|
|
|
svgWidth={width}
|
|
|
|
svgHeight={height}
|
|
|
|
/>
|
|
|
|
<AnnotationGroupContainer
|
2019-02-08 01:47:28 +08:00
|
|
|
{...{
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
}}
|
2019-07-18 08:30:28 +08:00
|
|
|
whiteboardId={currentSlide.id}
|
|
|
|
/>
|
|
|
|
<CursorWrapperContainer
|
|
|
|
podId={podId}
|
|
|
|
whiteboardId={currentSlide.id}
|
|
|
|
widthRatio={widthRatio}
|
|
|
|
physicalWidthRatio={svgDimensions.width / width}
|
|
|
|
slideWidth={width}
|
|
|
|
slideHeight={height}
|
|
|
|
/>
|
|
|
|
</g>
|
|
|
|
{this.renderOverlays(
|
|
|
|
currentSlide,
|
|
|
|
svgDimensions,
|
|
|
|
viewBoxPosition,
|
|
|
|
viewBoxDimensions,
|
|
|
|
physicalDimensions,
|
|
|
|
)}
|
|
|
|
</svg>
|
2017-09-22 05:02:50 +08:00
|
|
|
</div>
|
|
|
|
);
|
2016-06-02 07:37:51 +08:00
|
|
|
}
|
|
|
|
|
2019-02-12 21:35:52 +08:00
|
|
|
renderPresentationToolbar() {
|
2017-09-19 07:54:52 +08:00
|
|
|
const {
|
2019-02-12 21:35:52 +08:00
|
|
|
currentSlide,
|
|
|
|
podId,
|
|
|
|
} = this.props;
|
2019-02-07 05:12:59 +08:00
|
|
|
|
2019-07-27 00:48:51 +08:00
|
|
|
const { zoom, fitToWidth, isFullscreen } = this.state;
|
2019-01-08 02:12:28 +08:00
|
|
|
|
2019-02-12 21:35:52 +08:00
|
|
|
if (!currentSlide) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-09-19 08:18:20 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<PresentationToolbarContainer
|
2019-03-11 01:21:48 +08:00
|
|
|
{...{
|
|
|
|
fitToWidth,
|
|
|
|
zoom,
|
|
|
|
podId,
|
|
|
|
}}
|
2019-03-13 01:05:32 +08:00
|
|
|
isFullscreen={isFullscreen}
|
2019-04-24 22:20:53 +08:00
|
|
|
fullscreenRef={this.refPresentationContainer}
|
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}
|
2017-09-19 08:18:20 +08:00
|
|
|
/>
|
|
|
|
);
|
2016-08-06 02:39:24 +08:00
|
|
|
}
|
|
|
|
|
2019-07-18 08:30:28 +08:00
|
|
|
renderWhiteboardToolbar(svgDimensions) {
|
2019-02-08 01:47:28 +08:00
|
|
|
const { currentSlide } = this.props;
|
|
|
|
if (!this.isPresentationAccessible()) return null;
|
2017-09-21 05:05:17 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<WhiteboardToolbarContainer
|
2019-02-08 01:47:28 +08:00
|
|
|
whiteboardId={currentSlide.id}
|
2019-07-18 08:30:28 +08:00
|
|
|
height={svgDimensions.height}
|
2017-09-21 05:05:17 +08:00
|
|
|
/>
|
|
|
|
);
|
2017-04-19 08:54:51 +08:00
|
|
|
}
|
|
|
|
|
2019-03-08 03:00:01 +08:00
|
|
|
renderPresentationDownload() {
|
|
|
|
const { presentationIsDownloadable, downloadPresentationUri } = this.props;
|
|
|
|
|
|
|
|
if (!presentationIsDownloadable) return null;
|
|
|
|
|
|
|
|
const handleDownloadPresentation = () => {
|
|
|
|
window.open(downloadPresentationUri);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<DownloadPresentationButton
|
|
|
|
handleDownloadPresentation={handleDownloadPresentation}
|
|
|
|
dark
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-03-12 00:21:12 +08:00
|
|
|
renderPresentationFullscreen() {
|
|
|
|
const {
|
|
|
|
intl,
|
|
|
|
userIsPresenter,
|
|
|
|
} = this.props;
|
2019-07-27 00:48:51 +08:00
|
|
|
const { isFullscreen } = this.state;
|
2019-07-24 03:56:39 +08:00
|
|
|
|
|
|
|
if (userIsPresenter || !ALLOW_FULLSCREEN) return null;
|
2019-03-12 00:21:12 +08:00
|
|
|
|
|
|
|
return (
|
2019-04-24 22:20:53 +08:00
|
|
|
<FullscreenButtonContainer
|
|
|
|
fullscreenRef={this.refPresentationContainer}
|
2019-03-12 00:21:12 +08:00
|
|
|
elementName={intl.formatMessage(intlMessages.presentationLabel)}
|
2019-07-24 03:56:39 +08:00
|
|
|
isFullscreen={isFullscreen}
|
2019-03-12 00:21:12 +08:00
|
|
|
dark
|
2019-07-24 03:56:39 +08:00
|
|
|
bottom
|
2019-03-12 00:21:12 +08:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-02 07:37:51 +08:00
|
|
|
render() {
|
2019-03-12 00:21:12 +08:00
|
|
|
const {
|
|
|
|
userIsPresenter,
|
|
|
|
multiUser,
|
2019-08-01 03:10:41 +08:00
|
|
|
slidePosition,
|
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 {
|
|
|
|
showSlide,
|
|
|
|
fitToWidth,
|
2019-07-18 08:30:28 +08:00
|
|
|
presentationAreaWidth,
|
|
|
|
localPosition,
|
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
|
|
|
|
|
|
|
const toolbarHeight = this.getToolbarHeight();
|
|
|
|
|
2019-03-07 23:52:12 +08:00
|
|
|
let toolbarWidth = 0;
|
|
|
|
if (this.refWhiteboardArea) {
|
2019-07-18 08:30:28 +08:00
|
|
|
if (svgWidth === presentationAreaWidth
|
|
|
|
|| presentationAreaWidth <= 400
|
2019-03-12 21:56:05 +08:00
|
|
|
|| fitToWidth === true) {
|
2019-03-07 23:52:12 +08:00
|
|
|
toolbarWidth = '100%';
|
2019-07-18 08:30:28 +08:00
|
|
|
} else if (svgWidth <= 400
|
|
|
|
&& presentationAreaWidth > 400) {
|
|
|
|
toolbarWidth = '400px';
|
2019-03-07 23:52:12 +08:00
|
|
|
} else {
|
2019-07-18 08:30:28 +08:00
|
|
|
toolbarWidth = svgWidth;
|
2019-03-07 23:52:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-02 07:37:51 +08:00
|
|
|
return (
|
2019-01-26 00:21:05 +08:00
|
|
|
<div
|
|
|
|
ref={(ref) => { this.refPresentationContainer = ref; }}
|
2019-02-07 05:12:59 +08:00
|
|
|
className={styles.presentationContainer}
|
|
|
|
>
|
2017-07-29 08:29:40 +08:00
|
|
|
<div
|
2017-09-18 09:58:37 +08:00
|
|
|
ref={(ref) => { this.refPresentationArea = ref; }}
|
|
|
|
className={styles.presentationArea}
|
2017-07-29 08:29:40 +08:00
|
|
|
>
|
2017-03-24 05:52:36 +08:00
|
|
|
<div
|
2017-09-18 09:58:37 +08:00
|
|
|
ref={(ref) => { this.refWhiteboardArea = ref; }}
|
2017-07-29 08:29:40 +08:00
|
|
|
className={styles.whiteboardSizeAvailable}
|
|
|
|
/>
|
2019-02-19 20:27:54 +08:00
|
|
|
<div
|
|
|
|
className={styles.svgContainer}
|
|
|
|
style={{
|
2019-07-18 08:30:28 +08:00
|
|
|
height: svgHeight + toolbarHeight,
|
2019-02-19 20:27:54 +08:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{showSlide
|
2019-07-18 08:30:28 +08:00
|
|
|
? this.renderPresentationArea(svgDimensions, viewBoxDimensions)
|
2019-02-19 20:27:54 +08:00
|
|
|
: null}
|
2019-07-18 08:30:28 +08:00
|
|
|
{showSlide && (userIsPresenter || multiUser)
|
|
|
|
? this.renderWhiteboardToolbar(svgDimensions)
|
2019-02-19 20:27:54 +08:00
|
|
|
: null}
|
2019-07-18 08:30:28 +08:00
|
|
|
{showSlide && userIsPresenter
|
2019-02-19 20:27:54 +08:00
|
|
|
? (
|
|
|
|
<div
|
|
|
|
className={styles.presentationToolbar}
|
|
|
|
ref={(ref) => { this.refPresentationToolbar = ref; }}
|
2019-03-07 05:57:07 +08:00
|
|
|
style={
|
|
|
|
{
|
2019-03-07 23:52:12 +08:00
|
|
|
width: toolbarWidth,
|
2019-03-07 05:57:07 +08:00
|
|
|
}
|
|
|
|
}
|
2019-02-19 20:27:54 +08:00
|
|
|
>
|
|
|
|
{this.renderPresentationToolbar()}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
: null}
|
|
|
|
</div>
|
2017-07-29 08:29:40 +08:00
|
|
|
</div>
|
2016-05-31 06:07:02 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-12 00:21:12 +08:00
|
|
|
export default injectIntl(PresentationArea);
|
2019-02-07 05:12:59 +08:00
|
|
|
|
2017-07-29 08:29:40 +08:00
|
|
|
PresentationArea.propTypes = {
|
2019-03-12 00:21:12 +08:00
|
|
|
intl: intlShape.isRequired,
|
2018-04-12 04:05:30 +08:00
|
|
|
podId: PropTypes.string.isRequired,
|
2017-07-29 08:29:40 +08:00
|
|
|
// Defines a boolean value to detect whether a current user is a presenter
|
|
|
|
userIsPresenter: PropTypes.bool.isRequired,
|
|
|
|
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,
|
|
|
|
}),
|
|
|
|
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,
|
2016-05-31 06:07:02 +08:00
|
|
|
};
|
2017-08-19 10:47:31 +08:00
|
|
|
|
|
|
|
PresentationArea.defaultProps = {
|
|
|
|
currentSlide: undefined,
|
2019-08-01 03:10:41 +08:00
|
|
|
slidePosition: undefined,
|
2017-08-19 10:47:31 +08:00
|
|
|
};
|