Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

WhiteboardWrapper.tsx 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { ExcalidrawApp } from '@jitsi/excalidraw';
  2. import i18next from 'i18next';
  3. import React, { useCallback, useRef } from 'react';
  4. import { WHITEBOARD_UI_OPTIONS } from '../../constants';
  5. /**
  6. * Whiteboard wrapper for mobile.
  7. *
  8. * @returns {JSX.Element}
  9. */
  10. const WhiteboardWrapper = ({
  11. className,
  12. collabDetails,
  13. collabServerUrl,
  14. localParticipantName
  15. }: {
  16. className?: string;
  17. collabDetails: {
  18. roomId: string;
  19. roomKey: string;
  20. };
  21. collabServerUrl: string;
  22. localParticipantName: string;
  23. }) => {
  24. const excalidrawRef = useRef<any>(null);
  25. const excalidrawAPIRef = useRef<any>(null);
  26. const collabAPIRef = useRef<any>(null);
  27. const getExcalidrawAPI = useCallback(excalidrawAPI => {
  28. if (excalidrawAPIRef.current) {
  29. return;
  30. }
  31. excalidrawAPIRef.current = excalidrawAPI;
  32. }, []);
  33. const getCollabAPI = useCallback(collabAPI => {
  34. if (collabAPIRef.current) {
  35. return;
  36. }
  37. collabAPIRef.current = collabAPI;
  38. collabAPIRef.current.setUsername(localParticipantName);
  39. }, [ localParticipantName ]);
  40. return (
  41. <div className = { className }>
  42. <div className = 'excalidraw-wrapper'>
  43. <ExcalidrawApp
  44. collabDetails = { collabDetails }
  45. collabServerUrl = { collabServerUrl }
  46. detectScroll = { true }
  47. excalidraw = {{
  48. isCollaborating: true,
  49. langCode: i18next.language,
  50. // @ts-ignore
  51. ref: excalidrawRef,
  52. theme: 'light',
  53. UIOptions: WHITEBOARD_UI_OPTIONS
  54. }}
  55. getCollabAPI = { getCollabAPI }
  56. getExcalidrawAPI = { getExcalidrawAPI } />
  57. </div>
  58. </div>
  59. );
  60. };
  61. export default WhiteboardWrapper;