diff --git a/package-lock.json b/package-lock.json index f2800c77..ec5dac8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -61,6 +61,7 @@ "react-chartjs-2": "^3.3.0", "react-dom": "^16.13.1", "react-pdf": "^7.7.3", + "react-resize-detector": "^7.1.2", "resolve": "1.15.0", "resolve-url-loader": "^5.0.0", "semver": "6.3", @@ -21747,6 +21748,18 @@ } } }, + "node_modules/react-resize-detector": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/react-resize-detector/-/react-resize-detector-7.1.2.tgz", + "integrity": "sha512-zXnPJ2m8+6oq9Nn8zsep/orts9vQv3elrpA+R8XTcW7DVVUJ9vwDwMXaBtykAYjMnkCIaOoK9vObyR7ZgFNlOw==", + "dependencies": { + "lodash": "^4.17.21" + }, + "peerDependencies": { + "react": "^16.0.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -43808,6 +43821,14 @@ "warning": "^4.0.0" } }, + "react-resize-detector": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/react-resize-detector/-/react-resize-detector-7.1.2.tgz", + "integrity": "sha512-zXnPJ2m8+6oq9Nn8zsep/orts9vQv3elrpA+R8XTcW7DVVUJ9vwDwMXaBtykAYjMnkCIaOoK9vObyR7ZgFNlOw==", + "requires": { + "lodash": "^4.17.21" + } + }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", diff --git a/package.json b/package.json index 17bb4a18..c8777bf8 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "react-chartjs-2": "^3.3.0", "react-dom": "^16.13.1", "react-pdf": "^7.7.3", + "react-resize-detector": "^7.1.2", "resolve": "1.15.0", "resolve-url-loader": "^5.0.0", "semver": "6.3", diff --git a/src/essence/Basics/Layers_/Layers_.js b/src/essence/Basics/Layers_/Layers_.js index 4cc9e09d..380490a1 100644 --- a/src/essence/Basics/Layers_/Layers_.js +++ b/src/essence/Basics/Layers_/Layers_.js @@ -3323,37 +3323,48 @@ const L_ = { } } } - //If there isn't one, search all string valued props for image urls - else { - for (var p in props) { - if ( - typeof props[p] === 'string' && - props[p].toLowerCase().match(/\.(jpeg|jpg|gif|png|xml)$/) != - null - ) { - var url = props[p] - if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url - images.push({ - url: url, - name: p, - isPanoramic: false, - isModel: false, - }) - } - if ( - typeof props[p] === 'string' && - (props[p].toLowerCase().match(/\.(obj)$/) != null || - props[p].toLowerCase().match(/\.(dae)$/) != null) - ) { - var url = props[p] - if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url - images.push({ - url: url, - name: p, - isPanoramic: false, - isModel: true, - }) - } + //Now search all string valued props for image urls + + for (let p in props) { + if ( + typeof props[p] === 'string' && + props[p].toLowerCase().match(/\.(jpeg|jpg|gif|png|xml)$/) != + null + ) { + let url = props[p] + if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url + images.push({ + url: url, + name: p, + isPanoramic: false, + isModel: false, + }) + } else if ( + typeof props[p] === 'string' && + props[p].toLowerCase().match(/\.(pdf)$/) != null + ) { + let url = props[p] + if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url + images.push({ + url: url, + name: p, + type: 'document', + isPanoramic: false, + isModel: false, + }) + } else if ( + typeof props[p] === 'string' && + (props[p].toLowerCase().match(/\.(obj)$/) != null || + props[p].toLowerCase().match(/\.(dae)$/) != null) + ) { + let url = props[p] + if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url + images.push({ + url: url, + name: p, + isPanoramic: false, + isModel: true, + }) } } diff --git a/src/essence/Basics/Viewer_/PDFViewer.js b/src/essence/Basics/Viewer_/PDFViewer.js index e5391563..b3fe5902 100644 --- a/src/essence/Basics/Viewer_/PDFViewer.js +++ b/src/essence/Basics/Viewer_/PDFViewer.js @@ -1,6 +1,8 @@ import { render } from 'react-dom' import React, { useState, useEffect } from 'react' import { Document, Page, pdfjs } from 'react-pdf' +import { useResizeDetector } from 'react-resize-detector' + import 'react-pdf/dist/Page/AnnotationLayer.css' import 'react-pdf/dist/Page/TextLayer.css' @@ -14,25 +16,30 @@ const ReactPDF = (props) => { const zoomLevels = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 2.5, 3, 4, 5] const [zoom, setZoom] = useState(3) - function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { - setNumPages(numPages) - } + const { width, height, ref } = useResizeDetector({ + handleHeight: false, + refreshMode: 'debounce', + refreshRate: 1000, + }) useEffect(() => { setZoom(3) }, [pdfPath]) + function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { + setNumPages(numPages) + } const bcr = document .getElementById('pdfViewerWrapper') .getBoundingClientRect() - const width = bcr ? bcr.width - 40 : null + const pageWidth = bcr ? bcr.width - 40 : null return ( -
+
{ const container = document.getElementById('pdfViewerWrapper') diff --git a/src/essence/Tools/Draw/DrawTool_Editing.js b/src/essence/Tools/Draw/DrawTool_Editing.js index 4ff4ac87..e4f5b408 100644 --- a/src/essence/Tools/Draw/DrawTool_Editing.js +++ b/src/essence/Tools/Draw/DrawTool_Editing.js @@ -26,6 +26,8 @@ var Editing = { DrawTool.cmLayerMove = Editing.cmLayerMove }, removeContextMenu: function () { + if (DrawTool.contextMenuLayer) + DrawTool.contextMenuLayer.dragging = false $('.drawToolContextMenu').remove() UserInterface_.closeRightPanel() }, diff --git a/src/essence/Tools/Draw/DrawTool_Shapes.js b/src/essence/Tools/Draw/DrawTool_Shapes.js index 0c31eae3..ef1abfd5 100644 --- a/src/essence/Tools/Draw/DrawTool_Shapes.js +++ b/src/essence/Tools/Draw/DrawTool_Shapes.js @@ -352,7 +352,12 @@ var Shapes = { $('#drawToolMouseoverText').addClass('active') $('#drawToolMouseoverText').css({ top: centerPx.y, - left: centerPx.x + 310, + left: + centerPx.x + + 20 + + document + .getElementById('mapScreen') + .getBoundingClientRect().left, }) } })(layer, index) diff --git a/src/essence/Tools/Draw/DrawTool_Templater.js b/src/essence/Tools/Draw/DrawTool_Templater.js index bc5dd775..998d301e 100644 --- a/src/essence/Tools/Draw/DrawTool_Templater.js +++ b/src/essence/Tools/Draw/DrawTool_Templater.js @@ -854,7 +854,7 @@ const DrawTool_Templater = { typeMarkup = [ `
`, `
`, - `
Value with a single '#' to place an incrementing number:
`, + `
Value with single '#' to place incrementing number:
`, ``, "
", "
"