mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-25 02:41:07 +01:00
Markdown documentation for HTTP requests (#145)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import useResizeObserver from '@react-hook/resize-observer';
|
||||
import 'react-pdf/dist/Page/TextLayer.css';
|
||||
import 'react-pdf/dist/Page/AnnotationLayer.css';
|
||||
import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
@@ -6,7 +5,7 @@ import './PdfViewer.css';
|
||||
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { Document, Page } from 'react-pdf';
|
||||
import { useDebouncedState } from '../../hooks/useDebouncedState';
|
||||
import useSize from '@react-hook/size';
|
||||
|
||||
interface Props {
|
||||
bodyPath: string;
|
||||
@@ -19,12 +18,9 @@ const options = {
|
||||
|
||||
export function PdfViewer({ bodyPath }: Props) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const [containerWidth, setContainerWidth] = useDebouncedState<number>(0, 100);
|
||||
const [numPages, setNumPages] = useState<number>();
|
||||
|
||||
useResizeObserver(containerRef.current ?? null, (v) => {
|
||||
setContainerWidth(v.contentRect.width);
|
||||
});
|
||||
const [containerWidth] = useSize(containerRef.current);
|
||||
|
||||
const onDocumentLoadSuccess = ({ numPages: nextNumPages }: PDFDocumentProxy): void => {
|
||||
setNumPages(nextNumPages);
|
||||
|
||||
Reference in New Issue
Block a user