From 2d70a3bc17fe94d0bf92d8362b8fda8a2e4a82e1 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 26 Jun 2025 16:41:01 -0400 Subject: fixed rendering pdfs, text selections on pdfs, --- src/client/views/MarqueeAnnotator.tsx | 16 ++++++++-------- src/client/views/ScriptBox.tsx | 4 ++-- src/client/views/nodes/PDFBox.tsx | 15 +++++---------- src/client/views/nodes/WebBox.tsx | 8 ++++---- src/client/views/nodes/formattedText/DashDocView.tsx | 2 +- src/client/views/pdf/PDFViewer.scss | 1 + src/client/views/pdf/PDFViewer.tsx | 8 ++++---- 7 files changed, 25 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/client/views/MarqueeAnnotator.tsx b/src/client/views/MarqueeAnnotator.tsx index d354dd2c0..7bb14c01e 100644 --- a/src/client/views/MarqueeAnnotator.tsx +++ b/src/client/views/MarqueeAnnotator.tsx @@ -104,16 +104,16 @@ export class MarqueeAnnotator extends ObservableReactComponent value.forEach(anno => { - const x = parseInt(anno.style.left ?? '0'); - const y = parseInt(anno.style.top ?? '0'); - const height = parseInt(anno.style.height ?? '0'); - const width = parseInt(anno.style.width ?? '0'); + const x = parseInt(anno.style.left || '0'); + const y = parseInt(anno.style.top || '0'); + const height = parseInt(anno.style.height || '0'); + const width = parseInt(anno.style.width || '0'); annoRects.push(`${x}:${y}:${width}:${height}`); anno.remove(); - minY = Math.min(NumCast(y), minY); - minX = Math.min(NumCast(x), minX); - maxY = Math.max(NumCast(y) + NumCast(height), maxY); - maxX = Math.max(NumCast(x) + NumCast(width), maxX); + minY = Math.min(y, minY); + minX = Math.min(x, minX); + maxY = Math.max(y + height, maxY); + maxX = Math.max(x + width, maxX); }) ); diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx index 52c0227d8..c2fbef5a5 100644 --- a/src/client/views/ScriptBox.tsx +++ b/src/client/views/ScriptBox.tsx @@ -131,8 +131,8 @@ export class ScriptBox extends React.Component { } const div = document.createElement('div'); - div.style.width = '90'; - div.style.height = '20'; + div.style.width = '90px'; + div.style.height = '20px'; div.style.background = 'gray'; div.style.position = 'absolute'; div.style.display = 'inline-block'; diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index 5501f0a31..4deb1f207 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -72,12 +72,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent() { !this.Document._layout_fitWidth && (this.Document._height = NumCast(this.Document._width) * (nh / nw)); if (this.pdfUrl) { this._pdf = PDFBox.pdfcache.get(this.pdfUrl.url.href); - !this._pdf && - PDFBox.pdfpromise.get(this.pdfUrl.url.href)?.then( - action(pdf => { - this._pdf = pdf; - }) - ); + !this._pdf && PDFBox.pdfpromise.get(this.pdfUrl.url.href)?.then(action(pdf => (this._pdf = pdf))); } } @@ -150,8 +145,8 @@ export class PDFBox extends ViewBoxAnnotatableComponent() { this.addDocument(region); const newDiv = docViewContent.cloneNode(true) as HTMLDivElement; - newDiv.style.width = NumCast(this.layoutDoc._width).toString(); - newDiv.style.height = NumCast(this.layoutDoc._height).toString(); + newDiv.style.width = NumCast(this.layoutDoc._width).toString() + 'px'; + newDiv.style.height = NumCast(this.layoutDoc._height).toString() + 'px'; this.replaceCanvases(docViewContent, newDiv); const htmlString = this._pdfViewer?._mainCont.current && new XMLSerializer().serializeToString(newDiv); @@ -409,7 +404,7 @@ export class PDFBox extends ViewBoxAnnotatableComponent() { this.layoutDoc._show_sidebar = nativeWidth !== this.layoutDoc._nativeWidth; } }); - settingsPanel() { + @computed get settingsPanel() { const pageBtns = ( <>