import React from 'react';
import {
HTMLContainer,
Rectangle2d,
ShapeUtil,
TLOnResizeHandler,
getDefaultColorTheme,
resizeBox,
} from '@bigbluebutton/tldraw';
import { pollShapeMigrations } from './poll-shape-migrations';
import { pollShapeProps } from './poll-shape-props';
import { IPollShape } from './poll-shape-types';
import ChatPollContent from '/imports/ui/components/chat/chat-graphql/chat-message-list/page/chat-message/message-content/poll-content/component';
export class PollShapeUtil extends ShapeUtil {
static override type = 'poll' as const;
static override props = pollShapeProps;
static override migrations = pollShapeMigrations;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
override isAspectRatioLocked = (_shape: IPollShape) => false;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
override canResize = (_shape: IPollShape) => true;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
override canBind = (_shape: IPollShape) => true;
getDefaultProps(): IPollShape['props'] {
return {
w: 300,
h: 300,
color: 'black',
fill: 'white',
question: '',
numRespondents: 0,
numResponders: 0,
questionText: '',
questionType: '',
answers: [],
};
}
// eslint-disable-next-line class-methods-use-this
getGeometry(shape: IPollShape) {
return new Rectangle2d({
width: shape.props.w,
height: shape.props.h,
isFilled: true,
});
}
component(shape: IPollShape) {
const { bounds } = this.editor.getShapeGeometry(shape);
const theme = getDefaultColorTheme({
isDarkMode: this.editor.user.getIsDarkMode(),
});
const contentRef = React.useRef(null);
const pollMetadata = JSON.stringify({
id: shape.id,
question: shape.props.question,
numRespondents: shape.props.numRespondents,
numResponders: shape.props.numResponders,
questionText: shape.props.questionText,
questionType: shape.props.questionType,
answers: shape.props.answers,
});
const adjustedHeight = shape.props.questionText.length > 0 ? bounds.height - 75 : bounds.height;
return (
);
}
// eslint-disable-next-line class-methods-use-this
indicator(shape: IPollShape) {
return ;
}
override onResize: TLOnResizeHandler = (shape, info) => {
return resizeBox(shape, info);
}
}
export default PollShapeUtil;