bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/presentation/component.jsx

1059 lines
32 KiB
React
Raw Normal View History

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
2022-04-05 22:49:13 +08:00
import WhiteboardOverlayContainer from '/imports/ui/components/whiteboard/whiteboard-overlay/container'
import WhiteboardContainer from '/imports/ui/components/whiteboard/container';
2017-04-19 08:54:51 +08:00
import WhiteboardToolbarContainer from '/imports/ui/components/whiteboard/whiteboard-toolbar/container';
import { HUNDRED_PERCENT, MAX_PERCENT } from '/imports/utils/slideCalcUtils';
import { defineMessages, injectIntl } from 'react-intl';
import { toast } from 'react-toastify';
import { Session } from 'meteor/session';
import PresentationToolbarContainer from './presentation-toolbar/container';
import PresentationPlaceholder from './presentation-placeholder/component';
import PresentationMenu from './presentation-menu/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';
import PresentationOverlayContainer from './presentation-overlay/container';
import Slide from './slide/component';
2021-11-09 01:28:22 +08:00
import Styled from './styles';
2022-04-05 22:49:13 +08:00
import MediaService, { shouldEnableSwapLayout } from '../media/service';
// import PresentationCloseButton from './presentation-close-button/component';
import DownloadPresentationButton from './download-presentation-button/component';
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';
import PollingContainer from '/imports/ui/components/polling/container';
import { ACTIONS, LAYOUT_TYPE } from '../layout/enums';
import DEFAULT_VALUES from '../layout/defaultValues';
import { colorContentBackground } from '/imports/ui/stylesheets/styled-components/palette';
import browserInfo from '/imports/utils/browserInfo';
import { addNewAlert } from '../screenreader-alert/service';
import { clearCursors } from '/imports/ui/components/cursor/service';
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',
},
downloadLabel: {
2020-09-02 21:30:44 +08:00
id: 'app.presentation.downloadLabel',
description: 'label for downloadable presentations',
},
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',
},
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',
},
2019-03-12 00:21:12 +08:00
});
2022-04-05 22:49:13 +08:00
const ALLOW_FULLSCREEN = Meteor.settings.public.app.allowFullscreen;
const OLD_MINIMIZE_BUTTON_ENABLED = Meteor.settings.public.presentation.oldMinimizeButton;
const { isSafari } = browserInfo;
const FULLSCREEN_CHANGE_EVENT = isSafari ? 'webkitfullscreenchange' : 'fullscreenchange';
2021-06-09 21:49:59 +08:00
class Presentation extends PureComponent {
constructor() {
super();
this.state = {
2021-06-09 21:49:59 +08:00
presentationWidth: 0,
presentationHeight: 0,
showSlide: false,
zoom: 100,
2018-09-25 20:47:49 +08:00
fitToWidth: false,
2019-07-27 00:48:51 +08:00
isFullscreen: false,
2022-05-16 10:35:17 +08:00
tldrawAPI: null,
isZoomed: false,
};
this.currentPresentationToastId = null;
this.getSvgRef = this.getSvgRef.bind(this);
this.setFitToWidth = this.setFitToWidth.bind(this);
this.zoomChanger = this.zoomChanger.bind(this);
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);
this.getPresentationSizesAvailable = this.getPresentationSizesAvailable.bind(this);
this.handleResize = this.handleResize.bind(this);
2022-05-16 10:35:17 +08:00
this.setTldrawAPI = this.setTldrawAPI.bind(this);
this.renderPresentationMenu = this.renderPresentationMenu.bind(this);
this.setIsZoomed = this.setIsZoomed.bind(this);
2019-07-30 23:03:29 +08:00
this.onResize = () => setTimeout(this.handleResize.bind(this), 0);
this.renderCurrentPresentationToast = this.renderCurrentPresentationToast.bind(this);
this.setPresentationRef = this.setPresentationRef.bind(this);
Session.set('componentPresentationWillUnmount', false);
}
static getDerivedStateFromProps(props, state) {
const { prevProps } = state;
const stateChange = { prevProps: props };
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));
stateChange.zoom = potentialZoom;
}
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
}
return stateChange;
2019-03-20 03:50:08 +08:00
}
componentDidMount() {
this.getInitialPresentationSizes();
this.refPresentationContainer
.addEventListener(FULLSCREEN_CHANGE_EVENT, this.onFullscreenChange);
2020-04-23 22:07:44 +08:00
window.addEventListener('resize', this.onResize, false);
2021-05-18 04:25:07 +08:00
const {
2021-08-05 19:03:24 +08:00
currentSlide, slidePosition, layoutContextDispatch,
2021-05-18 04:25:07 +08:00
} = this.props;
2020-09-02 21:30:44 +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,
},
});
}
}
componentDidUpdate(prevProps) {
const {
currentPresentation,
slidePosition,
presentationIsOpen,
currentSlide,
publishedPoll,
isViewer,
setPresentationIsOpen,
restoreOnUpdate,
2020-04-23 22:07:44 +08:00
layoutContextDispatch,
userIsPresenter,
presentationBounds,
numCameras,
intl,
multiUser,
clearFakeAnnotations,
} = this.props;
2020-04-23 22:07:44 +08:00
2022-04-06 01:37:52 +08:00
const { presentationWidth, presentationHeight } = this.state;
const {
numCameras: prevNumCameras,
presentationBounds: prevPresentationBounds,
multiUser: prevMultiUser,
} = prevProps;
2020-06-09 11:09:46 +08:00
if (prevMultiUser && !multiUser) {
clearFakeAnnotations();
clearCursors();
}
if (numCameras !== prevNumCameras) {
2020-06-09 11:09:46 +08:00
this.onResize();
}
2022-01-25 01:52:24 +08:00
if (
currentSlide?.num != null
&& prevProps?.currentSlide?.num != null
&& currentSlide?.num !== prevProps.currentSlide?.num
2022-01-25 01:52:24 +08:00
) {
addNewAlert(intl.formatMessage(intlMessages.slideContentChanged, { 0: currentSlide.num }));
}
2022-03-11 22:57:43 +08:00
if (currentPresentation) {
const downloadableOn = !prevProps?.currentPresentation?.downloadable
2021-05-18 04:25:07 +08:00
&& currentPresentation.downloadable;
const shouldCloseToast = !(currentPresentation.downloadable && !userIsPresenter);
if (
2022-03-11 22:57:43 +08:00
prevProps?.currentPresentation?.name !== currentPresentation.name
2021-05-18 04:25:07 +08:00
|| (downloadableOn && !userIsPresenter)
) {
if (this.currentPresentationToastId) {
toast.update(this.currentPresentationToastId, {
autoClose: shouldCloseToast,
render: this.renderCurrentPresentationToast(),
});
} else {
this.currentPresentationToastId = toast(this.renderCurrentPresentationToast(), {
onClose: () => { this.currentPresentationToastId = null; },
autoClose: shouldCloseToast,
className: 'actionToast',
2021-05-18 04:25:07 +08:00
});
}
}
2022-03-11 22:57:43 +08:00
const downloadableOff = prevProps?.currentPresentation?.downloadable
2021-05-18 04:25:07 +08:00
&& !currentPresentation.downloadable;
2021-05-18 04:25:07 +08:00
if (this.currentPresentationToastId && downloadableOff) {
toast.update(this.currentPresentationToastId, {
2021-05-18 04:25:07 +08:00
autoClose: true,
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,
},
});
}
if (!presentationIsOpen && restoreOnUpdate && !userIsPresenter && currentSlide) {
2021-05-18 04:25:07 +08:00
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) {
setPresentationIsOpen(layoutContextDispatch, !presentationIsOpen);
2021-05-18 04:25:07 +08:00
}
}
2021-05-18 04:25:07 +08:00
2022-04-06 01:37:52 +08:00
if ((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,
});
}
2019-03-20 03:50:08 +08:00
}
componentWillUnmount() {
Session.set('componentPresentationWillUnmount', true);
const { fullscreenContext, layoutContextDispatch } = this.props;
2020-04-23 22:07:44 +08:00
window.removeEventListener('resize', this.onResize, false);
this.refPresentationContainer
.removeEventListener(FULLSCREEN_CHANGE_EVENT, this.onFullscreenChange);
if (fullscreenContext) {
layoutContextDispatch({
type: ACTIONS.SET_FULLSCREEN_ELEMENT,
value: {
element: '',
group: '',
},
});
}
}
2022-05-16 10:35:17 +08:00
setTldrawAPI(api) {
this.setState({
tldrawAPI: api,
})
}
setIsZoomed(isZoomed) {
this.setState({
isZoomed,
})
}
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
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;
const newIsFullscreen = FullscreenService.isFullScreen(this.refPresentationContainer);
if (isFullscreen !== newIsFullscreen) {
this.setState({ isFullscreen: newIsFullscreen });
}
}
setPresentationRef(ref) {
this.refPresentationContainer = ref;
}
// 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;
}
getToolbarHeight() {
let height = 0;
const toolbarEl = document.getElementById('presentationToolbarWrapper');
if (toolbarEl) {
const { clientHeight } = toolbarEl;
height = clientHeight;
}
return height;
}
2017-09-18 09:58:37 +08:00
getPresentationSizesAvailable() {
const {
presentationBounds,
2021-06-09 21:49:59 +08:00
presentationAreaSize: newPresentationAreaSize,
} = this.props;
const presentationSizes = {
2021-06-09 21:49:59 +08:00
presentationWidth: 0,
presentationHeight: 0,
};
2021-08-05 12:22:07 +08:00
if (newPresentationAreaSize) {
2021-06-09 21:49:59 +08:00
presentationSizes.presentationWidth = newPresentationAreaSize.presentationAreaWidth;
2021-08-05 12:22:07 +08:00
presentationSizes.presentationHeight = newPresentationAreaSize
.presentationAreaHeight - (this.getToolbarHeight() || 0);
2021-06-09 21:49:59 +08:00
return presentationSizes;
}
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
// 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
this.setState({
2021-06-09 21:49:59 +08:00
presentationHeight: presentationSizes.presentationHeight,
presentationWidth: presentationSizes.presentationWidth,
showSlide: true,
});
2017-09-06 09:36:15 +08:00
}
}
setFitToWidth(fitToWidth) {
this.setState({ fitToWidth });
}
calculateSize(viewBoxDimensions) {
const {
2021-06-09 21:49:59 +08:00
presentationHeight,
presentationWidth,
fitToWidth,
} = this.state;
const {
userIsPresenter,
currentSlide,
slidePosition,
} = this.props;
if (!currentSlide || !slidePosition) {
return { width: 0, height: 0 };
}
const originalWidth = slidePosition.width;
const originalHeight = slidePosition.height;
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;
} else {
2021-06-09 21:49:59 +08:00
svgHeight = presentationHeight;
}
} else if (!fitToWidth) {
2021-06-09 21:49:59 +08:00
svgWidth = (presentationHeight * originalWidth) / originalHeight;
if (presentationWidth < svgWidth) {
svgHeight = (presentationHeight * presentationWidth) / svgWidth;
svgWidth = presentationWidth;
} else {
2021-06-09 21:49:59 +08:00
svgHeight = presentationHeight;
}
2019-03-20 03:50:08 +08:00
} else {
2021-06-09 21:49:59 +08:00
svgWidth = presentationWidth;
svgHeight = (svgWidth * originalHeight) / originalWidth;
2021-06-09 21:49:59 +08:00
if (svgHeight > presentationHeight) svgHeight = presentationHeight;
}
2021-03-04 02:59:34 +08:00
if (typeof svgHeight !== 'number' || typeof svgWidth !== 'number') {
return { width: 0, height: 0 };
}
return {
width: svgWidth,
height: svgHeight,
};
}
zoomChanger(zoom) {
this.setState({ zoom });
2018-09-18 02:02:52 +08:00
}
2018-09-25 20:47:49 +08:00
fitToWidthHandler() {
const {
fitToWidth,
} = this.state;
2019-02-12 21:35:52 +08:00
this.setState({
fitToWidth: !fitToWidth,
zoom: HUNDRED_PERCENT,
2019-02-12 21:35:52 +08:00
});
2019-02-08 01:47:28 +08:00
}
isPresentationAccessible() {
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
}
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);
}
renderPresentationClose() {
const { isFullscreen } = this.state;
const {
layoutType,
fullscreenContext,
layoutContextDispatch,
isIphone,
2022-04-05 22:49:13 +08:00
// <<<<<<< HEAD
// presentationIsOpen,
// } = this.props;
// if (isFullscreen
// =======
} = this.props;
2022-04-05 22:49:13 +08:00
if (!OLD_MINIMIZE_BUTTON_ENABLED
|| !shouldEnableSwapLayout()
|| isFullscreen
// >>>>>>> embed Tldraw into BBB client
|| fullscreenContext
|| layoutType === LAYOUT_TYPE.PRESENTATION_FOCUS) {
return null;
}
}
renderOverlays(slideObj, svgDimensions, viewBoxPosition, viewBoxDimensions, physicalDimensions) {
2019-02-12 21:35:52 +08:00
const {
userIsPresenter,
multiUser,
podId,
currentSlide,
slidePosition,
2019-02-12 21:35:52 +08:00
} = this.props;
const {
zoom,
fitToWidth,
isZoomed,
2019-02-12 21:35:52 +08:00
} = this.state;
if (!userIsPresenter && !multiUser) {
return null;
}
// retrieving the pre-calculated data from the slide object
const {
width,
height,
} = slidePosition;
2019-02-12 21:35:52 +08:00
return (
<PresentationOverlayContainer
podId={podId}
userIsPresenter={userIsPresenter}
2019-02-12 21:35:52 +08:00
currentSlideNum={currentSlide.num}
slide={slideObj}
slideWidth={width}
slideHeight={height}
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}
updateLocalPosition={this.updateLocalPosition}
panAndZoomChanger={this.panAndZoomChanger}
2019-02-12 21:35:52 +08:00
getSvgRef={this.getSvgRef}
fitToWidth={fitToWidth}
>
<WhiteboardOverlayContainer
getSvgRef={this.getSvgRef}
userIsPresenter={userIsPresenter}
2019-02-12 21:35:52 +08:00
whiteboardId={slideObj.id}
slide={slideObj}
2019-02-12 21:35:52 +08:00
slideWidth={width}
slideHeight={height}
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}
setIsZoomed={this.setIsZoomed}
isZoomed={isZoomed}
2019-02-12 21:35:52 +08:00
/>
</PresentationOverlayContainer>
);
}
// renders the whole presentation area
2021-06-09 21:49:59 +08:00
renderPresentation(svgDimensions, viewBoxDimensions) {
const {
2020-08-20 09:48:10 +08:00
intl,
podId,
currentSlide,
slidePosition,
userIsPresenter,
presentationIsOpen,
} = this.props;
2019-02-08 01:47:28 +08:00
const {
localPosition,
} = this.state;
if (!this.isPresentationAccessible()) {
return null;
}
// retrieving the pre-calculated data from the slide object
const {
width,
height,
} = slidePosition;
const {
imageUri,
2020-08-20 09:48:10 +08:00
content,
} = currentSlide;
2019-02-12 21:35:52 +08:00
let viewBoxPosition;
if (userIsPresenter && localPosition) {
viewBoxPosition = {
x: localPosition.x,
y: localPosition.y,
};
} else {
viewBoxPosition = {
x: slidePosition.x,
y: slidePosition.y,
2019-02-12 21:35:52 +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} `
2019-12-19 05:35:03 +08:00
+ `${viewBoxDimensions.width} ${Number.isNaN(viewBoxDimensions.height) ? 0 : viewBoxDimensions.height}`;
2019-02-12 21:35:52 +08:00
2020-08-20 09:48:10 +08:00
const slideContent = content ? `${intl.formatMessage(intlMessages.slideContentStart)}
${content}
${intl.formatMessage(intlMessages.slideContentEnd)}` : intl.formatMessage(intlMessages.noSlideContent);
return (
<div
style={{
position: 'absolute',
width: svgDimensions.width < 0 ? 0 : svgDimensions.width,
height: svgDimensions.height < 0 ? 0 : svgDimensions.height,
textAlign: 'center',
display: !presentationIsOpen ? 'none' : 'block',
}}
>
2021-11-09 01:28:22 +08:00
<Styled.VisuallyHidden id="currentSlideText">{slideContent}</Styled.VisuallyHidden>
{/* {this.renderPresentationClose()}
{this.renderPresentationDownload()}
{this.renderPresentationFullscreen()} */}
{this.renderPresentationMenu()}
2021-11-09 01:28:22 +08:00
<Styled.PresentationSvg
key={currentSlide.id}
data-test={!presentationIsOpen ? 'hiddenWhiteboard' : 'whiteboard'}
width={svgDimensions.width < 0 ? 0 : svgDimensions.width}
height={svgDimensions.height < 0 ? 0 : svgDimensions.height}
ref={(ref) => { if (ref != null) { this.svggroup = ref; } }}
viewBox={svgViewBox}
version="1.1"
xmlns="http://www.w3.org/2000/svg"
>
<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,
}}
2020-04-07 04:34:08 +08:00
published
whiteboardId={currentSlide.id}
/>
<AnnotationGroupContainer
{...{
width,
height,
}}
published={false}
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,
)}
2021-11-09 01:28:22 +08:00
</Styled.PresentationSvg>
</div>
);
}
2022-05-16 10:35:17 +08:00
renderPresentationToolbar(svgWidth = 0) {
const {
2019-02-12 21:35:52 +08:00
currentSlide,
podId,
isMobile,
layoutType,
numCameras,
fullscreenElementId,
fullscreenContext,
layoutContextDispatch,
presentationIsOpen,
slidePosition,
2019-02-12 21:35:52 +08:00
} = this.props;
const { zoom, fitToWidth } = this.state;
if (!currentSlide) return null;
const { presentationToolbarMinWidth } = DEFAULT_VALUES;
const toolbarWidth = ((this.refWhiteboardArea && svgWidth > presentationToolbarMinWidth)
|| isMobile
|| (layoutType === LAYOUT_TYPE.VIDEO_FOCUS && numCameras > 0))
? svgWidth
: presentationToolbarMinWidth;
return (
<PresentationToolbarContainer
{...{
fitToWidth,
zoom,
podId,
currentSlide,
slidePosition,
toolbarWidth,
fullscreenElementId,
layoutContextDispatch,
presentationIsOpen,
}}
isZoomed={this.state.isZoomed}
2022-05-16 10:35:17 +08:00
tldrawAPI={this.state.tldrawAPI}
curPageId={this.state.tldrawAPI?.getPage()?.id}
2019-02-08 01:47:28 +08:00
currentSlideNum={currentSlide.num}
presentationId={currentSlide.presentationId}
zoomChanger={this.zoomChanger}
2018-09-25 20:47:49 +08:00
fitToWidthHandler={this.fitToWidthHandler}
isFullscreen={fullscreenContext}
fullscreenAction={ACTIONS.SET_FULLSCREEN_ELEMENT}
fullscreenRef={this.refPresentationContainer}
addWhiteboardGlobalAccess={this.props.addWhiteboardGlobalAccess}
removeWhiteboardGlobalAccess={this.props.removeWhiteboardGlobalAccess}
multiUserSize={this.props.multiUserSize}
multiUser={this.props.multiUser}
whiteboardId={currentSlide?.id}
/>
);
2016-08-06 02:39:24 +08:00
}
renderWhiteboardToolbar(svgDimensions) {
const { currentSlide, userIsPresenter } = this.props;
2019-02-08 01:47:28 +08:00
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}
height={svgDimensions.height}
isPresenter={userIsPresenter}
2017-09-21 05:05:17 +08:00
/>
);
2017-04-19 08:54:51 +08:00
}
renderPresentationDownload() {
const { presentationIsDownloadable, downloadPresentationUri } = this.props;
if (!presentationIsDownloadable) return null;
const handleDownloadPresentation = () => {
window.open(downloadPresentationUri);
};
return (
<DownloadPresentationButton
handleDownloadPresentation={handleDownloadPresentation}
dark
/>
);
}
2022-04-05 22:49:13 +08:00
renderPresentationFullscreen() {
2019-03-12 00:21:12 +08:00
const {
intl,
2021-07-06 19:28:17 +08:00
fullscreenElementId,
2019-03-12 00:21:12 +08:00
} = this.props;
const { isFullscreen } = this.state;
2022-04-05 22:49:13 +08:00
if (!ALLOW_FULLSCREEN) return null;
2019-03-12 00:21:12 +08:00
return (
2022-04-05 22:49:13 +08:00
<Styled.PresentationFullscreenButton
fullscreenRef={this.refPresentationContainer}
2019-03-12 00:21:12 +08:00
elementName={intl.formatMessage(intlMessages.presentationLabel)}
2021-07-06 19:28:17 +08:00
elementId={fullscreenElementId}
2022-04-05 22:49:13 +08:00
isFullscreen={isFullscreen}
color="muted"
fullScreenStyle={false}
2019-03-12 00:21:12 +08:00
/>
);
}
renderCurrentPresentationToast() {
const {
intl, currentPresentation, userIsPresenter, downloadPresentationUri,
} = this.props;
const { downloadable } = currentPresentation;
return (
2021-11-09 01:28:22 +08:00
<Styled.InnerToastWrapper>
<Styled.ToastIcon>
<Styled.IconWrapper>
<Icon iconName="presentation" />
2021-11-09 01:28:22 +08:00
</Styled.IconWrapper>
</Styled.ToastIcon>
2021-11-09 01:28:22 +08:00
<Styled.ToastTextContent data-test="toastSmallMsg">
<div>{`${intl.formatMessage(intlMessages.changeNotification)}`}</div>
2021-11-09 01:28:22 +08:00
<Styled.PresentationName>{`${currentPresentation.name}`}</Styled.PresentationName>
</Styled.ToastTextContent>
{downloadable && !userIsPresenter
? (
2021-11-09 01:28:22 +08:00
<Styled.ToastDownload>
2021-11-11 19:47:39 +08:00
<Styled.ToastSeparator />
<a
data-test="toastDownload"
aria-label={`${intl.formatMessage(intlMessages.downloadLabel)} ${currentPresentation.name}`}
href={downloadPresentationUri}
target="_blank"
rel="noopener noreferrer"
>
{intl.formatMessage(intlMessages.downloadLabel)}
</a>
2021-11-09 01:28:22 +08:00
</Styled.ToastDownload>
2021-05-18 04:25:07 +08:00
) : null}
2021-11-09 01:28:22 +08:00
</Styled.InnerToastWrapper>
);
}
renderPresentationMenu() {
const {
intl,
fullscreenElementId,
layoutContextDispatch,
} = this.props;
return (
<PresentationMenu
fullscreenRef={this.refPresentationContainer}
2022-07-26 22:54:50 +08:00
tldrawAPI={this.state.tldrawAPI}
elementName={intl.formatMessage(intlMessages.presentationLabel)}
elementId={fullscreenElementId}
toggleSwapLayout={MediaService.toggleSwapLayout}
layoutContextDispatch={layoutContextDispatch}
/>
);
}
render() {
2019-03-12 00:21:12 +08:00
const {
userIsPresenter,
2022-05-07 00:37:43 +08:00
currentSlide,
2019-03-12 00:21:12 +08:00
multiUser,
slidePosition,
presentationBounds,
fullscreenContext,
isMobile,
layoutType,
numCameras,
currentPresentation,
layoutSwapped,
2022-05-12 05:58:16 +08:00
podId,
intl,
2022-06-02 23:00:28 +08:00
isViewersCursorLocked,
fullscreenElementId,
layoutContextDispatch,
2019-03-12 00:21:12 +08:00
} = this.props;
2019-03-12 21:56:05 +08:00
const {
showSlide,
isFullscreen,
localPosition,
isZoomed,
presentationWidth,
presentationHeight,
2019-03-12 21:56:05 +08:00
} = this.state;
2019-02-08 01:47: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) {
viewBoxDimensions = {
width: slidePosition.viewBoxWidth,
height: slidePosition.viewBoxHeight,
};
2019-08-02 01:50:39 +08:00
} else {
viewBoxDimensions = {
width: 0,
height: 0,
};
}
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();
const { presentationToolbarMinWidth } = DEFAULT_VALUES;
const isLargePresentation = (svgWidth > presentationToolbarMinWidth || isMobile)
&& !(layoutType === LAYOUT_TYPE.VIDEO_FOCUS && numCameras > 0 && !fullscreenContext);
const containerWidth = isLargePresentation
? svgWidth
: presentationToolbarMinWidth;
if (!currentPresentation && this.refPresentationContainer) {
return (
<></>
// <PresentationPlaceholder
// {
// ...presentationBounds
// }
// setPresentationRef={this.setPresentationRef}
// />
);
}
2022-04-05 22:49:13 +08:00
return (
<>
2022-04-05 22:49:13 +08:00
<Styled.PresentationContainer
role="region"
data-test="presentationContainer"
2022-04-05 22:49:13 +08:00
ref={(ref) => { this.refPresentationContainer = ref; }}
style={{
top: presentationBounds.top,
left: presentationBounds.left,
right: presentationBounds.right,
width: presentationBounds.width,
height: presentationBounds.height,
display: layoutSwapped ? 'none' : 'flex',
overflow: 'hidden',
zIndex: fullscreenContext ? presentationBounds.zIndex : undefined,
background: layoutType === LAYOUT_TYPE.VIDEO_FOCUS && numCameras > 0 && !fullscreenContext
? colorContentBackground
: null,
}}
>
{this.renderPresentationMenu()}
<WhiteboardContainer
2022-05-11 08:22:30 +08:00
whiteboardId={currentSlide?.id}
2022-05-12 05:58:16 +08:00
podId={podId}
slidePosition={slidePosition}
2022-05-07 00:37:43 +08:00
getSvgRef={this.getSvgRef}
2022-05-16 10:35:17 +08:00
setTldrawAPI={this.setTldrawAPI}
curPageId={currentSlide?.num.toString()}
svgUri={currentSlide?.svgUri}
intl={intl}
presentationWidth={presentationWidth}
presentationHeight={presentationHeight}
2022-06-02 23:00:28 +08:00
isViewersCursorLocked={isViewersCursorLocked}
isZoomed={isZoomed}
setIsZoomed={this.setIsZoomed}
zoomChanger={this.zoomChanger}
2022-05-07 00:37:43 +08:00
/>
2022-04-05 22:49:13 +08:00
{isFullscreen && <PollingContainer />}
2022-05-16 10:35:17 +08:00
{this.renderPresentationToolbar()}
2022-04-05 22:49:13 +08:00
{/*
2021-11-09 01:28:22 +08:00
<Styled.Presentation ref={(ref) => { this.refPresentation = ref; }}>
<Styled.WhiteboardSizeAvailable ref={(ref) => { this.refWhiteboardArea = ref; }} />
<Styled.SvgContainer
2019-02-19 20:27:54 +08:00
style={{
height: svgHeight + toolbarHeight,
2019-02-19 20:27:54 +08:00
}}
>
2021-03-04 02:59:34 +08:00
{showSlide && svgWidth > 0 && svgHeight > 0
2021-06-09 21:49:59 +08:00
? this.renderPresentation(svgDimensions, viewBoxDimensions)
2019-02-19 20:27:54 +08:00
: null}
{showSlide && (userIsPresenter || multiUser)
? this.renderWhiteboardToolbar(svgDimensions)
2019-02-19 20:27:54 +08:00
: null}
{showSlide && userIsPresenter
2019-02-19 20:27:54 +08:00
? (
2021-11-09 01:28:22 +08:00
<Styled.PresentationToolbar
2019-02-19 20:27:54 +08:00
ref={(ref) => { this.refPresentationToolbar = ref; }}
2019-03-07 05:57:07 +08:00
style={
{
width: containerWidth,
2019-03-07 05:57:07 +08:00
}
}
2019-02-19 20:27:54 +08:00
>
{this.renderPresentationToolbar(svgWidth)}
2021-11-09 01:28:22 +08:00
</Styled.PresentationToolbar>
2019-02-19 20:27:54 +08:00
)
: null}
2021-11-09 01:28:22 +08:00
</Styled.SvgContainer>
2022-04-05 22:49:13 +08:00
</Styled.Presentation> */}
2022-06-02 23:00:28 +08:00
</Styled.PresentationContainer>
</>
);
}
}
export default injectIntl(Presentation);
2021-06-09 21:49:59 +08:00
Presentation.propTypes = {
podId: PropTypes.string.isRequired,
// Defines a boolean value to detect whether a current user is a presenter
userIsPresenter: PropTypes.bool.isRequired,
currentSlide: PropTypes.shape({
presentationId: PropTypes.string.isRequired,
current: PropTypes.bool.isRequired,
num: PropTypes.number.isRequired,
id: PropTypes.string.isRequired,
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-08-15 08:15:11 +08:00
// current multi-user status
multiUser: PropTypes.bool.isRequired,
};
2021-06-09 21:49:59 +08:00
Presentation.defaultProps = {
currentSlide: undefined,
slidePosition: undefined,
2022-05-07 00:37:43 +08:00
};