From a2d2737fa4ec1a57f5288ed72eb44a2be4588ee8 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Fri, 13 Dec 2019 14:25:35 -0500 Subject: pdf path parsing fix in pdfviewer --- src/client/views/pdf/PDFViewer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/views') diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 3aa5d1d2c..d16fe2edd 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -125,7 +125,7 @@ export class PDFViewer extends DocAnnotatableComponent this._showWaiting = this._showCover = true); this.props.startupLive && this.setupPdfJsViewer(); -- cgit v1.2.3-70-g09d2 From f49cf16cb4af2851aaa98bb2c6fce81271042fea Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Fri, 13 Dec 2019 15:12:04 -0500 Subject: path rosemary server fix --- solr-8.3.1/server/logs/solr_gc.log.0.current | 29 +++++++++++++++++++++++++++- src/client/views/pdf/PDFViewer.tsx | 11 +++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'src/client/views') diff --git a/solr-8.3.1/server/logs/solr_gc.log.0.current b/solr-8.3.1/server/logs/solr_gc.log.0.current index 4b5cdd721..e45ebc49d 100644 --- a/solr-8.3.1/server/logs/solr_gc.log.0.current +++ b/solr-8.3.1/server/logs/solr_gc.log.0.current @@ -295,4 +295,31 @@ Heap after GC invocations=4 (full 0): 2019-12-13T14:20:31.796-0500: 65.642: Total time for which application threads were stopped: 0.0000504 seconds, Stopping threads took: 0.0000174 seconds 2019-12-13T14:20:31.796-0500: 65.642: Total time for which application threads were stopped: 0.0000489 seconds, Stopping threads took: 0.0000240 seconds 2019-12-13T14:20:31.804-0500: 65.649: Total time for which application threads were stopped: 0.0000811 seconds, Stopping threads took: 0.0000239 seconds -2019-12-13T14:20:31.804-0500: 65.649: Total time for which application \ No newline at end of file +2019-12-13T14:20:31.804-0500: 65.649: Total time for which application threads were stopped: 0.0000578 seconds, Stopping threads took: 0.0000174 seconds +2019-12-13T14:20:31.806-0500: 65.651: Total time for which application threads were stopped: 0.0000609 seconds, Stopping threads took: 0.0000206 seconds +2019-12-13T14:20:31.806-0500: 65.651: Total time for which application threads were stopped: 0.0000415 seconds, Stopping threads took: 0.0000167 seconds +2019-12-13T14:20:31.807-0500: 65.652: Total time for which application threads were stopped: 0.0000417 seconds, Stopping threads took: 0.0000152 seconds +2019-12-13T14:20:31.807-0500: 65.652: Total time for which application threads were stopped: 0.0001659 seconds, Stopping threads took: 0.0001210 seconds +2019-12-13T14:20:31.809-0500: 65.655: Total time for which application threads were stopped: 0.0001285 seconds, Stopping threads took: 0.0000161 seconds +2019-12-13T14:20:31.848-0500: 65.694: Total time for which application threads were stopped: 0.0002375 seconds, Stopping threads took: 0.0000963 seconds +2019-12-13T14:20:32.849-0500: 66.694: Total time for which application threads were stopped: 0.0000762 seconds, Stopping threads took: 0.0000226 seconds +2019-12-13T14:20:33.221-0500: 67.066: Total time for which application threads were stopped: 0.0002122 seconds, Stopping threads took: 0.0000344 seconds +2019-12-13T14:20:33.355-0500: 67.200: Total time for which application threads were stopped: 0.0010525 seconds, Stopping threads took: 0.0009766 seconds +2019-12-13T14:20:33.380-0500: 67.226: Total time for which application threads were stopped: 0.0001911 seconds, Stopping threads took: 0.0001312 seconds +2019-12-13T14:20:34.380-0500: 68.226: Total time for which application threads were stopped: 0.0001102 seconds, Stopping threads took: 0.0000259 seconds +2019-12-13T14:21:22.760-0500: 116.604: Total time for which application threads were stopped: 0.0000779 seconds, Stopping threads took: 0.0000232 seconds +2019-12-13T14:21:23.760-0500: 117.604: Total time for which application threads were stopped: 0.0000733 seconds, Stopping threads took: 0.0000271 seconds +2019-12-13T14:21:30.763-0500: 124.606: Total time for which application threads were stopped: 0.0000739 seconds, Stopping threads took: 0.0000263 seconds +2019-12-13T14:21:31.763-0500: 125.606: Total time for which application threads were stopped: 0.0000665 seconds, Stopping threads took: 0.0000222 seconds +2019-12-13T14:22:01.781-0500: 155.623: Total time for which application threads were stopped: 0.0000777 seconds, Stopping threads took: 0.0000250 seconds +2019-12-13T14:22:25.795-0500: 179.636: Total time for which application threads were stopped: 0.0000737 seconds, Stopping threads took: 0.0000255 seconds +2019-12-13T14:22:30.798-0500: 184.639: Total time for which application threads were stopped: 0.0000908 seconds, Stopping threads took: 0.0000229 seconds +2019-12-13T14:23:30.828-0500: 244.667: Total time for which application threads were stopped: 0.0000805 seconds, Stopping threads took: 0.0000293 seconds +2019-12-13T14:24:30.864-0500: 304.700: Total time for which application threads were stopped: 0.0000739 seconds, Stopping threads took: 0.0000250 seconds +2019-12-13T14:25:30.899-0500: 364.733: Total time for which application threads were stopped: 0.0000832 seconds, Stopping threads took: 0.0000266 seconds +2019-12-13T14:27:30.954-0500: 484.784: Total time for which application threads were stopped: 0.0002355 seconds, Stopping threads took: 0.0001565 seconds +2019-12-13T14:28:01.968-0500: 515.796: Total time for which application threads were stopped: 0.0000752 seconds, Stopping threads took: 0.0000252 seconds +2019-12-13T14:28:30.983-0500: 544.810: Total time for which application threads were stopped: 0.0000737 seconds, Stopping threads took: 0.0000252 seconds +2019-12-13T14:29:31.010-0500: 604.836: Total time for which application threads were stopped: 0.0000722 seconds, Stopping threads took: 0.0000242 seconds +2019-12-13T14:30:31.042-0500: 664.865: Total time for which application threads were stopped: 0.0000756 seconds, Stopping threads took: 0.0000251 seconds +2019-12-13T14:31:31.0 \ No newline at end of file diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index a1f710617..4716e9d66 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -30,6 +30,7 @@ import { DocumentDecorations } from "../DocumentDecorations"; import { InkingControl } from "../InkingControl"; import { InkTool } from "../../../new_fields/InkField"; import { TraceMobx } from "../../../new_fields/util"; +import { PdfField } from "../../../new_fields/URLField"; const PDFJSViewer = require("pdfjs-dist/web/pdf_viewer"); const pdfjsLib = require("pdfjs-dist"); @@ -125,6 +126,16 @@ export class PDFViewer extends DocAnnotatableComponent this._showWaiting = this._showCover = true); -- cgit v1.2.3-70-g09d2 From d4f793d73070594086c72cf67a8b2b0a60b2af77 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Fri, 13 Dec 2019 15:36:16 -0500 Subject: write to data doc + console logs for pdf fix --- src/client/views/pdf/PDFViewer.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 4716e9d66..253968443 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -126,15 +126,24 @@ export class PDFViewer extends DocAnnotatableComponent Date: Fri, 13 Dec 2019 15:48:13 -0500 Subject: absolute pathname to pdfbox, improved check --- src/client/views/nodes/PDFBox.tsx | 2 +- src/client/views/pdf/PDFViewer.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index 0f5cc0fa9..af996b3d8 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -57,7 +57,7 @@ export class PDFBox extends DocAnnotatableComponent componentDidMount() { const pdfUrl = Cast(this.dataDoc[this.props.fieldKey], PdfField); if (pdfUrl instanceof PdfField) { - Pdfjs.getDocument(pdfUrl.url.pathname).promise.then(pdf => runInAction(() => this._pdf = pdf)); + Pdfjs.getDocument(pdfUrl.url.href).promise.then(pdf => runInAction(() => this._pdf = pdf)); } this._selectReactionDisposer = reaction(() => this.props.isSelected(), () => { diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 253968443..41825cda7 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -137,7 +137,7 @@ export class PDFViewer extends DocAnnotatableComponent Date: Fri, 13 Dec 2019 16:49:10 -0500 Subject: server pdf stability improvements --- solr-8.3.1/server/logs/solr.log | 4 + solr-8.3.1/server/logs/solr_gc.log.0.current | 166 ++++++++++++++++++++++++++- src/client/views/pdf/PDFViewer.tsx | 9 +- src/server/ApiManagers/PDFManager.ts | 37 +++--- 4 files changed, 196 insertions(+), 20 deletions(-) (limited to 'src/client/views') diff --git a/solr-8.3.1/server/logs/solr.log b/solr-8.3.1/server/logs/solr.log index 25c8bae75..10ed06cb3 100644 --- a/solr-8.3.1/server/logs/solr.log +++ b/solr-8.3.1/server/logs/solr.log @@ -31,3 +31,7 @@ 2019-12-13 19:19:30.793 INFO (main) [ ] o.e.j.s.AbstractConnector Started ServerConnector@8297b3a{HTTP/1.1,[http/1.1, h2c]}{0.0.0.0:8983} 2019-12-13 19:19:30.793 INFO (main) [ ] o.e.j.s.Server Started @4641ms 2019-12-13 19:19:31.371 INFO (qtp1664439369-23) [ ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/info/system params={wt=json} status=0 QTime=51 +2019-12-13 20:58:25.058 INFO (qtp1664439369-19) [ ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/info/system params={wt=json} status=0 QTime=42 +2019-12-13 20:58:36.863 INFO (qtp1664439369-22) [ ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/cores params={indexInfo=false&wt=json&_=1576270716757} status=0 QTime=6 +2019-12-13 20:58:36.894 INFO (qtp1664439369-18) [ ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/info/system params={wt=json&_=1576270716757} status=0 QTime=36 +2019-12-13 20:58:36.921 INFO (qtp1664439369-40) [ ] o.a.s.s.HttpSolrCall [admin] webapp=null path=/admin/info/system params={wt=json&_=1576270716757} status=0 QTime=24 diff --git a/solr-8.3.1/server/logs/solr_gc.log.0.current b/solr-8.3.1/server/logs/solr_gc.log.0.current index e45ebc49d..687372454 100644 --- a/solr-8.3.1/server/logs/solr_gc.log.0.current +++ b/solr-8.3.1/server/logs/solr_gc.log.0.current @@ -322,4 +322,168 @@ Heap after GC invocations=4 (full 0): 2019-12-13T14:28:30.983-0500: 544.810: Total time for which application threads were stopped: 0.0000737 seconds, Stopping threads took: 0.0000252 seconds 2019-12-13T14:29:31.010-0500: 604.836: Total time for which application threads were stopped: 0.0000722 seconds, Stopping threads took: 0.0000242 seconds 2019-12-13T14:30:31.042-0500: 664.865: Total time for which application threads were stopped: 0.0000756 seconds, Stopping threads took: 0.0000251 seconds -2019-12-13T14:31:31.0 \ No newline at end of file +2019-12-13T14:31:31.081-0500: 724.901: Total time for which application threads were stopped: 0.0002465 seconds, Stopping threads took: 0.0001502 seconds +2019-12-13T14:36:31.227-0500: 1025.037: Total time for which application threads were stopped: 0.0000861 seconds, Stopping threads took: 0.0000258 seconds +2019-12-13T14:36:55.239-0500: 1049.048: Total time for which application threads were stopped: 0.0000796 seconds, Stopping threads took: 0.0000297 seconds +2019-12-13T14:37:31.260-0500: 1085.068: Total time for which application threads were stopped: 0.0000800 seconds, Stopping threads took: 0.0000252 seconds +2019-12-13T14:39:31.321-0500: 1205.125: Total time for which application threads were stopped: 0.0000985 seconds, Stopping threads took: 0.0000317 seconds +2019-12-13T14:41:31.380-0500: 1325.180: Total time for which application threads were stopped: 0.0000677 seconds, Stopping threads took: 0.0000185 seconds +2019-12-13T14:42:31.415-0500: 1385.213: Total time for which application threads were stopped: 0.0000780 seconds, Stopping threads took: 0.0000247 seconds +2019-12-13T14:43:31.443-0500: 1445.239: Total time for which application threads were stopped: 0.0000742 seconds, Stopping threads took: 0.0000250 seconds +2019-12-13T14:44:31.467-0500: 1505.261: Total time for which application threads were stopped: 0.0000927 seconds, Stopping threads took: 0.0000250 seconds +2019-12-13T14:45:31.500-0500: 1565.292: Total time for which application threads were stopped: 0.0000861 seconds, Stopping threads took: 0.0000298 seconds +2019-12-13T14:46:31.532-0500: 1625.322: Total time for which application threads were stopped: 0.0000926 seconds, Stopping threads took: 0.0000288 seconds +2019-12-13T14:51:31.682-0500: 1925.463: Total time for which application threads were stopped: 0.0000831 seconds, Stopping threads took: 0.0000269 seconds +2019-12-13T14:52:29.711-0500: 1983.489: Total time for which application threads were stopped: 0.0000811 seconds, Stopping threads took: 0.0000264 seconds +2019-12-13T14:57:30.858-0500: 2284.628: Total time for which application threads were stopped: 0.0000834 seconds, Stopping threads took: 0.0000264 seconds +2019-12-13T15:17:31.465-0500: 3485.201: Total time for which application threads were stopped: 0.0001128 seconds, Stopping threads took: 0.0000462 seconds +2019-12-13T15:19:31.533-0500: 3605.266: Total time for which application threads were stopped: 0.0000927 seconds, Stopping threads took: 0.0000303 seconds +2019-12-13T15:23:31.655-0500: 3845.381: Total time for which application threads were stopped: 0.0000822 seconds, Stopping threads took: 0.0000273 seconds +2019-12-13T15:40:32.169-0500: 4865.871: Total time for which application threads were stopped: 0.0000997 seconds, Stopping threads took: 0.0000339 seconds +2019-12-13T15:41:32.197-0500: 4925.897: Total time for which application threads were stopped: 0.0000729 seconds, Stopping threads took: 0.0000235 seconds +2019-12-13T15:47:32.371-0500: 5286.063: Total time for which application threads were stopped: 0.0001041 seconds, Stopping threads took: 0.0000327 seconds +2019-12-13T15:51:32.487-0500: 5526.174: Total time for which application threads were stopped: 0.0000795 seconds, Stopping threads took: 0.0000253 seconds +2019-12-13T15:55:15.598-0500: 5749.280: Total time for which application threads were stopped: 0.0001565 seconds, Stopping threads took: 0.0000314 seconds +2019-12-13T15:56:32.638-0500: 5826.319: Total time for which application threads were stopped: 0.0000771 seconds, Stopping threads took: 0.0000240 seconds +2019-12-13T15:58:09.684-0500: 5923.363: Total time for which application threads were stopped: 0.0000708 seconds, Stopping threads took: 0.0000216 seconds +2019-12-13T15:58:25.054-0500: 5938.734: Total time for which application threads were stopped: 0.0003699 seconds, Stopping threads took: 0.0000196 seconds +2019-12-13T15:58:25.054-0500: 5938.734: Total time for which application threads were stopped: 0.0000675 seconds, Stopping threads took: 0.0000113 seconds +2019-12-13T15:58:25.054-0500: 5938.734: Total time for which application threads were stopped: 0.0000413 seconds, Stopping threads took: 0.0000101 seconds +2019-12-13T15:58:26.056-0500: 5939.735: Total time for which application threads were stopped: 0.0001509 seconds, Stopping threads took: 0.0000193 seconds +2019-12-13T15:58:35.718-0500: 5949.397: Total time for which application threads were stopped: 0.0001277 seconds, Stopping threads took: 0.0000247 seconds +2019-12-13T15:58:35.719-0500: 5949.398: Total time for which application threads were stopped: 0.0000785 seconds, Stopping threads took: 0.0000151 seconds +2019-12-13T15:58:35.762-0500: 5949.441: Total time for which application threads were stopped: 0.0000840 seconds, Stopping threads took: 0.0000249 seconds +2019-12-13T15:58:35.762-0500: 5949.441: Total time for which application threads were stopped: 0.0000521 seconds, Stopping threads took: 0.0000146 seconds +2019-12-13T15:58:35.762-0500: 5949.441: Total time for which application threads were stopped: 0.0000387 seconds, Stopping threads took: 0.0000131 seconds +2019-12-13T15:58:35.790-0500: 5949.469: Total time for which application threads were stopped: 0.0000792 seconds, Stopping threads took: 0.0000227 seconds +2019-12-13T15:58:35.825-0500: 5949.505: Total time for which application threads were stopped: 0.0018974 seconds, Stopping threads took: 0.0009431 seconds +2019-12-13T15:58:35.845-0500: 5949.524: Total time for which application threads were stopped: 0.0038627 seconds, Stopping threads took: 0.0037713 seconds +2019-12-13T15:58:35.845-0500: 5949.525: Total time for which application threads were stopped: 0.0003415 seconds, Stopping threads took: 0.0002770 seconds +2019-12-13T15:58:35.856-0500: 5949.535: Total time for which application threads were stopped: 0.0001537 seconds, Stopping threads took: 0.0000599 seconds +2019-12-13T15:58:35.856-0500: 5949.535: Total time for which application threads were stopped: 0.0001040 seconds, Stopping threads took: 0.0000346 seconds +2019-12-13T15:58:35.861-0500: 5949.540: Total time for which application threads were stopped: 0.0001447 seconds, Stopping threads took: 0.0000367 seconds +2019-12-13T15:58:35.871-0500: 5949.551: Total time for which application threads were stopped: 0.0001568 seconds, Stopping threads took: 0.0000513 seconds +2019-12-13T15:58:35.876-0500: 5949.555: Total time for which application threads were stopped: 0.0002530 seconds, Stopping threads took: 0.0000532 seconds +2019-12-13T15:58:35.885-0500: 5949.564: Total time for which application threads were stopped: 0.0015837 seconds, Stopping threads took: 0.0014686 seconds +2019-12-13T15:58:35.897-0500: 5949.576: Total time for which application threads were stopped: 0.0001451 seconds, Stopping threads took: 0.0000412 seconds +2019-12-13T15:58:35.897-0500: 5949.577: Total time for which application threads were stopped: 0.0001025 seconds, Stopping threads took: 0.0000230 seconds +2019-12-13T15:58:35.897-0500: 5949.577: Total time for which application threads were stopped: 0.0000632 seconds, Stopping threads took: 0.0000166 seconds +2019-12-13T15:58:35.897-0500: 5949.577: Total time for which application threads were stopped: 0.0000689 seconds, Stopping threads took: 0.0000172 seconds +2019-12-13T15:58:35.897-0500: 5949.577: Total time for which application threads were stopped: 0.0000850 seconds, Stopping threads took: 0.0000176 seconds +2019-12-13T15:58:35.898-0500: 5949.577: Total time for which application threads were stopped: 0.0001922 seconds, Stopping threads took: 0.0001196 seconds +2019-12-13T15:58:35.898-0500: 5949.577: Total time for which application threads were stopped: 0.0000606 seconds, Stopping threads took: 0.0000168 seconds +2019-12-13T15:58:35.898-0500: 5949.577: Total time for which application threads were stopped: 0.0000555 seconds, Stopping threads took: 0.0000159 seconds +2019-12-13T15:58:35.898-0500: 5949.577: Total time for which application threads were stopped: 0.0000564 seconds, Stopping threads took: 0.0000160 seconds +2019-12-13T15:58:35.898-0500: 5949.577: Total time for which application threads were stopped: 0.0000587 seconds, Stopping threads took: 0.0000161 seconds +2019-12-13T15:58:35.927-0500: 5949.607: Total time for which application threads were stopped: 0.0001109 seconds, Stopping threads took: 0.0000534 seconds +2019-12-13T15:58:36.856-0500: 5950.535: Total time for which application threads were stopped: 0.0001815 seconds, Stopping threads took: 0.0000219 seconds +2019-12-13T15:58:37.856-0500: 5951.535: Total time for which application threads were stopped: 0.0000822 seconds, Stopping threads took: 0.0000206 seconds +2019-12-13T15:58:46.860-0500: 5960.539: Total time for which application threads were stopped: 0.0000913 seconds, Stopping threads took: 0.0000300 seconds +2019-12-13T15:58:59.867-0500: 5973.545: Total time for which application threads were stopped: 0.0000974 seconds, Stopping threads took: 0.0000263 seconds +2019-12-13T15:59:31.882-0500: 6005.560: Total time for which application threads were stopped: 0.0001038 seconds, Stopping threads took: 0.0000309 seconds +2019-12-13T16:00:35.912-0500: 6069.588: Total time for which application threads were stopped: 0.0000783 seconds, Stopping threads took: 0.0000223 seconds +2019-12-13T16:02:55.980-0500: 6209.653: Total time for which application threads were stopped: 0.0000870 seconds, Stopping threads took: 0.0000270 seconds +2019-12-13T16:07:01.094-0500: 6454.762: Total time for which application threads were stopped: 0.0001021 seconds, Stopping threads took: 0.0000318 seconds +2019-12-13T16:07:51.119-0500: 6504.786: Total time for which application threads were stopped: 0.0000833 seconds, Stopping threads took: 0.0000264 seconds +2019-12-13T16:09:42.175-0500: 6615.841: Total time for which application threads were stopped: 0.0001578 seconds, Stopping threads took: 0.0001029 seconds +2019-12-13T16:09:47.178-0500: 6620.843: Total time for which application threads were stopped: 0.0000833 seconds, Stopping threads took: 0.0000343 seconds +2019-12-13T16:09:52.181-0500: 6625.847: Total time for which application threads were stopped: 0.0000839 seconds, Stopping threads took: 0.0000264 seconds +2019-12-13T16:09:54.183-0500: 6627.848: Total time for which application threads were stopped: 0.0000903 seconds, Stopping threads took: 0.0000231 seconds +2019-12-13T16:09:55.183-0500: 6628.848: Total time for which application threads were stopped: 0.0000877 seconds, Stopping threads took: 0.0000241 seconds +2019-12-13T16:09:56.184-0500: 6629.849: Total time for which application threads were stopped: 0.0001001 seconds, Stopping threads took: 0.0000234 seconds +2019-12-13T16:10:02.186-0500: 6635.851: Total time for which application threads were stopped: 0.0000840 seconds, Stopping threads took: 0.0000265 seconds +2019-12-13T16:10:04.187-0500: 6637.852: Total time for which application threads were stopped: 0.0001204 seconds, Stopping threads took: 0.0000261 seconds +2019-12-13T16:10:21.197-0500: 6654.861: Total time for which application threads were stopped: 0.0000971 seconds, Stopping threads took: 0.0000267 seconds +2019-12-13T16:10:22.197-0500: 6655.862: Total time for which application threads were stopped: 0.0000808 seconds, Stopping threads took: 0.0000242 seconds +2019-12-13T16:10:23.198-0500: 6656.862: Total time for which application threads were stopped: 0.0000840 seconds, Stopping threads took: 0.0000238 seconds +2019-12-13T16:10:24.198-0500: 6657.863: Total time for which application threads were stopped: 0.0000868 seconds, Stopping threads took: 0.0000266 seconds +2019-12-13T16:10:25.199-0500: 6658.864: Total time for which application threads were stopped: 0.0000835 seconds, Stopping threads took: 0.0000269 seconds +2019-12-13T16:12:13.248-0500: 6766.911: Total time for which application threads were stopped: 0.0001228 seconds, Stopping threads took: 0.0000299 seconds +2019-12-13T16:12:56.273-0500: 6809.935: Total time for which application threads were stopped: 0.0001019 seconds, Stopping threads took: 0.0000298 seconds +2019-12-13T16:13:04.277-0500: 6817.939: Total time for which application threads were stopped: 0.0000859 seconds, Stopping threads took: 0.0000274 seconds +2019-12-13T16:14:31.319-0500: 6904.979: Total time for which application threads were stopped: 0.0001123 seconds, Stopping threads took: 0.0000309 seconds +2019-12-13T16:14:32.319-0500: 6905.979: Total time for which application threads were stopped: 0.0001097 seconds, Stopping threads took: 0.0000280 seconds +2019-12-13T16:16:32.379-0500: 7026.037: Total time for which application threads were stopped: 0.0000783 seconds, Stopping threads took: 0.0000233 seconds +2019-12-13T16:17:31.409-0500: 7085.066: Total time for which application threads were stopped: 0.0000940 seconds, Stopping threads took: 0.0000354 seconds +2019-12-13T16:18:36.447-0500: 7150.103: Total time for which application threads were stopped: 0.0000948 seconds, Stopping threads took: 0.0000364 seconds +2019-12-13T16:19:01.459-0500: 7175.114: Total time for which application threads were stopped: 0.0000938 seconds, Stopping threads took: 0.0000270 seconds +2019-12-13T16:19:31.474-0500: 7205.129: Total time for which application threads were stopped: 0.0000943 seconds, Stopping threads took: 0.0000283 seconds +2019-12-13T16:19:32.474-0500: 7206.129: Total time for which application threads were stopped: 0.0000866 seconds, Stopping threads took: 0.0000244 seconds +2019-12-13T16:21:26.529-0500: 7320.182: Total time for which application threads were stopped: 0.0000850 seconds, Stopping threads took: 0.0000263 seconds +2019-12-13T16:21:32.532-0500: 7326.184: Total time for which application threads were stopped: 0.0000867 seconds, Stopping threads took: 0.0000260 seconds +2019-12-13T16:22:32.557-0500: 7386.209: Total time for which application threads were stopped: 0.0000828 seconds, Stopping threads took: 0.0000258 seconds +2019-12-13T16:23:09.578-0500: 7423.228: Total time for which application threads were stopped: 0.0000867 seconds, Stopping threads took: 0.0000266 seconds +2019-12-13T16:23:12.579-0500: 7426.230: Total time for which application threads were stopped: 0.0000878 seconds, Stopping threads took: 0.0000262 seconds +2019-12-13T16:23:13.579-0500: 7427.230: Total time for which application threads were stopped: 0.0001116 seconds, Stopping threads took: 0.0000279 seconds +2019-12-13T16:23:14.580-0500: 7428.231: Total time for which application threads were stopped: 0.0000861 seconds, Stopping threads took: 0.0000273 seconds +2019-12-13T16:23:18.581-0500: 7432.232: Total time for which application threads were stopped: 0.0000899 seconds, Stopping threads took: 0.0000285 seconds +2019-12-13T16:23:31.589-0500: 7445.240: Total time for which application threads were stopped: 0.0000942 seconds, Stopping threads took: 0.0000286 seconds +2019-12-13T16:23:39.593-0500: 7453.243: Total time for which application threads were stopped: 0.0001319 seconds, Stopping threads took: 0.0000374 seconds +2019-12-13T16:23:41.594-0500: 7455.244: Total time for which application threads were stopped: 0.0000986 seconds, Stopping threads took: 0.0000269 seconds +2019-12-13T16:23:44.596-0500: 7458.246: Total time for which application threads were stopped: 0.0000753 seconds, Stopping threads took: 0.0000196 seconds +2019-12-13T16:23:45.597-0500: 7459.247: Total time for which application threads were stopped: 0.0000923 seconds, Stopping threads took: 0.0000269 seconds +2019-12-13T16:23:50.598-0500: 7464.248: Total time for which application threads were stopped: 0.0000901 seconds, Stopping threads took: 0.0000260 seconds +2019-12-13T16:24:02.603-0500: 7476.253: Total time for which application threads were stopped: 0.0000879 seconds, Stopping threads took: 0.0000266 seconds +2019-12-13T16:24:03.603-0500: 7477.253: Total time for which application threads were stopped: 0.0000809 seconds, Stopping threads took: 0.0000256 seconds +2019-12-13T16:24:05.604-0500: 7479.254: Total time for which application threads were stopped: 0.0000870 seconds, Stopping threads took: 0.0000265 seconds +2019-12-13T16:24:07.605-0500: 7481.255: Total time for which application threads were stopped: 0.0000906 seconds, Stopping threads took: 0.0000275 seconds +2019-12-13T16:24:09.606-0500: 7483.256: Total time for which application threads were stopped: 0.0000833 seconds, Stopping threads took: 0.0000252 seconds +2019-12-13T16:24:10.606-0500: 7484.256: Total time for which application threads were stopped: 0.0000848 seconds, Stopping threads took: 0.0000252 seconds +2019-12-13T16:24:11.606-0500: 7485.256: Total time for which application threads were stopped: 0.0000895 seconds, Stopping threads took: 0.0000260 seconds +2019-12-13T16:24:12.607-0500: 7486.257: Total time for which application threads were stopped: 0.0000837 seconds, Stopping threads took: 0.0000257 seconds +2019-12-13T16:24:14.608-0500: 7488.258: Total time for which application threads were stopped: 0.0000851 seconds, Stopping threads took: 0.0000265 seconds +2019-12-13T16:24:16.609-0500: 7490.259: Total time for which application threads were stopped: 0.0000911 seconds, Stopping threads took: 0.0000254 seconds +2019-12-13T16:24:24.612-0500: 7498.261: Total time for which application threads were stopped: 0.0001183 seconds, Stopping threads took: 0.0000294 seconds +2019-12-13T16:24:25.612-0500: 7499.262: Total time for which application threads were stopped: 0.0002358 seconds, Stopping threads took: 0.0001474 seconds +2019-12-13T16:24:50.625-0500: 7524.274: Total time for which application threads were stopped: 0.0000804 seconds, Stopping threads took: 0.0000241 seconds +2019-12-13T16:30:42.805-0500: 7876.448: Total time for which application threads were stopped: 0.0002015 seconds, Stopping threads took: 0.0000382 seconds +2019-12-13T16:36:07.971-0500: 8201.609: Total time for which application threads were stopped: 0.0001098 seconds, Stopping threads took: 0.0000310 seconds +2019-12-13T16:36:16.975-0500: 8210.612: Total time for which application threads were stopped: 0.0000827 seconds, Stopping threads took: 0.0000270 seconds +2019-12-13T16:36:31.982-0500: 8225.619: Total time for which application threads were stopped: 0.0000675 seconds, Stopping threads took: 0.0000229 seconds +2019-12-13T16:36:32.982-0500: 8226.620: Total time for which application threads were stopped: 0.0000745 seconds, Stopping threads took: 0.0000217 seconds +2019-12-13T16:44:33.635-0500: 8707.266: Total time for which application threads were stopped: 0.0007029 seconds, Stopping threads took: 0.0003845 seconds +2019-12-13T16:44:34.637-0500: 8708.267: Total time for which application threads were stopped: 0.0001147 seconds, Stopping threads took: 0.0000310 seconds +2019-12-13T16:45:15.662-0500: 8749.291: Total time for which application threads were stopped: 0.0001041 seconds, Stopping threads took: 0.0000289 seconds +2019-12-13T16:45:26.667-0500: 8760.296: Total time for which application threads were stopped: 0.0001035 seconds, Stopping threads took: 0.0000324 seconds +{Heap before GC invocations=5 (full 0): + garbage-first heap total 524288K, used 330659K [0x00000000e0000000, 0x00000000e0101000, 0x0000000100000000) + region size 1024K, 307 young (314368K), 4 survivors (4096K) + Metaspace used 32005K, capacity 33082K, committed 33408K, reserved 1079296K + class space used 3875K, capacity 4129K, committed 4224K, reserved 1048576K +2019-12-13T16:45:41.460-0500: 8775.090: [GC pause (G1 Evacuation Pause) (young) +Desired survivor size 20447232 bytes, new threshold 15 (max 15) +- age 1: 394704 bytes, 394704 total +- age 2: 1186424 bytes, 1581128 total +, 0.1129248 secs] + [Parallel Time: 99.7 ms, GC Workers: 8] + [GC Worker Start (ms): Min: 8775094.0, Avg: 8775094.9, Max: 8775095.4, Diff: 1.5] + [Ext Root Scanning (ms): Min: 1.3, Avg: 12.0, Max: 70.9, Diff: 69.6, Sum: 95.9] + [Update RS (ms): Min: 0.0, Avg: 5.9, Max: 14.2, Diff: 14.2, Sum: 47.5] + [Processed Buffers: Min: 0, Avg: 3.6, Max: 10, Diff: 10, Sum: 29] + [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.3] + [Code Root Scanning (ms): Min: 0.0, Avg: 0.9, Max: 2.1, Diff: 2.1, Sum: 6.9] + [Object Copy (ms): Min: 12.1, Avg: 58.2, Max: 74.6, Diff: 62.6, Sum: 465.7] + [Termination (ms): Min: 15.1, Avg: 21.2, Max: 25.9, Diff: 10.8, Sum: 170.0] + [Termination Attempts: Min: 145, Avg: 171.0, Max: 187, Diff: 42, Sum: 1368] + [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.3] + [GC Worker Total (ms): Min: 97.8, Avg: 98.3, Max: 99.2, Diff: 1.5, Sum: 786.5] + [GC Worker End (ms): Min: 8775193.2, Avg: 8775193.2, Max: 8775193.2, Diff: 0.0] + [Code Root Fixup: 0.4 ms] + [Code Root Purge: 0.8 ms] + [Clear CT: 0.5 ms] + [Other: 11.6 ms] + [Choose CSet: 0.0 ms] + [Ref Proc: 6.1 ms] + [Ref Enq: 0.1 ms] + [Redirty Cards: 0.2 ms] + [Humongous Register: 0.6 ms] + [Humongous Reclaim: 0.0 ms] + [Free CSet: 0.8 ms] + [Eden: 303.0M(303.0M)->0.0B(289.0M) Survivors: 4096.0K->18.0M Heap: 322.9M(512.0M)->33.2M(512.0M)] +Heap after GC invocations=6 (full 0): + garbage-first heap total 524288K, used 34032K [0x00000000e0000000, 0x00000000e0101000, 0x0000000100000000) + region size 1024K, 18 young (18432K), 18 survivors (18432K) + Metaspace used 32005K, capacity 33082K, committed 33408K, reserved 1079296K + class space used 3875K, capacity 4129K, committed 4224K, reserved 1048576K +} + [Times: user=0.20 sys=0.20, real=0.11 secs] diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 41825cda7..450add208 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -136,16 +136,18 @@ export class PDFViewer extends DocAnnotatableComponent this._showWaiting = this._showCover = true); this.props.startupLive && this.setupPdfJsViewer(); @@ -623,7 +625,8 @@ export class PDFViewer extends DocAnnotatableComponent this._coverPath.path = "http://www.cs.brown.edu/~bcz/face.gif")} onLoad={action(() => this._showWaiting = false)} + const resolved = Utils.prepend(this._coverPath.path); + return this._coverPath.path = "http://www.cs.brown.edu/~bcz/face.gif")} onLoad={action(() => this._showWaiting = false)} style={{ position: "absolute", display: "inline-block", top: 0, left: 0, width: `${nativeWidth}px`, height: `${nativeHeight}px` }} />; } diff --git a/src/server/ApiManagers/PDFManager.ts b/src/server/ApiManagers/PDFManager.ts index a190ab0cb..30fadfebd 100644 --- a/src/server/ApiManagers/PDFManager.ts +++ b/src/server/ApiManagers/PDFManager.ts @@ -24,6 +24,14 @@ export default class PDFManager extends ApiManager { } +function dispatchThumbnail(res: express.Response, { width, height }: Pdfjs.PDFPageViewport, thumbnailName: string) { + res.send({ + path: clientPathToFile(Directory.pdf_thumbnails, thumbnailName), + width, + height + }); +} + function getOrCreateThumbnail(thumbnailName: string, res: express.Response) { const noExtension = thumbnailName.substring(0, thumbnailName.length - ".png".length); const pageString = noExtension.split('-')[1]; @@ -33,17 +41,13 @@ function getOrCreateThumbnail(thumbnailName: string, res: express.Response) { exists(path, (exists: boolean) => { if (exists) { const existingThumbnail = createReadStream(path); - imageSize(existingThumbnail, (err: any, { width, height }: any) => { + imageSize(existingThumbnail, (err: any, viewport: any) => { if (err) { console.log(red(`In PDF thumbnail response, unable to determine dimensions of ${thumbnailName}:`)); console.log(err); return; } - res.send({ - path: clientPathToFile(Directory.pdf_thumbnails, thumbnailName), - width, - height - }); + dispatchThumbnail(res, viewport, thumbnailName); }); } else { const offset = thumbnailName.length - pageString.length - 5; @@ -70,19 +74,20 @@ async function CreateThumbnail(file: string, pageNumber: number, res: express.Re await page.render(renderContext).promise; const pngStream = canvas.createPNGStream(); const filenames = path.basename(file).split("."); - const pngFile = serverPathToFile(Directory.pdf_thumbnails, `${filenames[0]}-${pageNumber}.png`); + const thumbnailName = `${filenames[0]}-${pageNumber}.png`; + const pngFile = serverPathToFile(Directory.pdf_thumbnails, thumbnailName); const out = createWriteStream(pngFile); pngStream.pipe(out); - out.on("finish", () => { - res.send({ - path: pngFile, - width: viewport.width, - height: viewport.height + return new Promise((resolve, reject) => { + out.on("finish", () => { + dispatchThumbnail(res, viewport, thumbnailName); + resolve(); + }); + out.on("error", error => { + console.log(red(`In PDF thumbnail creation, encountered the following error when piping ${pngFile}:`)); + console.log(error); + reject(); }); - }); - out.on("error", error => { - console.log(red(`In PDF thumbnail creation, encountered the following error when piping ${pngFile}:`)); - console.log(error); }); } -- cgit v1.2.3-70-g09d2 From 6e6c4f7fd6b36cae11b9dc5089e672f457d5944f Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Fri, 13 Dec 2019 17:04:23 -0500 Subject: added re-write check to constructor --- src/client/views/pdf/PDFViewer.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 450add208..648522cd9 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -121,11 +121,8 @@ export class PDFViewer extends DocAnnotatableComponent this._script.run({ this: anno }, console.log, true).result); } - _lastSearch: string = ""; - componentDidMount = async () => { - !this.props.Document.lockedTransform && (this.props.Document.lockedTransform = true); - // change the address to be the file address of the PNG version of each page - // file address of the pdf + constructor(props: any) { + super(props); const backup = "oldPath"; const { url, Document } = this.props; const pathCorrectionTest = /upload\_[a-z0-9]{32}.(.*)/g; @@ -147,6 +144,13 @@ export class PDFViewer extends DocAnnotatableComponent { + !this.props.Document.lockedTransform && (this.props.Document.lockedTransform = true); + // change the address to be the file address of the PNG version of each page + // file address of the pdf const path = Utils.prepend(`/thumbnail${this.props.url.substring("files/pdfs/".length, this.props.url.length - ".pdf".length)}-${(this.Document.curPage || 1)}.png`); this._coverPath = JSON.parse(await rp.get(path)); runInAction(() => this._showWaiting = this._showCover = true); -- cgit v1.2.3-70-g09d2 From 4a0cd5a75d6f77067ee5d119012c489d73ffb649 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Fri, 13 Dec 2019 17:31:21 -0500 Subject: wrong constructor dammit --- src/client/views/nodes/PDFBox.tsx | 27 +++++++++++++++++++++++++-- src/client/views/pdf/PDFViewer.tsx | 25 ------------------------- 2 files changed, 25 insertions(+), 27 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index af996b3d8..9f67f3eab 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -6,8 +6,8 @@ import "pdfjs-dist/web/pdf_viewer.css"; import { Opt, WidthSym, Doc } from "../../../new_fields/Doc"; import { makeInterface } from "../../../new_fields/Schema"; import { ScriptField } from '../../../new_fields/ScriptField'; -import { Cast, NumCast } from "../../../new_fields/Types"; -import { PdfField } from "../../../new_fields/URLField"; +import { Cast, NumCast, StrCast } from "../../../new_fields/Types"; +import { PdfField, URLField } from "../../../new_fields/URLField"; import { Utils } from '../../../Utils'; import { KeyCodes } from '../../northstar/utils/KeyCodes'; import { undoBatch } from '../../util/UndoManager'; @@ -49,6 +49,29 @@ export class PDFBox extends DocAnnotatableComponent constructor(props: any) { super(props); this._initialScale = this.props.ScreenToLocalTransform().Scale; + + const backup = "oldPath"; + const { Document } = this.props; + const { url: { href } } = Cast(Document[this.props.fieldKey], PdfField)!; + const pathCorrectionTest = /upload\_[a-z0-9]{32}.(.*)/g; + const matches = pathCorrectionTest.exec(href); + console.log("\nHere's the { url } being fed into the outer regex:"); + console.log(href); + console.log("And here's the 'properPath' build from the captured filename:\n"); + if (matches !== null) { + const properPath = Utils.prepend(`/files/pdfs/${matches[0]}`); + console.log(properPath); + if (!properPath.includes(href)) { + console.log(`The two (url and proper path) were not equal`); + const proto = Doc.GetProto(Document); + proto[this.props.fieldKey] = new PdfField(properPath); + proto[backup] = href; + } else { + console.log(`The two (url and proper path) were equal`); + } + } else { + console.log("Outer matches was null!"); + } } componentWillUnmount() { diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 648522cd9..e34d353f4 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -121,31 +121,6 @@ export class PDFViewer extends DocAnnotatableComponent this._script.run({ this: anno }, console.log, true).result); } - constructor(props: any) { - super(props); - const backup = "oldPath"; - const { url, Document } = this.props; - const pathCorrectionTest = /upload\_[a-z0-9]{32}.(.*)/g; - const matches = pathCorrectionTest.exec(url); - console.log("\nHere's the { url } being fed into the outer regex:"); - console.log(url); - console.log("And here's the 'properPath' build from the captured filename:\n"); - if (matches !== null) { - const properPath = Utils.prepend(`/files/pdfs/${matches[0]}`); - console.log(properPath); - if (!properPath.includes(url)) { - console.log(`The two (url and proper path) were not equal`); - const proto = Doc.GetProto(Document); - proto[this.props.fieldKey] = new PdfField(properPath); - proto[backup] = url; - } else { - console.log(`The two (url and proper path) were equal`); - } - } else { - console.log("Outer matches was null!"); - } - } - _lastSearch: string = ""; componentDidMount = async () => { !this.props.Document.lockedTransform && (this.props.Document.lockedTransform = true); -- cgit v1.2.3-70-g09d2 From 56e384f2d97d2c399adf21fcf58143773fe3fd53 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sat, 14 Dec 2019 01:51:13 -0500 Subject: fixes to make nativewidth/height more robust for PDFs. fixes for search - filter out extension docs. --- src/client/documents/Documents.ts | 11 ++++--- src/client/util/DragManager.ts | 23 ++++++++------ .../util/Import & Export/DirectoryImportBox.tsx | 7 +---- src/client/util/SearchUtil.ts | 4 +-- src/client/views/DocComponent.tsx | 1 + src/client/views/collections/CollectionSubView.tsx | 4 +-- .../views/collections/ParentDocumentSelector.tsx | 2 +- src/client/views/nodes/PDFBox.tsx | 34 ++++++++++++-------- src/client/views/pdf/PDFMenu.tsx | 36 ++-------------------- src/client/views/pdf/PDFViewer.tsx | 4 +-- src/client/views/search/SearchBox.tsx | 5 ++- src/new_fields/Doc.ts | 11 +++++-- 12 files changed, 61 insertions(+), 81 deletions(-) (limited to 'src/client/views') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 7df08c7e6..4ba45ac30 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -112,7 +112,7 @@ export interface DocumentOptions { dropConverter?: ScriptField; // script to run when documents are dropped on this Document. strokeWidth?: number; color?: string; - limitHeight?:number; // maximum height for newly created (eg, from pasting) text documents + limitHeight?: number; // maximum height for newly created (eg, from pasting) text documents // [key: string]: Opt; } @@ -181,7 +181,7 @@ export namespace Docs { }], [DocumentType.PDF, { layout: { view: PDFBox, dataField: data }, - options: { nativeWidth: 1200, curPage: 1 } + options: { curPage: 1 } }], [DocumentType.ICON, { layout: { view: IconBox, dataField: data }, @@ -644,17 +644,20 @@ export namespace Docs { let ctor: ((path: string, options: DocumentOptions) => (Doc | Promise)) | undefined = undefined; if (type.indexOf("image") !== -1) { ctor = Docs.Create.ImageDocument; + if (!options.width) options.width = 300; } if (type.indexOf("video") !== -1) { ctor = Docs.Create.VideoDocument; + if (!options.width) options.width = 600; + if (!options.height) options.height = options.width * 2 / 3; } if (type.indexOf("audio") !== -1) { ctor = Docs.Create.AudioDocument; } if (type.indexOf("pdf") !== -1) { ctor = Docs.Create.PdfDocument; - options.nativeWidth = 927; - options.nativeHeight = 1200; + if (!options.width) options.width = 400; + if (!options.height) options.height = options.width * 1200 / 927; } if (type.indexOf("excel") !== -1) { ctor = Docs.Create.DBDocument; diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts index 326262895..2631a1e3c 100644 --- a/src/client/util/DragManager.ts +++ b/src/client/util/DragManager.ts @@ -18,7 +18,7 @@ import { convertDropDataToButtons } from "./DropConverter"; export type dropActionType = "alias" | "copy" | undefined; export function SetupDrag( _reference: React.RefObject, - docFunc: () => Doc | Promise, + docFunc: () => Doc | Promise | undefined, moveFunc?: DragManager.MoveFunction, dropAction?: dropActionType, treeViewId?: string, @@ -32,13 +32,15 @@ export function SetupDrag( document.removeEventListener("pointermove", onRowMove); document.removeEventListener('pointerup', onRowUp); const doc = await docFunc(); - const dragData = new DragManager.DocumentDragData([doc]); - dragData.dropAction = dropAction; - dragData.moveDocument = moveFunc; - dragData.treeViewId = treeViewId; - dragData.dontHideOnDrop = dontHideOnDrop; - DragManager.StartDocumentDrag([_reference.current!], dragData, e.x, e.y); - dragStarted && dragStarted(); + if (doc) { + const dragData = new DragManager.DocumentDragData([doc]); + dragData.dropAction = dropAction; + dragData.moveDocument = moveFunc; + dragData.treeViewId = treeViewId; + dragData.dontHideOnDrop = dontHideOnDrop; + DragManager.StartDocumentDrag([_reference.current!], dragData, e.x, e.y); + dragStarted && dragStarted(); + } }; const onRowUp = (): void => { document.removeEventListener("pointermove", onRowMove); @@ -49,12 +51,13 @@ export function SetupDrag( e.stopPropagation(); if (e.shiftKey && CollectionDockingView.Instance) { e.persist(); - CollectionDockingView.Instance.StartOtherDrag({ + let dragDoc = await docFunc(); + dragDoc && CollectionDockingView.Instance.StartOtherDrag({ pageX: e.pageX, pageY: e.pageY, preventDefault: emptyFunction, button: 0 - }, [await docFunc()]); + }, [dragDoc]); } else { document.addEventListener("pointermove", onRowMove); document.addEventListener("pointerup", onRowUp); diff --git a/src/client/util/Import & Export/DirectoryImportBox.tsx b/src/client/util/Import & Export/DirectoryImportBox.tsx index e6a215b2c..5b5bffd8c 100644 --- a/src/client/util/Import & Export/DirectoryImportBox.tsx +++ b/src/client/util/Import & Export/DirectoryImportBox.tsx @@ -122,12 +122,7 @@ export default class DirectoryImportBox extends React.Component await Promise.all(uploads.map(async ({ name, type, clientAccessPath, exifData }) => { const path = Utils.prepend(clientAccessPath); - const options = { - nativeWidth: 300, - width: 300, - title: name - }; - const document = await Docs.Get.DocumentFromType(type, path, options); + const document = await Docs.Get.DocumentFromType(type, path, { width: 300, title: name }); const { data, error } = exifData; if (document) { Doc.GetProto(document).exif = error || Docs.Get.DocumentHierarchyFromJson(data); diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index 7a9176bec..1fda82880 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -64,7 +64,7 @@ export namespace SearchUtil { const textDocs = newIds.map((id: string) => textDocMap[id]).map(doc => doc as Doc); for (let i = 0; i < textDocs.length; i++) { const testDoc = textDocs[i]; - if (testDoc instanceof Doc && testDoc.type !== DocumentType.KVP && theDocs.findIndex(d => Doc.AreProtosEqual(d, testDoc)) === -1) { + if (testDoc instanceof Doc && testDoc.type !== DocumentType.KVP && testDoc.type !== DocumentType.EXTENSION && theDocs.findIndex(d => Doc.AreProtosEqual(d, testDoc)) === -1) { theDocs.push(Doc.GetProto(testDoc)); theLines.push(newLines[i].map(line => line.replace(query, query.toUpperCase()))); } @@ -74,7 +74,7 @@ export namespace SearchUtil { const docs = ids.map((id: string) => docMap[id]).map(doc => doc as Doc); for (let i = 0; i < ids.length; i++) { const testDoc = docs[i]; - if (testDoc instanceof Doc && testDoc.type !== DocumentType.KVP && (options.allowAliases || theDocs.findIndex(d => Doc.AreProtosEqual(d, testDoc)) === -1)) { + if (testDoc instanceof Doc && testDoc.type !== DocumentType.KVP && testDoc.type !== DocumentType.EXTENSION && (options.allowAliases || theDocs.findIndex(d => Doc.AreProtosEqual(d, testDoc)) === -1)) { theDocs.push(testDoc); theLines.push([]); } diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index c7ddee7ea..7fbad4638 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -59,6 +59,7 @@ export function DocAnnotatableComponent

