From 54bdf1a1549e57d6d28ae977706b601384fdc3c4 Mon Sep 17 00:00:00 2001 From: Lauren Choi Date: Sat, 30 Oct 2021 15:03:59 -0400 Subject: edit link description --- src/client/views/PropertiesView.tsx | 62 +++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx index b5bae6652..69224312a 100644 --- a/src/client/views/PropertiesView.tsx +++ b/src/client/views/PropertiesView.tsx @@ -31,6 +31,7 @@ import { PropertiesButtons } from "./PropertiesButtons"; import { PropertiesDocContextSelector } from "./PropertiesDocContextSelector"; import "./PropertiesView.scss"; import { DefaultStyleProvider } from "./StyleProvider"; +import { LinkManager } from "../util/LinkManager"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; @@ -1084,6 +1085,55 @@ export class PropertiesView extends React.Component { } + @observable + description = Field.toString(LinkManager.currentLink?.description as any as Field); + @observable + follow = Field.toString(LinkManager.currentLink?.follow as any as Field); + + @action + handleDescriptionChange = (e: React.ChangeEvent) => { this.description = e.target.value; } + + @undoBatch + setDescripValue = action((value: string) => { + if (LinkManager.currentLink) { + Doc.GetProto(LinkManager.currentLink).description = value; + return true; + } + }); + + @undoBatch + changeFollowBehavior = action((follow: string) => { + if (LinkManager.currentLink) { + Doc.GetProto(LinkManager.currentLink).followLinkLocation = follow; + return true; + } + }); + + onSelectOut = () => { + this.setDescripValue(this.description); + document.getElementById('input')?.blur(); + } + + onDescriptionKey = (e: React.KeyboardEvent) => { + if (e.key === "Enter") { + this.setDescripValue(this.description); + document.getElementById('input')?.blur(); + } + } + + @computed + get editDescription() { + return + } /** * Handles adding and removing members from the sharing panel @@ -1123,7 +1173,7 @@ export class PropertiesView extends React.Component {

Description

- + {this.editDescription}
@@ -1131,8 +1181,14 @@ export class PropertiesView extends React.Component {

Follow