daedalOS/components/Programs/WebODF.tsx
Dustin Brett d99517a970 Tweaks
2020-11-22 21:41:49 -08:00

30 lines
675 B
TypeScript

import styles from '@/styles/Programs/WebODF.module.scss';
import type { AppComponent } from '@/types/utils/programs';
import useOdf from '@/hooks/useOdf';
import { useEffect, useRef } from 'react';
const WebODF: React.FC<AppComponent> = ({
url: appUrl,
file: { url = '/docs/welcome.odt' } = {}
}) => {
const odfElementRef = useRef<HTMLElement>(null);
const odfLib = useOdf({ odfElementRef, url });
useEffect(() => {
if (appUrl && odfLib) {
odfLib.load(appUrl);
}
}, [appUrl, odfLib]);
return <article className={styles.webOdf} ref={odfElementRef} />;
};
export default WebODF;
export const loaderOptions = {
width: 450,
height: 500
};