aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/PropertiesView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-02-07 22:43:00 -0500
committerbobzel <zzzman@gmail.com>2024-02-07 22:43:00 -0500
commit536cd22988407ab86099595daa4ffe4f054b2914 (patch)
treea4613ab9f78ba017904b2eeb832b6935083fe6d7 /src/client/views/PropertiesView.tsx
parent5fa690804ebd0b915488530882564a241315ad09 (diff)
fixed icon placement in linkMenuItem.
Diffstat (limited to 'src/client/views/PropertiesView.tsx')
-rw-r--r--src/client/views/PropertiesView.tsx49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 3ae2362a1..e4e7bec32 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -41,6 +41,7 @@ import { DocumentView, OpenWhere } from './nodes/DocumentView';
import { StyleProviderFuncType } from './nodes/FieldView';
import { KeyValueBox } from './nodes/KeyValueBox';
import { PresBox, PresEffect, PresEffectDirection } from './nodes/trails';
+import { LinkBox } from './nodes/LinkBox';
const _global = (window /* browser */ || global) /* node */ as any;
interface PropertiesViewProps {
@@ -69,6 +70,10 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
return SelectionManager.SelectedSchemaDoc || this.selectedDocumentView?.Document || Doc.ActiveDashboard;
}
+ @computed get selectedLink() {
+ return this.selectedDocumentView?.ComponentView instanceof LinkBox ? this.selectedDocumentView.Document : LinkManager.Instance.currentLink;
+ }
+
@computed get selectedLayoutDoc() {
return SelectionManager.SelectedSchemaDoc || this.selectedDocumentView?.layoutDoc || Doc.ActiveDashboard;
}
@@ -110,7 +115,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
componentDidMount() {
this._disposers.link = reaction(
- () => LinkManager.Instance.currentLink,
+ () => this.selectedLink,
link => {
link && this.CloseAll();
link && (this.openLinks = true);
@@ -583,11 +588,11 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
</>
</p>
) : null}
- {LinkManager.Instance.currentLink?.title ? (
+ {this.selectedLink?.title ? (
<p className="propertiesView-titleExtender">
<>
<b>Link:</b>
- {LinkManager.Instance.currentLink.title}
+ {this.selectedLink.title}
</>
</p>
) : null}
@@ -1190,10 +1195,10 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
}
@computed get description() {
- return Field.toString(LinkManager.Instance.currentLink?.link_description as any as Field);
+ return Field.toString(this.selectedLink?.link_description as any as Field);
}
@computed get relationship() {
- return StrCast(LinkManager.Instance.currentLink?.link_relationship);
+ return StrCast(this.selectedLink?.link_relationship);
}
@observable private relationshipButtonColor: string = '';
@@ -1203,7 +1208,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
handleDescriptionChange = undoable(
action((value: string) => {
- if (LinkManager.Instance.currentLink && this.selectedDoc) {
+ if (this.selectedLink) {
this.setDescripValue(value);
}
}),
@@ -1212,7 +1217,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
handlelinkRelationshipChange = undoable(
action((value: string) => {
- if (LinkManager.Instance.currentLink && this.selectedDoc) {
+ if (this.selectedLink) {
this.setlinkRelationshipValue(value);
}
}),
@@ -1221,17 +1226,17 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
@undoBatch
setDescripValue = action((value: string) => {
- if (LinkManager.Instance.currentLink) {
- Doc.GetProto(LinkManager.Instance.currentLink).link_description = value;
+ if (this.selectedLink) {
+ this.selectedLink[DocData].link_description = value;
}
});
@undoBatch
setlinkRelationshipValue = action((value: string) => {
- if (LinkManager.Instance.currentLink) {
- const prevRelationship = StrCast(LinkManager.Instance.currentLink.link_relationship);
- LinkManager.Instance.currentLink.link_relationship = value;
- Doc.GetProto(LinkManager.Instance.currentLink).link_relationship = value;
+ if (this.selectedLink) {
+ const prevRelationship = StrCast(this.selectedLink.link_relationship);
+ this.selectedLink.link_relationship = value;
+ Doc.GetProto(this.selectedLink).link_relationship = value;
const linkRelationshipList = StrListCast(Doc.UserDoc().link_relationshipList);
const linkRelationshipSizes = NumListCast(Doc.UserDoc().link_relationshipSizes);
const linkColorList = StrListCast(Doc.UserDoc().link_ColorList);
@@ -1315,11 +1320,11 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
};
toggleLinkProp = (e: React.PointerEvent, prop: string) => {
- setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => LinkManager.Instance.currentLink && (LinkManager.Instance.currentLink[prop] = !LinkManager.Instance.currentLink[prop]))));
+ setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => this.selectedLink && (this.selectedLink[prop] = !this.selectedLink[prop]))));
};
@computed get destinationAnchor() {
- const ldoc = LinkManager.Instance.currentLink;
+ const ldoc = this.selectedLink;
const lanch = this.selectedDocumentView?.anchorViewDoc ?? LinkManager.Instance.currentLinkAnchor;
if (ldoc && lanch) return LinkManager.getOppositeAnchor(ldoc, lanch) ?? lanch;
return ldoc ? DocCast(ldoc.link_anchor_2) : ldoc;
@@ -1328,7 +1333,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
@computed get sourceAnchor() {
const selAnchor = this.selectedDocumentView?.anchorViewDoc ?? LinkManager.Instance.currentLinkAnchor;
- return selAnchor ?? (LinkManager.Instance.currentLink && this.destinationAnchor ? LinkManager.getOppositeAnchor(LinkManager.Instance.currentLink, this.destinationAnchor) : LinkManager.Instance.currentLink);
+ return selAnchor ?? (this.selectedLink && this.destinationAnchor ? LinkManager.getOppositeAnchor(this.selectedLink, this.destinationAnchor) : this.selectedLink);
}
toggleAnchorProp = (e: React.PointerEvent, prop: string, anchor?: Doc, value: any = true, ovalue: any = false, cb: (val: any) => any = val => val) => {
@@ -1354,7 +1359,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
style={{ color: SettingsManager.userColor, backgroundColor: SettingsManager.userBackgroundColor }}
autoComplete={'off'}
id="link_relationship_input"
- value={StrCast(LinkManager.Instance.currentLink?.link_relationship)}
+ value={StrCast(this.selectedLink?.link_relationship)}
onKeyDown={this.onRelationshipKey}
onBlur={this.onSelectOutRelationship}
onChange={e => this.handlelinkRelationshipChange(e.currentTarget.value)}
@@ -1371,7 +1376,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
autoComplete="off"
style={{ textAlign: 'left', color: SettingsManager.userColor, backgroundColor: SettingsManager.userBackgroundColor }}
id="link_description_input"
- value={StrCast(LinkManager.Instance.currentLink?.link_description)}
+ value={StrCast(this.selectedLink?.link_description)}
onKeyDown={this.onDescriptionKey}
onBlur={this.onSelectOutDesc}
onChange={e => this.handleDescriptionChange(e.currentTarget.value)}
@@ -1393,7 +1398,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
const zoom = Number((NumCast(this.sourceAnchor?.followLinkZoomScale, 1) * 100).toPrecision(3));
const targZoom = this.sourceAnchor?.followLinkZoom;
const indent = 30;
- const hasSelectedAnchor = LinkManager.Links(this.sourceAnchor).includes(LinkManager.Instance.currentLink!);
+ const hasSelectedAnchor = LinkManager.Links(this.sourceAnchor).includes(this.selectedLink!);
return (
<>
@@ -1424,7 +1429,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
<option value={OpenWhere.add}>Opening in new tab</option>
<option value={OpenWhere.replace}>Replacing current tab</option>
<option value={OpenWhere.inParent}>Opening in same collection</option>
- {LinkManager.Instance.currentLink?.linksToAnnotation ? <option value="openExternal">Open in external page</option> : null}
+ {this.selectedLink?.linksToAnnotation ? <option value="openExternal">Open in external page</option> : null}
</select>
</div>
<div className="propertiesView-input inline first" style={{ display: 'grid', gridTemplateColumns: '84px calc(100% - 134px) 50px' }}>
@@ -1609,7 +1614,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
render() {
const isNovice = Doc.noviceMode;
- const hasSelectedAnchor = LinkManager.Links(this.sourceAnchor).includes(LinkManager.Instance.currentLink!);
+ const hasSelectedAnchor = LinkManager.Links(this.sourceAnchor).includes(this.selectedLink!);
if (!this.selectedDoc && !this.isPres) {
return (
<div className="propertiesView" style={{ width: this._props.width }}>
@@ -1643,7 +1648,7 @@ export class PropertiesView extends ObservableReactComponent<PropertiesViewProps
{this.fieldsSubMenu}
{this.optionsSubMenu}
{this.linksSubMenu}
- {!LinkManager.Instance.currentLink || !this.openLinks ? null : this.linkProperties}
+ {!this.selectedLink || !this.openLinks ? null : this.linkProperties}
{this.inkSubMenu}
{this.contextsSubMenu}
{isNovice ? null : this.sharingSubMenu}