From 6ca8c250de45f1edabdf01d054d73b12d9fb791b Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 20 Sep 2022 11:34:38 -0400
Subject: fixed pdf boxes to be active in lightboxview by fixing lightboxview
 docview to be observable so that IsLightboxDoc's will invalidate.  made
 webBox's content 'relative' so that linksButton is in correct place.  changed
 text highlight color to orange for webboxes

---
 src/client/views/nodes/WebBox.tsx | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'src/client/views/nodes/WebBox.tsx')

diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index b086b7ffb..e7b188961 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -366,12 +366,31 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
     iframeClick = () => this._iframeClick;
     iframeScaling = () => 1 / this.props.ScreenToLocalTransform().Scale;
 
+    addStyleSheet(document: any, styleType: string = 'text/css') {
+        const style = document.createElement('style');
+        style.type = styleType;
+        const sheets = document.head.appendChild(style);
+        return (sheets as any).sheet;
+    }
+    addStyleSheetRule(sheet: any, selector: any, css: any, selectorPrefix = '.') {
+        const propText =
+            typeof css === 'string'
+                ? css
+                : Object.keys(css)
+                      .map(p => p + ':' + (p === 'content' ? "'" + css[p] + "'" : css[p]))
+                      .join(';');
+        return sheet.insertRule(selectorPrefix + selector + '{' + propText + '}', sheet.cssRules.length);
+    }
+
     @action
     iframeLoaded = (e: any) => {
         const iframe = this._iframe;
         if (this._initialScroll !== undefined) {
             this.setScrollPos(this._initialScroll);
         }
+
+        this.addStyleSheetRule(this.addStyleSheet(this._iframe?.contentDocument), '::selection', { color: 'white', background: 'orange' }, '');
+
         let requrlraw = decodeURIComponent(iframe?.contentWindow?.location.href.replace(Utils.prepend('') + '/corsProxy/', '') ?? this._url.toString());
         if (requrlraw !== this._url.toString()) {
             if (requrlraw.match(/q=.*&/)?.length && this._url.toString().match(/q=.*&/)?.length) {
-- 
cgit v1.2.3-70-g09d2