(schema @computed get layoutDoc() { return Doc.Layout(this.props.Document); } @computed get dataDoc() { return (this.props.DataDoc && this.props.Document.isTemplateField ? this.props.DataDoc : Doc.GetProto(this.props.Document)) as Doc; } @computed get extensionDoc() { return Doc.fieldExtensionDoc(this.dataDoc, this.props.fieldKey); } + @computed get extensionDocSync() { return Doc.fieldExtensionDocSync(this.dataDoc, this.props.fieldKey); } @computed get annotationsKey() { return "annotations"; } @action.bound diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index 5c7794cc0..062521690 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -262,7 +262,7 @@ export function CollectionSubView(schemaCtor: (doc: Doc) => T) { .then(result => { const type = result["content-type"]; if (type) { - Docs.Get.DocumentFromType(type, str, { ...options, width: 300, nativeWidth: type.indexOf("video") !== -1 ? 600 : 300 }) + Docs.Get.DocumentFromType(type, str, options) .then(doc => doc && this.props.addDocument(doc)); } }); @@ -281,7 +281,7 @@ export function CollectionSubView(schemaCtor: (doc: Doc) => T) { const dropFileName = file ? file.name : "-empty-"; promises.push(Networking.PostFormDataToServer("/upload", formData).then(results => { results.map(action(({ clientAccessPath }: any) => { - const full = { ...options, nativeWidth: type.indexOf("video") !== -1 ? 600 : 300, width: 300, title: dropFileName }; + const full = { ...options, width: 300, title: dropFileName }; const pathname = Utils.prepend(clientAccessPath); Docs.Get.DocumentFromType(type, pathname, full).then(doc => { doc && (Doc.GetProto(doc).fileUpload = basename(pathname).replace("upload_", "").replace(/\.[a-z0-9]*$/, "")); diff --git a/src/client/views/collections/ParentDocumentSelector.tsx b/src/client/views/collections/ParentDocumentSelector.tsx index 5208f65c4..31f19d42d 100644 --- a/src/client/views/collections/ParentDocumentSelector.tsx +++ b/src/client/views/collections/ParentDocumentSelector.tsx @@ -81,7 +81,7 @@ export class SelectorContextMenu extends React.Component { @observer export class ParentDocSelector extends React.Component { render() { - let flyout = ( + const flyout = (

diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx index 9f67f3eab..2f1e1832e 100644 --- a/src/client/views/nodes/PDFBox.tsx +++ b/src/client/views/nodes/PDFBox.tsx @@ -3,7 +3,7 @@ import { action, observable, runInAction, reaction, IReactionDisposer, trace, un import { observer } from "mobx-react"; import * as Pdfjs from "pdfjs-dist"; import "pdfjs-dist/web/pdf_viewer.css"; -import { Opt, WidthSym, Doc } from "../../../new_fields/Doc"; +import { Opt, WidthSym, Doc, HeightSym } from "../../../new_fields/Doc"; import { makeInterface } from "../../../new_fields/Schema"; import { ScriptField } from '../../../new_fields/ScriptField'; import { Cast, NumCast, StrCast } from "../../../new_fields/Types"; @@ -49,6 +49,9 @@ export class PDFBox extends DocAnnotatableComponent constructor(props: any) { super(props); this._initialScale = this.props.ScreenToLocalTransform().Scale; + const nw = this.Document.nativeWidth = NumCast(this.extensionDocSync.nativeWidth, NumCast(this.Document.nativeWidth, 927)); + const nh = this.Document.nativeHeight = NumCast(this.extensionDocSync.nativeHeight, NumCast(this.Document.nativeHeight, 1200)); + !this.Document.fitWidth && !this.Document.ignoreAspect && (this.Document.height = this.Document[WidthSym]() * (nh / nw)); const backup = "oldPath"; const { Document } = this.props; @@ -78,10 +81,6 @@ export class PDFBox extends DocAnnotatableComponent this._selectReactionDisposer && this._selectReactionDisposer(); } componentDidMount() { - const pdfUrl = Cast(this.dataDoc[this.props.fieldKey], PdfField); - if (pdfUrl instanceof PdfField) { - Pdfjs.getDocument(pdfUrl.url.href).promise.then(pdf => runInAction(() => this._pdf = pdf)); - } this._selectReactionDisposer = reaction(() => this.props.isSelected(), () => { document.removeEventListener("keydown", this.onKeyDown); @@ -90,9 +89,9 @@ export class PDFBox extends DocAnnotatableComponent } loaded = (nw: number, nh: number, np: number) => { - this.dataDoc.numPages = np; - this.Document.nativeWidth = nw * 96 / 72; - this.Document.nativeHeight = nh * 96 / 72; + this.extensionDocSync.numPages = np; + this.extensionDocSync.nativeWidth = this.Document.nativeWidth = nw * 96 / 72; + this.extensionDocSync.nativeHeight = this.Document.nativeHeight = nh * 96 / 72; !this.Document.fitWidth && !this.Document.ignoreAspect && (this.Document.height = this.Document[WidthSym]() * (nh / nw)); } @@ -220,9 +219,9 @@ export class PDFBox extends DocAnnotatableComponent @computed get renderTitleBox() { const classname = "pdfBox" + (this.active() ? "-interactive" : ""); return
{this.props.Document.title} @@ -248,10 +247,19 @@ export class PDFBox extends DocAnnotatableComponent
; } + _pdfjsRequested = false; render() { const pdfUrl = Cast(this.dataDoc[this.props.fieldKey], PdfField, null); if (this.props.isSelected() || this.props.Document.scrollY !== undefined) this._everActive = true; - return !pdfUrl || !this._pdf || !this.extensionDoc || (!this._everActive && this.props.ScreenToLocalTransform().Scale > 2.5) ? - this.renderTitleBox : this.renderPdfView; + if (pdfUrl && this.extensionDoc && (this._everActive || (this.extensionDoc.nativeWidth && this.props.ScreenToLocalTransform().Scale < 2.5))) { + if (pdfUrl instanceof PdfField && this._pdf) { + return this.renderPdfView; + } + if (!this._pdfjsRequested) { + this._pdfjsRequested = true; + Pdfjs.getDocument(pdfUrl.url.href).promise.then(pdf => runInAction(() => this._pdf = pdf)); + } + } + return this.renderTitleBox; } } \ No newline at end of file diff --git a/src/client/views/pdf/PDFMenu.tsx b/src/client/views/pdf/PDFMenu.tsx index 38e10e99a..503696ae9 100644 --- a/src/client/views/pdf/PDFMenu.tsx +++ b/src/client/views/pdf/PDFMenu.tsx @@ -12,19 +12,17 @@ export default class PDFMenu extends AntimodeMenu { static Instance: PDFMenu; private _commentCont = React.createRef(); - private _snippetButton: React.RefObject = React.createRef(); @observable private _keyValue: string = ""; @observable private _valueValue: string = ""; @observable private _added: boolean = false; @observable public Highlighting: boolean = false; - @observable public Status: "pdf" | "annotation" | "snippet" | "" = ""; + @observable public Status: "pdf" | "annotation" | "" = ""; public StartDrag: (e: PointerEvent, ele: HTMLElement) => void = unimplementedFunction; public Highlight: (color: string) => Opt = (color: string) => undefined; public Delete: () => void = unimplementedFunction; - public Snippet: (marquee: { left: number, top: number, width: number, height: number }) => void = unimplementedFunction; public AddTag: (key: string, value: string) => boolean = returnFalse; public PinToPres: () => void = unimplementedFunction; public Marquee: { left: number; top: number; width: number; height: number; } | undefined; @@ -80,34 +78,6 @@ export default class PDFMenu extends AntimodeMenu { this.Delete(); } - snippetStart = (e: React.PointerEvent) => { - document.removeEventListener("pointermove", this.snippetDrag); - document.addEventListener("pointermove", this.snippetDrag); - document.removeEventListener("pointerup", this.snippetEnd); - document.addEventListener("pointerup", this.snippetEnd); - - e.stopPropagation(); - e.preventDefault(); - } - - snippetDrag = (e: PointerEvent) => { - e.stopPropagation(); - e.preventDefault(); - if (!this._dragging) { - this._dragging = true; - - this.Marquee && this.Snippet(this.Marquee); - } - } - - snippetEnd = (e: PointerEvent) => { - this._dragging = false; - document.removeEventListener("pointermove", this.snippetDrag); - document.removeEventListener("pointerup", this.snippetEnd); - e.stopPropagation(); - e.preventDefault(); - } - @action keyChanged = (e: React.ChangeEvent) => { this._keyValue = e.currentTarget.value; @@ -128,14 +98,12 @@ export default class PDFMenu extends AntimodeMenu { } render() { - const buttons = this.Status === "pdf" || this.Status === "snippet" ? + const buttons = this.Status === "pdf" ? [ , , - , ] : [ diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index e34d353f4..1a09991d2 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -417,7 +417,6 @@ export class PDFViewer extends DocAnnotatableComponent v.forEach(a => a.remove())); @@ -515,7 +514,6 @@ export class PDFViewer extends DocAnnotatableComponent { this.Document.height = this.Document[WidthSym]() * this._coverPath.height / this._coverPath.width; - this.Document.nativeHeight = nativeWidth * this._coverPath.height / this._coverPath.width; + this.Document.nativeHeight = (this.Document.nativeWidth || 0) * this._coverPath.height / this._coverPath.width; }).bind(this), 0); } const nativeWidth = (this.Document.nativeWidth || 0); diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index b80c3bb54..2f28ebf76 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -234,8 +234,7 @@ export class SearchBox extends React.Component { y += 300; } } - return Docs.Create.FreeformDocument(docs, { width: 400, height: 400, panX: 175, panY: 175, backgroundColor: "grey", title: `Search Docs: "${this._searchString}"` }); - + return Docs.Create.TreeDocument(docs, { width: 200, height: 400, backgroundColor: "grey", title: `Search Docs: "${this._searchString}"` }); } @action.bound @@ -341,7 +340,7 @@ export class SearchBox extends React.Component { return (
{ e.stopPropagation(); e.preventDefault(); }}>
- + this._searchString ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection"> CreateDocumentExtensionForField(doc, fieldKey), 0); - return extension ? extension : undefined; + const extension = doc[fieldKey + "_ext"]; + if (extension === undefined) { + setTimeout(() => CreateDocumentExtensionForField(doc, fieldKey), 0); + } + return extension ? extension as Doc : undefined; + } + export function fieldExtensionDocSync(doc: Doc, fieldKey: string) { + return (doc[fieldKey + "_ext"] as Doc) || CreateDocumentExtensionForField(doc, fieldKey); } export function CreateDocumentExtensionForField(doc: Doc, fieldKey: string) { -- cgit v1.2.3-70-g09d2 From 7edce1af91621b7724e4763a5afabb4ab86d183c Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sat, 14 Dec 2019 21:49:09 -0500 Subject: make %@ portal hyperlink creation create a link as well. --- src/client/util/RichTextRules.ts | 5 +++-- src/client/views/nodes/DocumentView.tsx | 6 ------ src/client/views/nodes/FormattedTextBox.tsx | 1 + 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'src/client/views') diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts index 364c85165..f5dd459fc 100644 --- a/src/client/util/RichTextRules.ts +++ b/src/client/util/RichTextRules.ts @@ -85,8 +85,9 @@ export const inpRules = { const value = state.doc.textBetween(start, end); if (value) { DocServer.GetRefField(value).then(docx => { - const doc = ((docx instanceof Doc) && docx) || Docs.Create.FreeformDocument([], { title: value, width: 500, height: 500 }, value); - DocUtils.Publish(doc, value, returnFalse, returnFalse); + const target = ((docx instanceof Doc) && docx) || Docs.Create.FreeformDocument([], { title: value, width: 500, height: 500 }, value); + DocUtils.Publish(target, value, returnFalse, returnFalse); + DocUtils.MakeLink({ doc: (schema as any).Document }, { doc: target }, "portal link", ""); }); const link = state.schema.marks.link.create({ href: Utils.prepend("/doc/" + value), location: "onRight", title: value }); return state.tr.addMark(start, end, link); diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index b096d68fc..9f651a498 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -434,12 +434,6 @@ export class DocumentView extends DocComponent(Docu onClicks.push({ description: this.Document.ignoreClick ? "Select" : "Do Nothing", event: () => this.Document.ignoreClick = !this.Document.ignoreClick, icon: this.Document.ignoreClick ? "unlock" : "lock" }); onClicks.push({ description: this.Document.isButton || this.Document.onClick ? "Remove Click Behavior" : "Follow Link", event: this.makeBtnClicked, icon: "concierge-bell" }); onClicks.push({ description: "Edit onClick Script", icon: "edit", event: (obj: any) => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", obj.x, obj.y) }); - onClicks.push({ - description: "Edit onClick Foreach Doc Script", icon: "edit", event: (obj: any) => { - this.props.Document.collectionContext = this.props.ContainingCollectionDoc; - ScriptBox.EditButtonScript("Foreach Collection Doc (d) => ", this.props.Document, "onClick", obj.x, obj.y, "docList(this.collectionContext.data).map(d => {", "});\n"); - } - }); !existingOnClick && cm.addItem({ description: "OnClick...", subitems: onClicks, icon: "hand-point-right" }); const funcs: ContextMenuProps[] = []; diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index a298fd6af..e40c00e54 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -822,6 +822,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps & clipboardTextSerializer: this.clipboardTextSerializer, handlePaste: this.handlePaste, }); + (this._editorView.state.schema as any).Document = this.props.Document; if (startup && this._editorView) { Doc.GetProto(doc).documentText = undefined; this._editorView.dispatch(this._editorView.state.tr.insertText(startup)); -- cgit v1.2.3-70-g09d2 From 877a6f481a06e2454ff9d8eabe43acb0e58a2676 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sun, 15 Dec 2019 10:38:23 -0500 Subject: writing selectedDocs to user doc to allow selection to be part of scripting --- src/client/util/DragManager.ts | 2 +- src/client/util/SelectionManager.ts | 3 +++ src/client/views/nodes/FormattedTextBox.tsx | 2 +- src/client/views/nodes/KeyValueBox.tsx | 3 ++- src/new_fields/Doc.ts | 12 +++++++++--- 5 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src/client/views') diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts index 2631a1e3c..df2f5fe3c 100644 --- a/src/client/util/DragManager.ts +++ b/src/client/util/DragManager.ts @@ -51,7 +51,7 @@ export function SetupDrag( e.stopPropagation(); if (e.shiftKey && CollectionDockingView.Instance) { e.persist(); - let dragDoc = await docFunc(); + const dragDoc = await docFunc(); dragDoc && CollectionDockingView.Instance.StartOtherDrag({ pageX: e.pageX, pageY: e.pageY, diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts index e01216e0f..d9283de35 100644 --- a/src/client/util/SelectionManager.ts +++ b/src/client/util/SelectionManager.ts @@ -2,6 +2,8 @@ import { observable, action, runInAction, ObservableMap } from "mobx"; import { Doc } from "../../new_fields/Doc"; import { DocumentView } from "../views/nodes/DocumentView"; import { computedFn } from "mobx-utils"; +import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils"; +import { List } from "../../new_fields/List"; export namespace SelectionManager { @@ -27,6 +29,7 @@ export namespace SelectionManager { manager.SelectedDocuments.clear(); manager.SelectedDocuments.set(docView, true); } + Doc.UserDoc().SelectedDocs = new List(SelectionManager.SelectedDocuments().map(dv => dv.props.Document)); } @action DeselectDoc(docView: DocumentView): void { diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index e40c00e54..3efbd434e 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -822,7 +822,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps & clipboardTextSerializer: this.clipboardTextSerializer, handlePaste: this.handlePaste, }); - (this._editorView.state.schema as any).Document = this.props.Document; + this._editorView.state.schema.Document = this.props.Document; if (startup && this._editorView) { Doc.GetProto(doc).documentText = undefined; this._editorView.dispatch(this._editorView.state.tr.insertText(startup)); diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx index 322d639dc..07d6d6f5e 100644 --- a/src/client/views/nodes/KeyValueBox.tsx +++ b/src/client/views/nodes/KeyValueBox.tsx @@ -57,7 +57,8 @@ export class KeyValueBox extends React.Component { value = eq ? value.substr(1) : value; const dubEq = value.startsWith(":=") ? "computed" : value.startsWith(";=") ? "script" : false; value = dubEq ? value.substr(2) : value; - const options: ScriptOptions = { addReturn: true, params: { this: "Doc" } }; + const editable = value.includes("selectedDocs"); // bcz: Argh TODO - need a UI mechanism for letting user know that a function can't be run read-only. e.g., selectedDocs() wants to cache its old value so it can't be run read-only + const options: ScriptOptions = { addReturn: true, params: { this: "Doc" }, editable: editable }; if (dubEq) options.typecheck = false; const script = CompileScript(value, options); if (!script.compiled) { diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index aa33d4c8b..a22b289bb 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -1,4 +1,4 @@ -import { observable, ObservableMap, runInAction, action } from "mobx"; +import { observable, ObservableMap, runInAction, action, untracked } from "mobx"; import { alias, map, serializable } from "serializr"; import { DocServer } from "../client/DocServer"; import { DocumentType } from "../client/documents/DocumentTypes"; @@ -474,7 +474,7 @@ export namespace Doc { return extension ? extension as Doc : undefined; } export function fieldExtensionDocSync(doc: Doc, fieldKey: string) { - return (doc[fieldKey + "_ext"] as Doc) || CreateDocumentExtensionForField(doc, fieldKey); + return (doc[fieldKey + "_ext"] as Doc) || CreateDocumentExtensionForField(doc, fieldKey); } export function CreateDocumentExtensionForField(doc: Doc, fieldKey: string) { @@ -753,4 +753,10 @@ Scripting.addGlobal(function aliasDocs(field: any) { return new List(field. Scripting.addGlobal(function docList(field: any) { return DocListCast(field); }); Scripting.addGlobal(function sameDocs(doc1: any, doc2: any) { return Doc.AreProtosEqual(doc1, doc2); }); Scripting.addGlobal(function undo() { return UndoManager.Undo(); }); -Scripting.addGlobal(function redo() { return UndoManager.Redo(); }); \ No newline at end of file +Scripting.addGlobal(function redo() { return UndoManager.Redo(); }); +Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: boolean) { + let docs = DocListCast(Doc.UserDoc().SelectedDocs).filter(d => (!excludeCollections || !Cast(d.data, listSpec(Doc), null)) && d.type !== DocumentType.KVP && !Doc.AreProtosEqual(d, container)); + if (docs.length) untracked(() => container && (container.cachedSelection = new List(docs))); + else docs = untracked(() => DocListCast(container.cachedSelection)); + return new List(docs); +}); \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 6683517a69f4806d026e7af85069f18b1f0a9d1f Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sun, 15 Dec 2019 12:44:20 -0500 Subject: added _last_ for computedScripts to access last value of script --- src/client/util/RichTextSchema.tsx | 6 +++++- src/client/views/nodes/KeyValueBox.tsx | 3 +-- src/new_fields/Doc.ts | 5 ++--- src/new_fields/ScriptField.ts | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/client/views') diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx index 543f45731..7a048ed0d 100644 --- a/src/client/util/RichTextSchema.tsx +++ b/src/client/util/RichTextSchema.tsx @@ -741,7 +741,11 @@ export class DashDocView { self._dashDoc = dashDoc; dashDoc.hideSidebar = true; if (node.attrs.width !== dashDoc.width + "px" || node.attrs.height !== dashDoc.height + "px") { - view.dispatch(view.state.tr.setNodeMarkup(getPos(), null, { ...node.attrs, width: dashDoc.width + "px", height: dashDoc.height + "px" })); + try { // bcz: an exception will be thrown if two aliases are open at the same time when a doc view comment is made + view.dispatch(view.state.tr.setNodeMarkup(getPos(), null, { ...node.attrs, width: dashDoc.width + "px", height: dashDoc.height + "px" })); + } catch (e) { + console.log(e); + } } this._reactionDisposer && this._reactionDisposer(); this._reactionDisposer = reaction(() => dashDoc[HeightSym]() + dashDoc[WidthSym](), () => { diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx index 07d6d6f5e..234a6a9d3 100644 --- a/src/client/views/nodes/KeyValueBox.tsx +++ b/src/client/views/nodes/KeyValueBox.tsx @@ -57,8 +57,7 @@ export class KeyValueBox extends React.Component { value = eq ? value.substr(1) : value; const dubEq = value.startsWith(":=") ? "computed" : value.startsWith(";=") ? "script" : false; value = dubEq ? value.substr(2) : value; - const editable = value.includes("selectedDocs"); // bcz: Argh TODO - need a UI mechanism for letting user know that a function can't be run read-only. e.g., selectedDocs() wants to cache its old value so it can't be run read-only - const options: ScriptOptions = { addReturn: true, params: { this: "Doc" }, editable: editable }; + const options: ScriptOptions = { addReturn: true, params: { this: "Doc", _last_: "any" }, editable: false }; if (dubEq) options.typecheck = false; const script = CompileScript(value, options); if (!script.compiled) { diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index a22b289bb..171f3fd2d 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -754,9 +754,8 @@ Scripting.addGlobal(function docList(field: any) { return DocListCast(field); }) Scripting.addGlobal(function sameDocs(doc1: any, doc2: any) { return Doc.AreProtosEqual(doc1, doc2); }); Scripting.addGlobal(function undo() { return UndoManager.Undo(); }); Scripting.addGlobal(function redo() { return UndoManager.Redo(); }); -Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: boolean) { +Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: boolean, prevValue: any) { let docs = DocListCast(Doc.UserDoc().SelectedDocs).filter(d => (!excludeCollections || !Cast(d.data, listSpec(Doc), null)) && d.type !== DocumentType.KVP && !Doc.AreProtosEqual(d, container)); - if (docs.length) untracked(() => container && (container.cachedSelection = new List(docs))); - else docs = untracked(() => DocListCast(container.cachedSelection)); + if (!docs.length) return prevValue; return new List(docs); }); \ No newline at end of file diff --git a/src/new_fields/ScriptField.ts b/src/new_fields/ScriptField.ts index 6b2723663..0cadb60ed 100644 --- a/src/new_fields/ScriptField.ts +++ b/src/new_fields/ScriptField.ts @@ -124,8 +124,9 @@ export class ScriptField extends ObjectField { @scriptingGlobal @Deserializable("computed", deserializeScript) export class ComputedField extends ScriptField { + _lastComputedResult: any; //TODO maybe add an observable cache based on what is passed in for doc, considering there shouldn't really be that many possible values for doc - value = computedFn((doc: Doc) => this.script.run({ this: doc }, console.log).result); + value = computedFn((doc: Doc) => this._lastComputedResult = this.script.run({ this: doc, _last_: this._lastComputedResult }, console.log).result); public static MakeScript(script: string, params: object = {}, ) { const compiled = ScriptField.CompileScript(script, params, false); return compiled.compiled ? new ComputedField(compiled) : undefined; -- cgit v1.2.3-70-g09d2 From 2bb5667b10a8c402f8ec75c632ca3fdabe642419 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sun, 15 Dec 2019 18:25:03 -0500 Subject: added LOD detail switching for collection free form views --- .../collectionFreeForm/CollectionFreeFormView.scss | 2 ++ .../collectionFreeForm/CollectionFreeFormView.tsx | 21 ++++++++++++++------- src/new_fields/documentSchemas.ts | 4 +++- 3 files changed, 19 insertions(+), 8 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.scss b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.scss index 070d4aa65..f8a9e49d8 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.scss +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.scss @@ -52,6 +52,8 @@ left: 0; width: 100%; height: 100%; + align-items: center; + display: flex; } // selection border...? diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 89c1df598..9bb6fa97e 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -882,6 +882,19 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) { eles.push(); return eles; } + @computed get placeholder() { + return
+ {this.props.Document.title}>
; + } + @computed get marqueeView() { + return + + {this.children} + + ; + } render() { TraceMobx(); // update the actual dimensions of the collection so that they can inquired (e.g., by a minimap) @@ -895,13 +908,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
- - - {this.children} - - + {!BoolCast(this.Document.LODdisable) && this.props.renderDepth > 0 && this.Document[WidthSym]() * this.Document[HeightSym]() / this.props.ScreenToLocalTransform().Scale < NumCast(this.Document.LODarea, 100000) ? this.placeholder : this.marqueeView}
; } diff --git a/src/new_fields/documentSchemas.ts b/src/new_fields/documentSchemas.ts index 5c2ba6111..21e69fbed 100644 --- a/src/new_fields/documentSchemas.ts +++ b/src/new_fields/documentSchemas.ts @@ -48,7 +48,9 @@ export const documentSchema = createSchema({ animateToDimensions: listSpec("number"), // layout information about the target rectangle a document is animating towards scrollToLinkID: "string", // id of link being traversed. allows this doc to scroll/highlight/etc its link anchor. scrollToLinkID should be set to undefined by this doc after it sets up its scroll,etc. strokeWidth: "number", - fontSize: "string" + fontSize: "string", + LODarea: "number", // area (width*height) where CollectionFreeFormViews switch from a label to rendering contents + LODdisable: "boolean", // whether to disbale LOD switching for CollectionFreeFormViews }); export const positionSchema = createSchema({ -- cgit v1.2.3-70-g09d2 From 55823d0cc300f5cdd90ee34013bfdee93b5709e6 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sun, 15 Dec 2019 20:11:58 -0500 Subject: added a DocumentBox as a contentfitting container for another document. added a menu item for showing selected document. --- src/client/documents/DocumentTypes.ts | 3 +- src/client/documents/Documents.ts | 9 ++++ .../collectionFreeForm/CollectionFreeFormView.tsx | 2 +- .../views/nodes/ContentFittingDocumentView.tsx | 6 +-- src/client/views/nodes/DocumentBox.scss | 6 +++ src/client/views/nodes/DocumentBox.tsx | 55 ++++++++++++++++++++++ src/client/views/nodes/DocumentContentsView.tsx | 3 +- src/client/views/nodes/ImageBox.tsx | 1 - src/new_fields/ScriptField.ts | 2 +- .../authentication/models/current_user_utils.ts | 1 + 10 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 src/client/views/nodes/DocumentBox.scss create mode 100644 src/client/views/nodes/DocumentBox.tsx (limited to 'src/client/views') diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts index f6dd0c346..8f96b2fa6 100644 --- a/src/client/documents/DocumentTypes.ts +++ b/src/client/documents/DocumentTypes.ts @@ -25,5 +25,6 @@ export enum DocumentType { COLOR = "color", DOCULINK = "doculink", PDFANNO = "pdfanno", - INK = "ink" + INK = "ink", + DOCUMENT = "document" } \ No newline at end of file diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 4ba45ac30..50c51ace1 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -48,6 +48,7 @@ import { PresElementBox } from "../views/presentationview/PresElementBox"; import { QueryBox } from "../views/nodes/QueryBox"; import { ColorBox } from "../views/nodes/ColorBox"; import { DocuLinkBox } from "../views/nodes/DocuLinkBox"; +import { DocumentBox } from "../views/nodes/DocumentBox"; import { InkingStroke } from "../views/InkingStroke"; import { InkField } from "../../new_fields/InkField"; const requestImageSize = require('../util/request-image-size'); @@ -171,6 +172,10 @@ export namespace Docs { layout: { view: KeyValueBox, dataField: data }, options: { height: 150 } }], + [DocumentType.DOCUMENT, { + layout: { view: DocumentBox, dataField: data }, + options: { height: 250 } + }], [DocumentType.VID, { layout: { view: VideoBox, dataField: data }, options: { currentTimecode: 0 }, @@ -482,6 +487,10 @@ export namespace Docs { return InstanceFromProto(Prototypes.get(DocumentType.KVP), document, { title: document.title + ".kvp", ...options }); } + export function DocumentDocument(document?: Doc, options: DocumentOptions = {}) { + return InstanceFromProto(Prototypes.get(DocumentType.DOCUMENT), document, { title: document ? document.title + "" : "container", ...options }); + } + export function FreeformDocument(documents: Array, options: DocumentOptions, id?: string) { return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title", "#f1efeb")]), ...options, viewType: CollectionViewType.Freeform }, id); } diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 9bb6fa97e..0b18e9f25 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -908,7 +908,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
- {!BoolCast(this.Document.LODdisable) && this.props.renderDepth > 0 && this.Document[WidthSym]() * this.Document[HeightSym]() / this.props.ScreenToLocalTransform().Scale < NumCast(this.Document.LODarea, 100000) ? this.placeholder : this.marqueeView} + {!BoolCast(this.Document.LODdisable) && !this.props.isAnnotationOverlay && this.props.renderDepth > 0 && this.Document[WidthSym]() * this.Document[HeightSym]() / this.props.ScreenToLocalTransform().Scale < NumCast(this.Document.LODarea, 100000) ? this.placeholder : this.marqueeView}
; } diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx index 5e3306a11..2565fd932 100644 --- a/src/client/views/nodes/ContentFittingDocumentView.tsx +++ b/src/client/views/nodes/ContentFittingDocumentView.tsx @@ -31,9 +31,9 @@ interface ContentFittingDocumentViewProps { CollectionDoc?: Doc; onClick?: ScriptField; getTransform: () => Transform; - addDocument: (document: Doc) => boolean; - moveDocument: (document: Doc, target: Doc | undefined, addDoc: ((doc: Doc) => boolean)) => boolean; - removeDocument: (document: Doc) => boolean; + addDocument?: (document: Doc) => boolean; + moveDocument?: (document: Doc, target: Doc | undefined, addDoc: ((doc: Doc) => boolean)) => boolean; + removeDocument?: (document: Doc) => boolean; active: (outsideReaction: boolean) => boolean; whenActiveChanged: (isActive: boolean) => void; addDocTab: (document: Doc, dataDoc: Doc | undefined, where: string) => boolean; diff --git a/src/client/views/nodes/DocumentBox.scss b/src/client/views/nodes/DocumentBox.scss new file mode 100644 index 000000000..6a2f98166 --- /dev/null +++ b/src/client/views/nodes/DocumentBox.scss @@ -0,0 +1,6 @@ +.documentBox-container { + width: 100%; + height: 100%; + pointer-events: all; + background: gray; +} \ No newline at end of file diff --git a/src/client/views/nodes/DocumentBox.tsx b/src/client/views/nodes/DocumentBox.tsx new file mode 100644 index 000000000..2f2cba485 --- /dev/null +++ b/src/client/views/nodes/DocumentBox.tsx @@ -0,0 +1,55 @@ +import { observer } from "mobx-react"; +import { Doc } from "../../../new_fields/Doc"; +import { documentSchema } from "../../../new_fields/documentSchemas"; +import { makeInterface } from "../../../new_fields/Schema"; +import { ComputedField } from "../../../new_fields/ScriptField"; +import { emptyFunction, emptyPath } from "../../../Utils"; +import { ContextMenu } from "../ContextMenu"; +import { ContextMenuProps } from "../ContextMenuItem"; +import { DocComponent } from "../DocComponent"; +import { ContentFittingDocumentView } from "./ContentFittingDocumentView"; +import "./DocumentBox.scss"; +import { FieldView, FieldViewProps } from "./FieldView"; +import React = require("react"); + +type DocBoxSchema = makeInterface<[typeof documentSchema]>; +const DocBoxDocument = makeInterface(documentSchema); + +@observer +export class DocumentBox extends DocComponent(DocBoxDocument) { + public static LayoutString(fieldKey: string) { return FieldView.LayoutString(DocumentBox, fieldKey); } + + + specificContextMenu = (e: React.MouseEvent): void => { + const funcs: ContextMenuProps[] = []; + funcs.push({ description: "Auto Show Selected", event: () => Doc.GetProto(this.props.Document).data = ComputedField.MakeFunction("selectedDocs(this,true,_last_)?.[0]"), icon: "expand-arrows-alt" }); + + ContextMenu.Instance.addItem({ description: "DocumentBox Funcs...", subitems: funcs, icon: "asterisk" }); + } + render() { + const containedDoc = this.props.Document[this.props.fieldKey] as Doc; + return
+ {!containedDoc ? (null) : } +
; + } +} diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx index 1bbc82119..8f6bfc8e1 100644 --- a/src/client/views/nodes/DocumentContentsView.tsx +++ b/src/client/views/nodes/DocumentContentsView.tsx @@ -14,6 +14,7 @@ import { LinkFollowBox } from "../linking/LinkFollowBox"; import { YoutubeBox } from "./../../apis/youtube/YoutubeBox"; import { AudioBox } from "./AudioBox"; import { ButtonBox } from "./ButtonBox"; +import { DocumentBox } from "./DocumentBox"; import { DocumentViewProps } from "./DocumentView"; import "./DocumentView.scss"; import { FontIconBox } from "./FontIconBox"; @@ -102,7 +103,7 @@ export class DocumentContentsView extends React.Component Date: Sun, 15 Dec 2019 20:31:34 -0500 Subject: from last --- .../views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/views') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 0b18e9f25..fc507bf5e 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -908,7 +908,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
- {!BoolCast(this.Document.LODdisable) && !this.props.isAnnotationOverlay && this.props.renderDepth > 0 && this.Document[WidthSym]() * this.Document[HeightSym]() / this.props.ScreenToLocalTransform().Scale < NumCast(this.Document.LODarea, 100000) ? this.placeholder : this.marqueeView} + {!BoolCast(this.Document.LODdisable) && !this.props.isAnnotationOverlay && this.props.renderDepth > 0 && this.Document[WidthSym]() * this.Document[HeightSym]() / this.props.ScreenToLocalTransform().Scale / this.props.ScreenToLocalTransform().Scale < NumCast(this.Document.LODarea, 100000) ? this.placeholder : this.marqueeView}
; } -- cgit v1.2.3-70-g09d2 From 15333069562d265a8bc8e5d1d3ec1bfc564d8796 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Sun, 15 Dec 2019 21:47:34 -0500 Subject: fixed auto show seleted function --- src/client/views/nodes/DocumentBox.tsx | 2 +- src/new_fields/Doc.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/nodes/DocumentBox.tsx b/src/client/views/nodes/DocumentBox.tsx index 2f2cba485..b9a97b42d 100644 --- a/src/client/views/nodes/DocumentBox.tsx +++ b/src/client/views/nodes/DocumentBox.tsx @@ -22,7 +22,7 @@ export class DocumentBox extends DocComponent(DocB specificContextMenu = (e: React.MouseEvent): void => { const funcs: ContextMenuProps[] = []; - funcs.push({ description: "Auto Show Selected", event: () => Doc.GetProto(this.props.Document).data = ComputedField.MakeFunction("selectedDocs(this,true,_last_)?.[0]"), icon: "expand-arrows-alt" }); + funcs.push({ description: "Auto Show Selected", event: () => Doc.GetProto(this.props.Document).data = ComputedField.MakeFunction("selectedDocs(this,true,[_last_])?.[0]"), icon: "expand-arrows-alt" }); ContextMenu.Instance.addItem({ description: "DocumentBox Funcs...", subitems: funcs, icon: "asterisk" }); } diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 171f3fd2d..c3a6a1658 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -756,6 +756,5 @@ Scripting.addGlobal(function undo() { return UndoManager.Undo(); }); Scripting.addGlobal(function redo() { return UndoManager.Redo(); }); Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: boolean, prevValue: any) { let docs = DocListCast(Doc.UserDoc().SelectedDocs).filter(d => (!excludeCollections || !Cast(d.data, listSpec(Doc), null)) && d.type !== DocumentType.KVP && !Doc.AreProtosEqual(d, container)); - if (!docs.length) return prevValue; - return new List(docs); + return docs.length ? new List(docs) : prevValue; }); \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 01aca20caca1f8736fd7035b8cda35e7c415aa2b Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Mon, 16 Dec 2019 00:38:59 -0500 Subject: added onclick option for selecting first link target. changed contentFittingDocView to center vertically as well as horizontally --- src/client/util/SelectionManager.ts | 5 ++++- src/client/views/nodes/ContentFittingDocumentView.scss | 5 +++-- src/client/views/nodes/ContentFittingDocumentView.tsx | 18 +++++++++++------- src/client/views/nodes/DocumentView.tsx | 15 +++++++++++++++ src/new_fields/Doc.ts | 4 +++- 5 files changed, 36 insertions(+), 11 deletions(-) (limited to 'src/client/views') diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts index d9283de35..cb7a69295 100644 --- a/src/client/util/SelectionManager.ts +++ b/src/client/util/SelectionManager.ts @@ -2,8 +2,8 @@ import { observable, action, runInAction, ObservableMap } from "mobx"; import { Doc } from "../../new_fields/Doc"; import { DocumentView } from "../views/nodes/DocumentView"; import { computedFn } from "mobx-utils"; -import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils"; import { List } from "../../new_fields/List"; +import { Scripting } from "./Scripting"; export namespace SelectionManager { @@ -81,3 +81,6 @@ export namespace SelectionManager { return Array.from(manager.SelectedDocuments.keys()); } } + +Scripting.addGlobal(function selectDoc(doc: any) { Doc.UserDoc().SelectedDocs = new List([doc]); }); + diff --git a/src/client/views/nodes/ContentFittingDocumentView.scss b/src/client/views/nodes/ContentFittingDocumentView.scss index 796e67269..2801af441 100644 --- a/src/client/views/nodes/ContentFittingDocumentView.scss +++ b/src/client/views/nodes/ContentFittingDocumentView.scss @@ -2,10 +2,11 @@ .contentFittingDocumentView { position: relative; - height: auto !important; + display: flex; + align-items: center; .contentFittingDocumentView-previewDoc { - position: absolute; + position: relative; display: inline; } diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx index 2565fd932..e15790c9d 100644 --- a/src/client/views/nodes/ContentFittingDocumentView.tsx +++ b/src/client/views/nodes/ContentFittingDocumentView.tsx @@ -47,8 +47,8 @@ interface ContentFittingDocumentViewProps { export class ContentFittingDocumentView extends React.Component{ public get displayName() { return "DocumentView(" + this.props.Document?.title + ")"; } // this makes mobx trace() statements more descriptive private get layoutDoc() { return this.props.Document && Doc.Layout(this.props.Document); } - private get nativeWidth() { return NumCast(this.layoutDoc!.nativeWidth, this.props.PanelWidth()); } - private get nativeHeight() { return NumCast(this.layoutDoc!.nativeHeight, this.props.PanelHeight()); } + private get nativeWidth() { return NumCast(this.layoutDoc?.nativeWidth, this.props.PanelWidth()); } + private get nativeHeight() { return NumCast(this.layoutDoc?.nativeHeight, this.props.PanelHeight()); } private contentScaling = () => { const wscale = this.props.PanelWidth() / (this.nativeWidth ? this.nativeWidth : this.props.PanelWidth()); if (wscale * this.nativeHeight > this.props.PanelHeight()) { @@ -73,21 +73,25 @@ export class ContentFittingDocumentView extends React.Component this.nativeWidth && (!this.props.Document || !this.props.Document.fitWidth) ? this.nativeWidth * this.contentScaling() : this.props.PanelWidth(); private PanelHeight = () => this.nativeHeight && (!this.props.Document || !this.props.Document.fitWidth) ? this.nativeHeight * this.contentScaling() : this.props.PanelHeight(); - private getTransform = () => this.props.getTransform().translate(-this.centeringOffset, 0).scale(1 / this.contentScaling()); + private getTransform = () => this.props.getTransform().translate(-this.centeringOffset, -this.centeringYOffset).scale(1 / this.contentScaling()); private get centeringOffset() { return this.nativeWidth && (!this.props.Document || !this.props.Document.fitWidth) ? (this.props.PanelWidth() - this.nativeWidth * this.contentScaling()) / 2 : 0; } + private get centeringYOffset() { return Math.abs(this.centeringOffset) < 0.001 ? (this.props.PanelHeight() - this.nativeHeight * this.contentScaling()) / 2 : 0; } - @computed get borderRounding() { return StrCast(this.props.Document!.borderRounding); } + @computed get borderRounding() { return StrCast(this.props.Document?.borderRounding); } render() { TraceMobx(); - return (
+ return (
0.001 ? "auto" : this.props.PanelWidth(), + height: Math.abs(this.centeringOffset) > 0.0001 ? "auto" : this.props.PanelHeight() + }}> {!this.props.Document || !this.props.PanelWidth ? (null) : (
0.001 ? `${100 * this.nativeHeight / this.nativeWidth * this.props.PanelWidth() / this.props.PanelHeight()}%` : this.props.PanelHeight(), + width: Math.abs(this.centeringOffset) > 0.001 ? `${100 * (this.props.PanelWidth() - this.centeringOffset * 2) / this.props.PanelWidth()}%` : this.props.PanelWidth() }}> (Docu this.onClickHandler.script.run({ this: this.Document.isTemplateField && this.props.DataDoc ? this.props.DataDoc : this.props.Document }, console.log); } else if (this.Document.type === DocumentType.BUTTON) { ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", e.clientX, e.clientY); + } else if (this.props.Document.isButton === "Selector") { // this should be moved to an OnClick script + this.Document.links?.[0] instanceof Doc && (Doc.UserDoc().SelectedDocs = new List([Doc.LinkOtherAnchor(this.Document.links[0]!, this.props.Document)])); } else if (this.Document.isButton) { SelectionManager.SelectDoc(this, e.ctrlKey); // don't think this should happen if a button action is actually triggered. this.buttonClick(e.altKey, e.ctrlKey); @@ -315,6 +318,17 @@ export class DocumentView extends DocComponent(Docu } } + @undoBatch + makeSelBtnClicked = (): void => { + if (this.Document.isButton || this.Document.onClick || this.Document.ignoreClick) { + this.Document.isButton = false; + this.Document.ignoreClick = false; + this.Document.onClick = undefined; + } else { + this.props.Document.isButton = "Selector"; + } + } + @undoBatch @action drop = async (e: Event, de: DragManager.DropEvent) => { @@ -433,6 +447,7 @@ export class DocumentView extends DocComponent(Docu onClicks.push({ description: "Toggle Detail", event: () => this.Document.onClick = ScriptField.MakeScript("toggleDetail(this)"), icon: "window-restore" }); onClicks.push({ description: this.Document.ignoreClick ? "Select" : "Do Nothing", event: () => this.Document.ignoreClick = !this.Document.ignoreClick, icon: this.Document.ignoreClick ? "unlock" : "lock" }); onClicks.push({ description: this.Document.isButton || this.Document.onClick ? "Remove Click Behavior" : "Follow Link", event: this.makeBtnClicked, icon: "concierge-bell" }); + onClicks.push({ description: this.props.Document.isButton ? "Remove Select Link Behavior" : "Select Link", event: this.makeSelBtnClicked, icon: "concierge-bell" }); onClicks.push({ description: "Edit onClick Script", icon: "edit", event: (obj: any) => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", obj.x, obj.y) }); !existingOnClick && cm.addItem({ description: "OnClick...", subitems: onClicks, icon: "hand-point-right" }); diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index c3a6a1658..b8f11c8c8 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -687,7 +687,9 @@ export namespace Doc { } + export function LinkOtherAnchor(linkDoc: Doc, anchorDoc: Doc) { return Doc.AreProtosEqual(anchorDoc, Cast(linkDoc.anchor1, Doc) as Doc) ? Cast(linkDoc.anchor2, Doc) as Doc : Cast(linkDoc.anchor1, Doc) as Doc; } export function LinkEndpoint(linkDoc: Doc, anchorDoc: Doc) { return Doc.AreProtosEqual(anchorDoc, Cast(linkDoc.anchor1, Doc) as Doc) ? "layoutKey1" : "layoutKey2"; } + export function linkFollowUnhighlight() { Doc.UnhighlightAll(); document.removeEventListener("pointerdown", linkFollowUnhighlight); @@ -755,6 +757,6 @@ Scripting.addGlobal(function sameDocs(doc1: any, doc2: any) { return Doc.AreProt Scripting.addGlobal(function undo() { return UndoManager.Undo(); }); Scripting.addGlobal(function redo() { return UndoManager.Redo(); }); Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: boolean, prevValue: any) { - let docs = DocListCast(Doc.UserDoc().SelectedDocs).filter(d => (!excludeCollections || !Cast(d.data, listSpec(Doc), null)) && d.type !== DocumentType.KVP && !Doc.AreProtosEqual(d, container)); + const docs = DocListCast(Doc.UserDoc().SelectedDocs).filter(d => !Doc.AreProtosEqual(d, container) && (!excludeCollections || !Cast(d.data, listSpec(Doc), null)) && d.type !== DocumentType.KVP); return docs.length ? new List(docs) : prevValue; }); \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 001cea83f6c57914e0e76a75a94f3e06e542a419 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Mon, 16 Dec 2019 01:01:09 -0500 Subject: from last --- src/client/views/nodes/DocumentView.tsx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/client/views') diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 59e68fc4c..18885f272 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -44,6 +44,7 @@ import { InkingControl } from '../InkingControl'; import { InkTool } from '../../../new_fields/InkField'; import { TraceMobx } from '../../../new_fields/util'; import { List } from '../../../new_fields/List'; +import { FormattedTextBoxComment } from './FormattedTextBoxComment'; library.add(fa.faEdit, fa.faTrash, fa.faShare, fa.faDownload, fa.faExpandArrowsAlt, fa.faCompressArrowsAlt, fa.faLayerGroup, fa.faExternalLinkAlt, fa.faAlignCenter, fa.faCaretSquareRight, fa.faSquare, fa.faConciergeBell, fa.faWindowRestore, fa.faFolder, fa.faMapPin, fa.faLink, fa.faFingerprint, fa.faCrosshairs, fa.faDesktop, fa.faUnlock, fa.faLock, fa.faLaptopCode, fa.faMale, @@ -172,6 +173,7 @@ export class DocumentView extends DocComponent(Docu } else if (this.Document.type === DocumentType.BUTTON) { ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", e.clientX, e.clientY); } else if (this.props.Document.isButton === "Selector") { // this should be moved to an OnClick script + FormattedTextBoxComment.Hide(); this.Document.links?.[0] instanceof Doc && (Doc.UserDoc().SelectedDocs = new List([Doc.LinkOtherAnchor(this.Document.links[0]!, this.props.Document)])); } else if (this.Document.isButton) { SelectionManager.SelectDoc(this, e.ctrlKey); // don't think this should happen if a button action is actually triggered. -- cgit v1.2.3-70-g09d2