diff options
author | bobzel <zzzman@gmail.com> | 2020-08-31 23:18:09 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2020-08-31 23:18:09 -0400 |
commit | fe4a45d0f63683c0f917b6e923e6d48b006e2701 (patch) | |
tree | 62e0454f537280d9f96fd2cd7d40b72eb05ee47c /src | |
parent | 284ee4620e941fcf986c97f6b330df19ad901e1f (diff) |
fixed addDocTab to not re-create the golden layout. fixed clicking tabs to register as an undo event. fixed color of links made in PDFs to be lightBlue. fixed default link behavior to be 'default'
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/CollectionDockingView.tsx | 3 | ||||
-rw-r--r-- | src/client/views/collections/TabDocView.tsx | 15 | ||||
-rw-r--r-- | src/client/views/linking/LinkEditor.tsx | 4 | ||||
-rw-r--r-- | src/client/views/linking/LinkMenuItem.tsx | 2 | ||||
-rw-r--r-- | src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx | 2 | ||||
-rw-r--r-- | src/client/views/pdf/Annotation.tsx | 14 | ||||
-rw-r--r-- | src/client/views/pdf/PDFViewer.tsx | 4 |
7 files changed, 19 insertions, 25 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 5f05b1193..d39ef5e80 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -197,6 +197,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) { newContentItem.config.width = 50; } } + instance._ignoreStateChange = JSON.stringify(instance._goldenLayout.toConfig()); newContentItem.callDownwards('_$init'); } @@ -255,7 +256,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) { new _global.ResizeObserver(this.onResize).observe(this._containerRef.current); this._reactionDisposer = reaction(() => StrCast(this.props.Document.dockingConfig), config => { - if (!this._goldenLayout || this._ignoreStateChange !== config) { + if (!this._goldenLayout || this._ignoreStateChange !== config) { // bcz: TODO! really need to diff config with ignoreStateChange and modify the current goldenLayout instead of building a new one. this.setupGoldenLayout(); } this._ignoreStateChange = ""; diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx index fb3de3b68..31e3fbed6 100644 --- a/src/client/views/collections/TabDocView.tsx +++ b/src/client/views/collections/TabDocView.tsx @@ -18,7 +18,7 @@ import { DragManager, dropActionType } from "../../util/DragManager"; import { SelectionManager } from '../../util/SelectionManager'; import { SnappingManager } from '../../util/SnappingManager'; import { Transform } from '../../util/Transform'; -import { undoBatch } from "../../util/UndoManager"; +import { undoBatch, UndoManager } from "../../util/UndoManager"; import { DocumentView } from "../nodes/DocumentView"; import { PresBox } from '../nodes/PresBox'; import { CollectionDockingView } from './CollectionDockingView'; @@ -55,11 +55,6 @@ export class TabDocView extends React.Component<TabDocViewProps> { tab.DashDoc = doc; CollectionDockingView.Instance.tabMap.add(tab); - tab.titleElement[0].onclick = (e: any) => { - if (Date.now() - tab.titleElement[0].lastClick < 1000) tab.titleElement[0].select(); - tab.titleElement[0].lastClick = Date.now(); - tab.titleElement[0].focus(); - }; tab.titleElement[0].onchange = (e: any) => { tab.titleElement[0].size = e.currentTarget.value.length + 1; Doc.GetProto(doc).title = e.currentTarget.value; @@ -73,9 +68,7 @@ export class TabDocView extends React.Component<TabDocViewProps> { gearSpan.style.paddingLeft = "0px"; gearSpan.style.paddingRight = "12px"; const stack = tab.contentItem.parent; - tab.element[0].onpointerdown = (e: any) => { - e.target.className !== "lm_close_tab" && this.view && SelectionManager.SelectDoc(this.view, false); - }; + tab.element[0].onclick = (e: any) => e.target.className !== "lm_close_tab" && this.view && SelectionManager.SelectDoc(this.view!, false); // shifts the focus to this tab when another tab is dragged over it tab.element[0].onmouseenter = (e: MouseEvent) => { if (SnappingManager.GetIsDragging() && tab.contentItem !== tab.header.parent.getActiveContentItem()) { @@ -92,7 +85,7 @@ export class TabDocView extends React.Component<TabDocViewProps> { tab._disposers.selectionDisposer = reaction(() => SelectionManager.SelectedDocuments().some(v => v.props.Document === doc), (selected) => { - selected && tab.contentItem !== tab.header.parent.getActiveContentItem() && tab.header.parent.setActiveContentItem(tab.contentItem); + selected && tab.contentItem !== tab.header.parent.getActiveContentItem() && UndoManager.RunInBatch(() => tab.header.parent.setActiveContentItem(tab.contentItem), "tab switch"); } ); tab._disposers.buttonDisposer = reaction(() => this.view, @@ -245,7 +238,7 @@ export class TabDocView extends React.Component<TabDocViewProps> { case "replace": return CollectionDockingView.ReplaceTab(doc, locationParams, this.stack); case "inPlace": case "add": - default: return CollectionDockingView.ToggleSplit(doc, locationParams, this.stack); + default: return CollectionDockingView.AddSplit(doc, locationParams, this.stack); } } diff --git a/src/client/views/linking/LinkEditor.tsx b/src/client/views/linking/LinkEditor.tsx index c9c2e657b..d6c3702d1 100644 --- a/src/client/views/linking/LinkEditor.tsx +++ b/src/client/views/linking/LinkEditor.tsx @@ -364,7 +364,7 @@ export class LinkEditor extends React.Component<LinkEditorProps> { <div className="linkEditor-followingDropdown-dropdown"> <div className="linkEditor-followingDropdown-header" onPointerDown={this.changeDropdown}> - {StrCast(this.props.linkDoc.followLinkLocation, "Default")} + {StrCast(this.props.linkDoc.followLinkLocation, "default")} <FontAwesomeIcon className="linkEditor-followingDropdown-icon" icon={this.openDropdown ? "chevron-up" : "chevron-down"} size={"lg"} /> @@ -372,7 +372,7 @@ export class LinkEditor extends React.Component<LinkEditorProps> { <div className="linkEditor-followingDropdown-optionsList" style={{ display: this.openDropdown ? "" : "none" }}> <div className="linkEditor-followingDropdown-option" - onPointerDown={() => this.changeFollowBehavior("Default")}> + onPointerDown={() => this.changeFollowBehavior("default")}> Default </div> <div className="linkEditor-followingDropdown-option" diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx index 05b6b584d..17549e3cf 100644 --- a/src/client/views/linking/LinkMenuItem.tsx +++ b/src/client/views/linking/LinkMenuItem.tsx @@ -157,7 +157,7 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> { return; } - if (linkDoc.followLinkLocation && linkDoc.followLinkLocation !== "Default") { + if (linkDoc.followLinkLocation && linkDoc.followLinkLocation !== "default") { const annotationOn = this.props.destinationDoc.annotationOn as Doc; this.props.addDocTab(annotationOn instanceof Doc ? annotationOn : this.props.destinationDoc, StrCast(linkDoc.followLinkLocation)); if (annotationOn) { diff --git a/src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx b/src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx index f41f03620..ef0222a4c 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx @@ -111,7 +111,7 @@ export class FormattedTextBoxComment { const target = anchor?.annotationOn ? await DocCastAsync(anchor.annotationOn) : anchor; if (FormattedTextBoxComment.linkDoc.follow) { - if (FormattedTextBoxComment.linkDoc.follow === "Default") { + if (FormattedTextBoxComment.linkDoc.follow === "default") { DocumentManager.Instance.FollowLink(FormattedTextBoxComment.linkDoc, textBox.props.Document, doc => textBox.props.addDocTab(doc, "add:right"), false); } else if (FormattedTextBoxComment.linkDoc.follow === "Always open in right tab") { if (target) { textBox.props.addDocTab(target, "add:right"); } diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx index a33068a18..222a6cb0f 100644 --- a/src/client/views/pdf/Annotation.tsx +++ b/src/client/views/pdf/Annotation.tsx @@ -4,7 +4,7 @@ import { observer } from "mobx-react"; import { Doc, DocListCast, HeightSym, WidthSym } from "../../../fields/Doc"; import { Id } from "../../../fields/FieldSymbols"; import { List } from "../../../fields/List"; -import { Cast, FieldValue, NumCast, StrCast } from "../../../fields/Types"; +import { Cast, FieldValue, NumCast, StrCast, PromiseValue } from "../../../fields/Types"; import { DocumentManager } from "../../util/DocumentManager"; import { PDFMenu } from "./PDFMenu"; import "./Annotation.scss"; @@ -86,7 +86,7 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> { } @action - onPointerDown = async (e: React.PointerEvent) => { + onPointerDown = (e: React.PointerEvent) => { if (e.button === 2 || e.ctrlKey) { PDFMenu.Instance.Status = "annotation"; PDFMenu.Instance.Delete = this.deleteAnnotation.bind(this); @@ -97,11 +97,11 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> { e.stopPropagation(); } else if (e.button === 0) { - const annoGroup = await Cast(this.props.document.group, Doc); - if (annoGroup) { - DocumentManager.Instance.FollowLink(undefined, annoGroup, (doc, followLinkLocation) => this.props.addDocTab(doc, e.ctrlKey ? "add" : followLinkLocation), false, undefined); - e.stopPropagation(); - } + e.persist(); + e.stopPropagation(); + PromiseValue(this.props.document.group).then(annoGroup => annoGroup instanceof Doc && + DocumentManager.Instance.FollowLink(undefined, annoGroup, (doc, followLinkLocation) => this.props.addDocTab(doc, e.ctrlKey ? "add" : followLinkLocation), false, undefined) + ); } } diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index d89e66ec5..8edb0e178 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -597,14 +597,14 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu // Doc.GetProto(targetDoc).snipped = this.dataDoc[this.props.fieldKey][Copy](); // const snipLayout = Docs.Create.PdfDocument("http://www.msn.com", { title: "snippetView", isTemplateDoc: true, isTemplateForField: "snipped", _fitWidth: true, _width: this.marqueeWidth(), _height: this.marqueeHeight(), _scrollTop: this.marqueeY() }); // Doc.GetProto(snipLayout).layout = PDFBox.LayoutString("snipped"); - const annotationDoc = this.highlight("rgba(146, 245, 95, 0.467)"); // yellowish highlight color when dragging out a text selection + const annotationDoc = this.highlight("lightBlue"); if (annotationDoc) { DragManager.StartPdfAnnoDrag([ele], new DragManager.PdfAnnoDragData(this.props.Document, annotationDoc, targetDoc), e.pageX, e.pageY, { dragComplete: e => { if (!e.aborted && e.annoDragData && !e.annoDragData.linkedToDoc) { const link = DocUtils.MakeLink({ doc: annotationDoc }, { doc: e.annoDragData.dropDocument }, "Annotation"); annotationDoc.isLinkButton = true; - if (link) link.followLinkLocation = "add:right"; + if (link) Doc.GetProto(link).followLinkLocation = "default"; } } }); |