diff options
| author | Bob Zeleznik <zzzman@gmail.com> | 2020-06-28 17:48:50 -0400 | 
|---|---|---|
| committer | Bob Zeleznik <zzzman@gmail.com> | 2020-06-28 17:48:50 -0400 | 
| commit | e3305050a7d35474e9981838b24d54cf1e77f193 (patch) | |
| tree | 9c03854b8443b00cedc7afb5b39939527d1c0ddb /src/client/views/DocumentButtonBar.tsx | |
| parent | 7a291cbffb9e609633759cfff8b459e1a32b4fc3 (diff) | |
| parent | eb403262aa4c1dd12dba8029fec70552cbce70bc (diff) | |
Merge branch 'master' into search_doc
Diffstat (limited to 'src/client/views/DocumentButtonBar.tsx')
| -rw-r--r-- | src/client/views/DocumentButtonBar.tsx | 63 | 
1 files changed, 8 insertions, 55 deletions
| diff --git a/src/client/views/DocumentButtonBar.tsx b/src/client/views/DocumentButtonBar.tsx index 62a95116f..c05ca33fb 100644 --- a/src/client/views/DocumentButtonBar.tsx +++ b/src/client/views/DocumentButtonBar.tsx @@ -1,28 +1,28 @@  import { IconProp, library } from '@fortawesome/fontawesome-svg-core'; -import { faArrowAltCircleDown, faPhotoVideo, faArrowAltCircleUp, faArrowAltCircleRight, faCheckCircle, faCloudUploadAlt, faLink, faShare, faStopCircle, faSyncAlt, faTag, faTimes } from '@fortawesome/free-solid-svg-icons'; +import { faArrowAltCircleDown, faArrowAltCircleRight, faArrowAltCircleUp, faCheckCircle, faCloudUploadAlt, faLink, faPhotoVideo, faShare, faStopCircle, faSyncAlt, faTag, faTimes } from '@fortawesome/free-solid-svg-icons';  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";  import { action, computed, observable, runInAction } from "mobx";  import { observer } from "mobx-react";  import { Doc, DocListCast } from "../../fields/Doc";  import { RichTextField } from '../../fields/RichTextField'; -import { NumCast, StrCast, Cast } from "../../fields/Types"; +import { Cast, NumCast } from "../../fields/Types";  import { emptyFunction, setupMoveUpEvents } from "../../Utils"; +import GoogleAuthenticationManager from '../apis/GoogleAuthenticationManager';  import { Pulls, Pushes } from '../apis/google_docs/GoogleApiClientUtils'; +import { Docs, DocUtils } from '../documents/Documents'; +import { DragManager } from '../util/DragManager';  import { UndoManager } from "../util/UndoManager";  import { CollectionDockingView, DockedFrameRenderer } from './collections/CollectionDockingView';  import { ParentDocSelector } from './collections/ParentDocumentSelector';  import './collections/ParentDocumentSelector.scss';  import './DocumentButtonBar.scss'; -import { LinkMenu } from "./linking/LinkMenu"; +import { MetadataEntryMenu } from './MetadataEntryMenu';  import { DocumentView } from './nodes/DocumentView';  import { GoogleRef } from "./nodes/formattedText/FormattedTextBox";  import { TemplateMenu } from "./TemplateMenu";  import { Template, Templates } from "./Templates";  import React = require("react"); -import { DragManager } from '../util/DragManager'; -import { MetadataEntryMenu } from './MetadataEntryMenu'; -import GoogleAuthenticationManager from '../apis/GoogleAuthenticationManager'; -import { Docs } from '../documents/Documents'; +import { DocumentLinksButton } from './nodes/DocumentLinksButton';  const higflyout = require("@hig/flyout");  export const { anchorPoints } = higflyout;  export const Flyout = higflyout.default; @@ -113,39 +113,6 @@ export class DocumentButtonBar extends React.Component<{ views: () => (DocumentV      get view0() { return this.props.views()?.[0]; } -    @action -    onLinkButtonMoved = (e: PointerEvent) => { -        if (this._linkButton.current !== null) { -            const linkDrag = UndoManager.StartBatch("Drag Link"); -            this.view0 && DragManager.StartLinkDrag(this._linkButton.current, this.view0.props.Document, e.pageX, e.pageY, { -                dragComplete: dropEv => { -                    const linkDoc = dropEv.linkDragData?.linkDocument as Doc; // equivalent to !dropEve.aborted since linkDocument is only assigned on a completed drop -                    if (this.view0 && linkDoc) { -                        !linkDoc.linkRelationship && (Doc.GetProto(linkDoc).linkRelationship = "hyperlink"); - -                        // we want to allow specific views to handle the link creation in their own way (e.g., rich text makes text hyperlinks) -                        // the dragged view can regiser a linkDropCallback to be notified that the link was made and to update their data structures -                        // however, the dropped document isn't so accessible.  What we do is set the newly created link document on the documentView -                        // The documentView passes a function prop returning this link doc to its descendants who can react to changes to it. -                        dropEv.linkDragData?.linkDropCallback?.(dropEv.linkDragData); -                        runInAction(() => this.view0!._link = linkDoc); -                        setTimeout(action(() => this.view0!._link = undefined), 0); -                    } -                    linkDrag?.end(); -                }, -                hideSource: false -            }); -            return true; -        } -        return false; -    } - - -    onLinkButtonDown = (e: React.PointerEvent): void => { -        setupMoveUpEvents(this, e, this.onLinkButtonMoved, emptyFunction, emptyFunction); -    } - -      @computed      get considerGoogleDocsPush() {          const targetDoc = this.view0?.props.Document; @@ -236,20 +203,6 @@ export class DocumentButtonBar extends React.Component<{ views: () => (DocumentV      }      @computed -    get linkButton() { -        const view0 = this.view0; -        const linkCount = view0 && DocListCast(view0.props.Document.links).length; -        return !view0 ? (null) : <div title="Drag(create link) Tap(view links)" className="documentButtonBar-linkFlyout" ref={this._linkButton}> -            <Flyout anchorPoint={anchorPoints.LEFT_TOP} -                content={<LinkMenu docView={view0} addDocTab={view0.props.addDocTab} changeFlyout={emptyFunction} />}> -                <div className={"documentButtonBar-linkButton-" + (linkCount ? "nonempty" : "empty")} onPointerDown={this.onLinkButtonDown} > -                    {linkCount ? linkCount : <FontAwesomeIcon className="documentdecorations-icon" icon="link" size="sm" />} -                </div> -            </Flyout> -        </div>; -    } - -    @computed      get metadataButton() {          const view0 = this.view0;          return !view0 ? (null) : <div title="Show metadata panel" className="documentButtonBar-linkFlyout"> @@ -318,7 +271,7 @@ export class DocumentButtonBar extends React.Component<{ views: () => (DocumentV          const considerPush = isText && this.considerGoogleDocsPush;          return <div className="documentButtonBar">              <div className="documentButtonBar-button"> -                {this.linkButton} +                <DocumentLinksButton View={this.view0} AlwaysOn={true} />              </div>              <div className="documentButtonBar-button">                  {this.templateButton} | 
