From d8fa6bd455bcb0c4b42fa5409a8e6340927aaaff Mon Sep 17 00:00:00 2001 From: Lauren Choi Date: Mon, 1 Nov 2021 00:04:13 -0400 Subject: implement auto-move anchor and fix changing follow behavior --- src/client/views/PropertiesView.tsx | 49 +++++++++++-------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index b9a6a5518..301936219 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -1,5 +1,6 @@ import React = require("react"); import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faAnchor } from '@fortawesome/free-solid-svg-icons' import { Checkbox, Tooltip } from "@material-ui/core"; import { intersection } from "lodash"; import { action, autorun, computed, Lambda, observable } from "mobx"; @@ -12,7 +13,7 @@ import { List } from "../../fields/List"; import { ComputedField } from "../../fields/ScriptField"; import { BoolCast, Cast, NumCast, StrCast } from "../../fields/Types"; import { denormalizeEmail, GetEffectiveAcl, SharingPermissions } from "../../fields/util"; -import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue } from "../../Utils"; +import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, setupMoveUpEvents } from "../../Utils"; import { DocumentType } from "../documents/DocumentTypes"; import { CurrentUserUtils } from "../util/CurrentUserUtils"; import { DocumentManager } from "../util/DocumentManager"; @@ -1076,15 +1077,6 @@ export class PropertiesView extends React.Component { ; } - toggleAnchor = () => { - this.selectedDoc.anchor = !this.selectedDoc.anchor - } - - toggleArrow = () => { - this.selectedDoc.arrow = !this.selectedDoc.arrow - } - - @observable description = Field.toString(LinkManager.currentLink?.description as any as Field); @@ -1102,23 +1094,11 @@ export class PropertiesView extends React.Component { @undoBatch changeFollowBehavior = action((follow: string) => { if (LinkManager.currentLink) { - Doc.GetProto(LinkManager.currentLink).followLinkLocation = follow; + this.selectedDoc.followLinkLocation = follow; return true; } }); - getCurrLink = () => { - if (LinkManager.currentLink) { - return Doc.GetProto(LinkManager.currentLink); - } - } - - getCurrentFollow = () => { - if (LinkManager.currentLink) { - return StrCast(Doc.GetProto(LinkManager.currentLink).followLinkLocation); - } - } - onSelectOut = () => { this.setDescripValue(this.description); document.getElementById('input')?.blur(); @@ -1131,6 +1111,10 @@ export class PropertiesView extends React.Component { } } + toggleAnchor = (e: React.PointerEvent) => { + setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => this.selectedDoc.linkAutoMove = !this.selectedDoc.linkAutoMove))); + } + @computed get editDescription() { return { name="selectList" id="selectList" onChange={e => this.changeFollowBehavior(e.currentTarget.value)} - value={this.getCurrentFollow()}> + value={StrCast(this.selectedDoc.followLinkLocation, "default")}> @@ -1203,7 +1187,7 @@ export class PropertiesView extends React.Component { - {this.getCurrLink()?.linksToAnnotation + {this.selectedDoc.linksToAnnotation ? : null} @@ -1211,16 +1195,11 @@ export class PropertiesView extends React.Component {

Auto-move anchor

-
-

Auto-move arrow

-
; -- cgit v1.2.3-70-g09d2