From a6d904bcd18a2c9962abfd9b5b325340f6b18b0d Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 9 Feb 2022 08:59:32 -0500 Subject: speeding up rendering using bitmaps for webpages and other heavyweight docs. --- .../collections/collectionFreeForm/MarqueeView.tsx | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/client/views/collections/collectionFreeForm') diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index 08da682bb..b10b0912f 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -30,6 +30,9 @@ import "./MarqueeView.scss"; import React = require("react"); import { StyleLayers } from "../../StyleProvider"; import { TreeView } from "../TreeView"; +import { VideoBox } from "../../nodes/VideoBox"; +import { ImageField, WebField } from "../../../../fields/URLField"; +import { pasteImageBitmap } from "../../nodes/WebBoxRenderer"; interface MarqueeViewProps { getContainerTransform: () => Transform; @@ -134,17 +137,15 @@ export class MarqueeView extends React.Component { - // const ns = text.split("\n").filter(t => t.trim() !== "\r" && t.trim() !== ""); - // if (ns.length === 1 && text.startsWith("http")) { - // this.props.addDocument(Docs.Create.ImageDocument(text, { _nativeWidth: 300, _width: 300, x: x, y: y }));// paste an image from its URL in the paste buffer - // } else { - // this.pasteTable(ns, x, y); - // } - // }); - // e.stopPropagation(); - + document.body.focus(); // so that we can access the clipboard without an error + setTimeout(() => + pasteImageBitmap((data: any, error: any) => { + error && console.log(error); + data && VideoBox.convertDataUri(data, this.props.Document[Id] + "-thumb-frozen").then(returnedfilename => { + this.props.Document["thumb-frozen"] = new ImageField(returnedfilename); + }); + })); + } else if (e.key === "s" && e.ctrlKey) { e.preventDefault(); const slide = Doc.copyDragFactory(Doc.UserDoc().emptySlide as Doc)!; slide.x = x; -- cgit v1.2.3-70-g09d2 From 99ce76f0f21b48d8186e6aba1a0e64c87b2c0649 Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 14 Feb 2022 13:44:47 -0500 Subject: added an incremental load for freeform collections. fixed updating of web page thumbs on deselection after the first thumb is generated. --- .../collectionFreeForm/CollectionFreeFormView.tsx | 8 +++++++- src/client/views/nodes/DocumentView.tsx | 4 ++-- src/client/views/nodes/WebBox.tsx | 18 +++++++++++------- src/fields/util.ts | 2 +- src/server/ApiManagers/UploadManager.ts | 2 +- 5 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src/client/views/collections/collectionFreeForm') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index aeda71d01..2df053c50 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -1300,6 +1300,7 @@ export class CollectionFreeFormView extends CollectionSubView { + this.numLoaded < this.views.length && setTimeout(action(() => this.numLoaded += 10), 500); const children = typeof this.props.children === "function" ? (this.props.children as any)() as JSX.Element[] : []; - return [...children, ...this.views, ]; + return [ + ...children, + ...this.views.slice(0, Math.min(this.views.length, this.numLoaded + 10)), + + ]; } chooseGridSpace = (gridSpace: number): number => { diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 19b16f071..b537cd370 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -840,7 +840,7 @@ export class DocumentViewInternal extends DocComponent {(this.isContentActive() && !SnappingManager.GetIsDragging()) || !thumb ? (null) : - this._iframe = r)} src={"https://crossorigin.me/https://cs.brown.edu"} />; } + setTimeout(action(() => this._webPageHasBeenRendered = true)); return view; } @@ -703,9 +708,8 @@ export class WebBox extends ViewBoxAnnotatableComponent; return (
-