refactor(whiteboard): remove unused code

This commit is contained in:
João Victor 2024-02-06 11:32:38 -03:00
parent b46464e94a
commit de8dbae3a0
3 changed files with 2 additions and 79 deletions

View File

@ -629,7 +629,6 @@ class App extends Component {
<SidebarContentContainer isSharedNotesPinned={shouldShowSharedNotes} />
<NavBarContainer main="new" />
<WebcamContainer isLayoutSwapped={!presentationIsOpen} layoutType={selectedLayout} />
<Styled.TextMeasure id="text-measure" />
<ExternalVideoPlayerContainer />
{shouldShowPresentation ? <PresentationContainer setPresentationFitToWidth={this.setPresentationFitToWidth} fitToWidth={presentationFitToWidth} darkTheme={darkTheme} presentationIsOpen={presentationIsOpen} layoutType={selectedLayout} /> : null}
{shouldShowScreenshare ? <ScreenshareContainer isLayoutSwapped={!presentationIsOpen} isPresenter={isPresenter} /> : null}

View File

@ -68,25 +68,6 @@ const DtfImages = `
svg
`;
const TextMeasure = styled.pre`
white-space: pre;
width: auto;
border: 1px solid red;
padding: 4px;
margin: 0px;
letter-spacing: -0.03em;
opacity: 0;
position: absolute;
top: -500px;
left: 0px;
z-index: 9999;
pointer-events: none;
user-select: none;
alignment-baseline: mathematical;
dominant-baseline: mathematical;
font-family: "Source Code Pro";
`;
export default {
CaptionsWrapper,
ActionsBar,
@ -94,5 +75,4 @@ export default {
DtfInvert,
DtfCss,
DtfImages,
TextMeasure,
};

View File

@ -100,67 +100,11 @@ const mapLanguage = (language) => {
}
};
/* getFontStyle adapted from tldraw source code
https://github.com/tldraw/tldraw/blob/55a8831a6b036faae0dfd77d6733a8f585f5ae23/packages/tldraw/src/state/shapes/shared/shape-styles.ts#L123 */
const getFontStyle = (style) => {
const fontSizes = {
small: 28,
medium: 48,
large: 96,
auto: 'auto',
};
const fontFaces = {
script: '"Caveat Brush"',
sans: '"Source Sans Pro"',
serif: '"Crimson Pro"',
mono: '"Source Code Pro"',
}
const fontSize = fontSizes[style.size];
const fontFace = fontFaces[style.font];
const { scale = 1 } = style;
return `${fontSize * scale}px/1 ${fontFace}`;
}
/* getMeasurementDiv and getTextSize adapted from tldraw source code
https://github.com/tldraw/tldraw/blob/55a8831a6b036faae0dfd77d6733a8f585f5ae23/packages/tldraw/src/state/shapes/shared/getTextSize.ts */
const getMeasurementDiv = (font) => {
// A div used for measurement
const pre = document.getElementById('text-measure');
pre.style.font = font;
return pre;
}
const getTextSize = (text, style, padding) => {
const font = getFontStyle(style);
if (!text) {
return [16, 32];
}
const melm = getMeasurementDiv(font);
melm.textContent = text;
if (!melm) {
// We're in SSR
return [10, 10];
}
// In tests, offsetWidth and offsetHeight will be 0
const width = melm.offsetWidth || 1;
const height = melm.offsetHeight || 1;
return [width + padding, height + padding];
};
const Utils = {
usePrevious, findRemoved, filterInvalidShapes, mapLanguage, getTextSize,
usePrevious, findRemoved, filterInvalidShapes, mapLanguage,
};
export default Utils;
export {
usePrevious, findRemoved, filterInvalidShapes, mapLanguage, getTextSize,
usePrevious, findRemoved, filterInvalidShapes, mapLanguage,
};