From 4cb09446498b208005235a3509c648aebb413a76 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Wed, 20 May 2020 14:26:16 -0400 Subject: made annotations history for WebBox --- src/client/views/nodes/WebBox.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/client/views/nodes') diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx index 1d242d958..12166147d 100644 --- a/src/client/views/nodes/WebBox.tsx +++ b/src/client/views/nodes/WebBox.tsx @@ -2,7 +2,7 @@ import { library } from "@fortawesome/fontawesome-svg-core"; import { faStickyNote, faPen, faMousePointer } from '@fortawesome/free-solid-svg-icons'; import { action, computed, observable, trace, IReactionDisposer, reaction, runInAction } from "mobx"; import { observer } from "mobx-react"; -import { Doc, FieldResult } from "../../../fields/Doc"; +import { Doc, FieldResult, DocListCast } from "../../../fields/Doc"; import { documentSchema } from "../../../fields/documentSchemas"; import { HtmlField } from "../../../fields/HtmlField"; import { InkTool } from "../../../fields/InkField"; @@ -145,6 +145,7 @@ export class WebBox extends ViewBoxAnnotatableComponent(DocListCast(this.dataDoc[this.annotationKey + "-" + this.urlHash(this._url)])); } } @@ -156,9 +157,13 @@ export class WebBox extends ViewBoxAnnotatableComponent([this._url]); else future.push(this._url); this.dataDoc[this.fieldKey] = new WebField(new URL(this._url = history.pop()!)); + this.dataDoc[this.annotationKey] = new List(DocListCast(this.dataDoc[this.annotationKey + "-" + this.urlHash(this._url)])); } } + urlHash(s: string) { + return s.split('').reduce((a: any, b: any) => { a = ((a << 5) - a) + b.charCodeAt(0); return a & a }, 0); + } @action submitURL = () => { if (!this._url.startsWith("http")) this._url = "http://" + this._url; @@ -166,16 +171,20 @@ export class WebBox extends ViewBoxAnnotatableComponent([url]); + } else { history.push(url); } future && (future.length = 0); + this.dataDoc[this.annotationKey + "-" + this.urlHash(url)] = new List(annos); } this.dataDoc[this.fieldKey] = new WebField(URLy); + this.dataDoc[this.annotationKey] = new List([]); } catch (e) { console.log("Error in URL :" + this._url); } -- cgit v1.2.3-70-g09d2