diff options
author | Sam Wilkins <samwilkins333@gmail.com> | 2019-08-06 11:11:37 -0400 |
---|---|---|
committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-08-06 11:11:37 -0400 |
commit | c21e85d7c34488ca891c34ace84b9c773605986a (patch) | |
tree | cc5206b8bca8fa4738d9614aad71a45d12c1ec5f | |
parent | 2978e805156bffad92e8ac23259843a7cf207fb7 (diff) | |
parent | 298d1c9b29d6ce2171fd9ac8274b64583b73f6f5 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into speech-to-text
21 files changed, 68 insertions, 75 deletions
diff --git a/src/.DS_Store b/src/.DS_Store Binary files differindex c544bc837..5b35884bd 100644 --- a/src/.DS_Store +++ b/src/.DS_Store diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 8142b2a1b..a58f38ae3 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -601,9 +601,8 @@ export namespace DocUtils { if (sv && sv.props.ContainingCollectionView && sv.props.ContainingCollectionView.props.Document === target) return; if (target === CurrentUserUtils.UserDocument) return undefined; - let linkDoc: Doc | undefined; + let linkDocProto = new Doc(); UndoManager.RunInBatch(() => { - let linkDocProto = new Doc(); linkDocProto.type = DocumentType.LINK; linkDocProto.targetContext = targetContext; @@ -627,7 +626,7 @@ export namespace DocUtils { computed.compiled && (Doc.GetProto(source).links = new ComputedField(computed)); computed.compiled && (Doc.GetProto(target).links = new ComputedField(computed)); }, "make link"); - return linkDoc; + return linkDocProto; } } diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 86d019e29..7ba13e961 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -1,6 +1,6 @@ import { library } from "@fortawesome/fontawesome-svg-core"; import { faEye } from "@fortawesome/free-regular-svg-icons"; -import { faCompass, faCompressArrowsAlt, faExpandArrowsAlt, faPaintBrush, faTable, faUpload } from "@fortawesome/free-solid-svg-icons"; +import { faCompass, faCompressArrowsAlt, faExpandArrowsAlt, faPaintBrush, faTable, faUpload, faChalkboard, faBraille } from "@fortawesome/free-solid-svg-icons"; import { action, computed, observable } from "mobx"; import { observer } from "mobx-react"; import { Doc, DocListCastAsync, HeightSym, WidthSym } from "../../../../new_fields/Doc"; @@ -38,7 +38,7 @@ import { MarqueeView } from "./MarqueeView"; import React = require("react"); import { DocumentType, Docs } from "../../../documents/Documents"; -library.add(faEye as any, faTable, faPaintBrush, faExpandArrowsAlt, faCompressArrowsAlt, faCompass, faUpload); +library.add(faEye as any, faTable, faPaintBrush, faExpandArrowsAlt, faCompressArrowsAlt, faCompass, faUpload, faBraille, faChalkboard); export const panZoomSchema = createSchema({ panX: "number", @@ -67,7 +67,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) { ComputeContentBounds(boundsList: { x: number, y: number, width: number, height: number }[]) { let bounds = boundsList.reduce((bounds, b) => { var [sptX, sptY] = [b.x, b.y]; - let [bptX, bptY] = [sptX + b.width, sptY + b.height]; + let [bptX, bptY] = [sptX + NumCast(b.width, 1), sptY + NumCast(b.height, 1)]; return { x: Math.min(sptX, bounds.x), y: Math.min(sptY, bounds.y), r: Math.max(bptX, bounds.r), b: Math.max(bptY, bounds.b) @@ -615,7 +615,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) { ele: <CollectionFreeFormDocumentView key={doc[Id]} x={script ? pos.x : undefined} y={script ? pos.y : undefined} width={script ? pos.width : undefined} height={script ? pos.height : undefined} {...this.getChildDocumentViewProps(doc)} />, - bounds: (pos.x !== undefined && pos.y !== undefined && pos.width !== undefined && pos.height !== undefined) ? { x: pos.x, y: pos.y, z: pos.z, width: pos.width, height: pos.height } : undefined + bounds: (pos.x !== undefined && pos.y !== undefined) ? { x: pos.x, y: pos.y, z: pos.z, width: NumCast(pos.width), height: NumCast(pos.height) } : undefined }); } } @@ -685,18 +685,24 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) { icon: !this.fitToBox ? "expand-arrows-alt" : "compress-arrows-alt" }); layoutItems.push({ + description: "reset view", event: () => { + this.props.Document.panX = this.props.Document.panY = 0; + this.props.Document.scale = 1; + }, icon: "compress-arrows-alt" + }); + layoutItems.push({ description: `${this.props.Document.useClusters ? "Uncluster" : "Use Clusters"}`, event: async () => { Docs.Prototypes.get(DocumentType.TEXT).defaultBackgroundColor = "#f1efeb"; // backward compatibility with databases that didn't have a default background color on prototypes Docs.Prototypes.get(DocumentType.COL).defaultBackgroundColor = "white"; this.props.Document.useClusters = !this.props.Document.useClusters; }, - icon: !this.props.Document.useClusters ? "expand-arrows-alt" : "compress-arrows-alt" + icon: !this.props.Document.useClusters ? "braille" : "braille" }); layoutItems.push({ description: `${this.props.Document.clusterOverridesDefaultBackground ? "Use Default Backgrounds" : "Clusters Override Defaults"}`, event: async () => this.props.Document.clusterOverridesDefaultBackground = !this.props.Document.clusterOverridesDefaultBackground, - icon: !this.props.Document.useClusters ? "expand-arrows-alt" : "compress-arrows-alt" + icon: !this.props.Document.useClusters ? "chalkboard" : "chalkboard" }); layoutItems.push({ description: "Arrange contents in grid", diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index e5b0b0b52..547d858ce 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -705,8 +705,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu let templates = Cast(this.layoutDoc.templates, listSpec("string")); if (!showOverlays && templates instanceof List) { templates.map(str => { - if (str.indexOf("{props.Document.title}") !== -1) showTitle = "title"; - if (str.indexOf("fieldKey={\"caption\"}") !== -1) showCaption = "caption"; + if (!showTitle && str.indexOf("{props.Document.title}") !== -1) showTitle = "title"; + if (!showCaption && str.indexOf("fieldKey={\"caption\"}") !== -1) showCaption = "caption"; }); } let showTextTitle = showTitle && StrCast(this.layoutDoc.layout).startsWith("<FormattedTextBox") ? showTitle : undefined; diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx index 6c97add76..9dd0643df 100644 --- a/src/client/views/nodes/FormattedTextBox.tsx +++ b/src/client/views/nodes/FormattedTextBox.tsx @@ -180,14 +180,6 @@ export class FormattedTextBox extends DocComponent<(FieldViewProps & FormattedTe } this._applyingChange = true; const fieldkey = "preview"; - if (Object.keys(this.dataDoc).indexOf(fieldkey) !== -1) { - this.dataDoc[this.props.fieldKey] = new RichTextField(JSON.stringify(state.toJSON())); - this.dataDoc[this.props.fieldKey + "_text"] = state.doc.textBetween(0, state.doc.content.size, "\n\n"); - } - else { - Doc.GetProto(this.dataDoc)[this.props.fieldKey] = new RichTextField(JSON.stringify(state.toJSON())); - Doc.GetProto(this.dataDoc)[this.props.fieldKey + "_text"] = state.doc.textBetween(0, state.doc.content.size, "\n\n"); - } if (this.extensionDoc) this.extensionDoc.text = state.doc.textBetween(0, state.doc.content.size, "\n\n"); if (this.extensionDoc) this.extensionDoc.lastModified = new DateField(new Date(Date.now())); this.dataDoc[this.props.fieldKey] = new RichTextField(JSON.stringify(state.toJSON())); diff --git a/src/client/views/pdf/Annotation.scss b/src/client/views/pdf/Annotation.scss new file mode 100644 index 000000000..0ea85d522 --- /dev/null +++ b/src/client/views/pdf/Annotation.scss @@ -0,0 +1,4 @@ +.pdfViewer-annotationBox { + pointer-events: all; + user-select: none; +}
\ No newline at end of file diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx index 513f9fed6..a08ff5969 100644 --- a/src/client/views/pdf/Annotation.tsx +++ b/src/client/views/pdf/Annotation.tsx @@ -1,16 +1,15 @@ import React = require("react"); -import { Doc, DocListCast, WidthSym, HeightSym } from "../../../new_fields/Doc"; -import { AnnotationTypes, Viewer, scale } from "./PDFViewer"; +import { action, IReactionDisposer, observable, reaction } from "mobx"; import { observer } from "mobx-react"; -import { observable, IReactionDisposer, reaction, action } from "mobx"; -import { BoolCast, NumCast, FieldValue, Cast, StrCast } from "../../../new_fields/Types"; +import { Doc, DocListCast, HeightSym, WidthSym } from "../../../new_fields/Doc"; import { Id } from "../../../new_fields/FieldSymbols"; import { List } from "../../../new_fields/List"; -import PDFMenu from "./PDFMenu"; +import { BoolCast, Cast, FieldValue, NumCast, StrCast } from "../../../new_fields/Types"; import { DocumentManager } from "../../util/DocumentManager"; import { PresentationView } from "../presentationview/PresentationView"; -import { LinkManager } from "../../util/LinkManager"; -import { CollectionDockingView } from "../collections/CollectionDockingView"; +import PDFMenu from "./PDFMenu"; +import "./Annotation.scss"; +import { AnnotationTypes, scale, Viewer } from "./PDFViewer"; interface IAnnotationProps { anno: Doc; @@ -118,8 +117,9 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> { if (targetDoc) { let context = await Cast(targetDoc.targetContext, Doc); if (context) { - DocumentManager.Instance.jumpToDocument(targetDoc, false, undefined, - ((doc) => this.props.parent.props.parent.props.addDocTab(context!, context!.proto, e.ctrlKey ? "onRight" : "inTab"))); + DocumentManager.Instance.jumpToDocument(targetDoc, false, false, + ((doc) => this.props.parent.props.parent.props.addDocTab(targetDoc!, undefined, e.ctrlKey ? "onRight" : "inTab")), + undefined, undefined); } } } @@ -151,7 +151,6 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> { left: this.props.x * scale, width: this.props.width * scale, height: this.props.height * scale, - pointerEvents: "all", backgroundColor: this.props.parent.Index === this.props.index ? "green" : StrCast(this.props.document.color) }}></div> ); diff --git a/src/client/views/pdf/PDFAnnotationLayer.scss b/src/client/views/pdf/PDFAnnotationLayer.scss new file mode 100644 index 000000000..733533007 --- /dev/null +++ b/src/client/views/pdf/PDFAnnotationLayer.scss @@ -0,0 +1,6 @@ +.pdfAnnotationLayer-cont { + width:100%; + height:100%; + position:relative; + top:-200%; +}
\ No newline at end of file diff --git a/src/client/views/pdf/PDFAnnotationLayer.tsx b/src/client/views/pdf/PDFAnnotationLayer.tsx index 1f49e0d2f..4f267a5c0 100644 --- a/src/client/views/pdf/PDFAnnotationLayer.tsx +++ b/src/client/views/pdf/PDFAnnotationLayer.tsx @@ -1,5 +1,6 @@ import React = require("react"); import { observer } from "mobx-react"; +import "./PDFAnnotationLayer.scss"; interface IAnnotationProps { @@ -15,10 +16,6 @@ export class PDFAnnotationLayer extends React.Component { } render() { - return ( - <div className="pdfAnnotationLayer-cont" style={{ width: "100%", height: "100%", position: "relative", top: "-200%" }} onPointerDown={this.onPointerDown}> - - </div> - ); + return <div className="pdfAnnotationLayer-cont" onPointerDown={this.onPointerDown} />; } }
\ No newline at end of file diff --git a/src/client/views/pdf/PDFViewer.scss b/src/client/views/pdf/PDFViewer.scss index 0fde764d0..7158aaffa 100644 --- a/src/client/views/pdf/PDFViewer.scss +++ b/src/client/views/pdf/PDFViewer.scss @@ -27,9 +27,12 @@ // position: absolute; // top: 0; } - +.pdfViewere-viewer { + pointer-events:inherit; +} .pdfViewer-text { - + transform: scale(1.5); + transform-origin: top left; .page { .canvasWrapper { display: none; @@ -120,6 +123,8 @@ .pdfViewer-annotationLayer { position: absolute; top: 0; + width: 100%; + pointer-events: none; } diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 5eb02a6da..6a99cec59 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -296,19 +296,19 @@ export class Viewer extends React.Component<IViewerProps> { } drop = async (e: Event, de: DragManager.DropEvent) => { - if (de.data instanceof DragManager.LinkDragData) { - let sourceDoc = de.data.linkSourceDocument; - let destDoc = this.makeAnnotationDocument(sourceDoc, 1, "red"); - de.data.droppedDocuments.push(destDoc); - let targetAnnotations = DocListCast(this.props.parent.fieldExtensionDoc.annotations); - if (targetAnnotations) { - targetAnnotations.push(destDoc); - } - else { - this.props.parent.fieldExtensionDoc.annotations = new List<Doc>([destDoc]); - } - e.stopPropagation(); - } + // if (de.data instanceof DragManager.LinkDragData) { + // let sourceDoc = de.data.linkSourceDocument; + // let destDoc = this.makeAnnotationDocument(sourceDoc, 1, "red"); + // de.data.droppedDocuments.push(destDoc); + // let targetAnnotations = DocListCast(this.props.parent.fieldExtensionDoc.annotations); + // if (targetAnnotations) { + // targetAnnotations.push(destDoc); + // } + // else { + // this.props.parent.fieldExtensionDoc.annotations = new List<Doc>([destDoc]); + // } + // e.stopPropagation(); + // } } /** * Called by the Page class when it gets rendered, initializes the lists and @@ -652,16 +652,12 @@ export class Viewer extends React.Component<IViewerProps> { render() { let compiled = this._script; return ( - <div ref={this._mainCont} style={{ pointerEvents: "all" }} onPointerDown={this.pointerDown}> + <div className="pdfViewer-viewer" ref={this._mainCont} onPointerDown={this.pointerDown}> <div className="viewer" style={this._searching ? { position: "absolute", top: 0 } : {}}> {this._visibleElements} </div> - <div className="pdfViewer-text" ref={this._viewer} onCopy={() => console.log("gello world")} style={{ transform: "scale(1.5)", transformOrigin: "top left" }} /> - <div className="pdfViewer-annotationLayer" - style={{ - height: this.props.parent.Document.nativeHeight, width: `100%`, - pointerEvents: this.props.parent.props.active() ? "none" : "all" - }}> + <div className="pdfViewer-text" ref={this._viewer} /> + <div className="pdfViewer-annotationLayer" style={{ height: this.props.parent.Document.nativeHeight }}> <div className="pdfViewer-annotationLayer-subCont" ref={this._annotationLayer}> {this._annotations.filter(anno => { if (compiled && compiled.compiled) { @@ -731,20 +727,12 @@ class SimpleLinkService { cachePageRef() { } - get pagesCount() { - return this.pdf ? this.pdf.numPages : 0; - } + get pagesCount() { return this.pdf ? this.pdf.numPages : 0; } - get page() { - return 0; - } + get page() { return 0; } - setPdf(pdf: any) { - this.pdf = pdf; - } + setPdf(pdf: any) { this.pdf = pdf; } - get rotation() { - return 0; - } + get rotation() { return 0; } set rotation(value: any) { } }
\ No newline at end of file diff --git a/src/client/views/pdf/Page.tsx b/src/client/views/pdf/Page.tsx index c5b2a1dda..dea4e0da1 100644 --- a/src/client/views/pdf/Page.tsx +++ b/src/client/views/pdf/Page.tsx @@ -5,7 +5,7 @@ import "pdfjs-dist/web/pdf_viewer.css"; import { Doc, DocListCastAsync, Opt, WidthSym } from "../../../new_fields/Doc"; import { List } from "../../../new_fields/List"; import { listSpec } from "../../../new_fields/Schema"; -import { Cast, NumCast, StrCast } from "../../../new_fields/Types"; +import { Cast, NumCast, StrCast, BoolCast } from "../../../new_fields/Types"; import { Docs, DocUtils } from "../../documents/Documents"; import { DragManager } from "../../util/DragManager"; import { PDFBox } from "../nodes/PDFBox"; @@ -159,6 +159,7 @@ export default class Page extends React.Component<IPageProps> { let targetDoc = Docs.Create.TextDocument({ width: 200, height: 200, title: "New Annotation" }); targetDoc.targetPage = this.props.page; let annotationDoc = this.highlight(undefined, "red"); + Doc.GetProto(annotationDoc).annotationOn = thisDoc; annotationDoc.linkedToDoc = false; // create dragData and star tdrag let dragData = new DragManager.AnnotationDragData(thisDoc, annotationDoc, targetDoc); @@ -166,13 +167,9 @@ export default class Page extends React.Component<IPageProps> { DragManager.StartAnnotationDrag([ele], dragData, e.pageX, e.pageY, { handlers: { dragComplete: async () => { - if (!(await annotationDoc.linkedToDoc)) { + if (!BoolCast(annotationDoc.linkedToDoc)) { let annotations = await DocListCastAsync(annotationDoc.annotations); - if (annotations) { - annotations.forEach(anno => { - anno.target = targetDoc; - }); - } + annotations && annotations.forEach(anno => anno.target = targetDoc); let pdfDoc = await Cast(annotationDoc.pdfDoc, Doc); if (pdfDoc) { DocUtils.MakeLink(annotationDoc, targetDoc, dragData.targetContext, `Annotation from ${StrCast(pdfDoc.title)}`, "", StrCast(pdfDoc.title)); diff --git a/src/scraping/buxton/source/Bill_Notes_3_button_optical_mouse.docx b/src/scraping/buxton/source/Bill_Notes_3_button_optical_mouse.docx Binary files differnew file mode 100644 index 000000000..a2ab04b78 --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_3_button_optical_mouse.docx diff --git a/src/scraping/buxton/source/Bill_Notes_Amazon_Kindle_Keyboard.docx b/src/scraping/buxton/source/Bill_Notes_Amazon_Kindle_Keyboard.docx Binary files differnew file mode 100644 index 000000000..e4375ebeb --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_Amazon_Kindle_Keyboard.docx diff --git a/src/scraping/buxton/source/Bill_Notes_Apple_Adj_Keyboard.docx b/src/scraping/buxton/source/Bill_Notes_Apple_Adj_Keyboard.docx Binary files differnew file mode 100644 index 000000000..99f7ad19d --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_Apple_Adj_Keyboard.docx diff --git a/src/scraping/buxton/source/Bill_Notes_BAT.docx b/src/scraping/buxton/source/Bill_Notes_BAT.docx Binary files differnew file mode 100644 index 000000000..0e3368611 --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_BAT.docx diff --git a/src/scraping/buxton/source/Bill_Notes_Casio_CZ-101.docx b/src/scraping/buxton/source/Bill_Notes_Casio_CZ-101.docx Binary files differnew file mode 100644 index 000000000..c8d3943c0 --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_Casio_CZ-101.docx diff --git a/src/scraping/buxton/source/Bill_Notes_Kindle_3G_lighted_cover.docx b/src/scraping/buxton/source/Bill_Notes_Kindle_3G_lighted_cover.docx Binary files differnew file mode 100644 index 000000000..f00fcb772 --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_Kindle_3G_lighted_cover.docx diff --git a/src/scraping/buxton/source/Bill_Notes_Microwriter.docx b/src/scraping/buxton/source/Bill_Notes_Microwriter.docx Binary files differnew file mode 100644 index 000000000..3ac272e42 --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_Microwriter.docx diff --git a/src/scraping/buxton/source/Bill_Notes_Twiddler.docx b/src/scraping/buxton/source/Bill_Notes_Twiddler.docx Binary files differnew file mode 100644 index 000000000..27b4acc85 --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_Twiddler.docx diff --git a/src/scraping/buxton/source/Bill_Notes_orbiTouch.doc b/src/scraping/buxton/source/Bill_Notes_orbiTouch.doc Binary files differnew file mode 100644 index 000000000..6bd71f20e --- /dev/null +++ b/src/scraping/buxton/source/Bill_Notes_orbiTouch.doc |