aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/linking
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-05-14 12:03:40 -0400
committerbobzel <zzzman@gmail.com>2023-05-14 12:03:40 -0400
commit42afc0250de658fc3e924864bfae5afb4edec335 (patch)
treed61bbc43d95cb6e1d6fa5c997102d505adc09af5 /src/client/views/linking
parent0849fbd97c61688d51e5fea6cf8edc47989df5de (diff)
major overhaul of field naming conventions.
Diffstat (limited to 'src/client/views/linking')
-rw-r--r--src/client/views/linking/LinkMenuGroup.tsx21
-rw-r--r--src/client/views/linking/LinkMenuItem.tsx30
-rw-r--r--src/client/views/linking/LinkRelationshipSearch.tsx52
3 files changed, 51 insertions, 52 deletions
diff --git a/src/client/views/linking/LinkMenuGroup.tsx b/src/client/views/linking/LinkMenuGroup.tsx
index d02a1c4eb..b9d56541a 100644
--- a/src/client/views/linking/LinkMenuGroup.tsx
+++ b/src/client/views/linking/LinkMenuGroup.tsx
@@ -24,12 +24,12 @@ export class LinkMenuGroup extends React.Component<LinkMenuGroupProps> {
private _menuRef = React.createRef<HTMLDivElement>();
getBackgroundColor = (): string => {
- const linkRelationshipList = StrListCast(Doc.UserDoc().linkRelationshipList);
+ const link_relationshipList = StrListCast(Doc.UserDoc().link_relationshipList);
const linkColorList = StrListCast(Doc.UserDoc().linkColorList);
let color = 'white';
// if this link's relationship property is not default "link", set its color
- if (linkRelationshipList) {
- const relationshipIndex = linkRelationshipList.indexOf(this.props.groupType);
+ if (link_relationshipList) {
+ const relationshipIndex = link_relationshipList.indexOf(this.props.groupType);
const RGBcolor: string = linkColorList[relationshipIndex];
if (RGBcolor) {
//set opacity to 0.25 by modifiying the rgb string
@@ -47,17 +47,18 @@ export class LinkMenuGroup extends React.Component<LinkMenuGroupProps> {
const sourceDoc =
this.props.docView.anchorViewDoc ??
(this.props.docView.rootDoc.type === DocumentType.LINK //
- ? this.props.docView.props.LayoutTemplateString?.includes('anchor1')
- ? DocCast(linkDoc.anchor1)
- : DocCast(linkDoc.anchor2)
+ ? this.props.docView.props.LayoutTemplateString?.includes('link_anchor_1')
+ ? DocCast(linkDoc.link_anchor_1)
+ : DocCast(linkDoc.link_anchor_2)
: this.props.sourceDoc);
const destDoc = !sourceDoc
? undefined
: this.props.docView.rootDoc.type === DocumentType.LINK
- ? this.props.docView.props.LayoutTemplateString?.includes('anchor1')
- ? DocCast(linkDoc.anchor2)
- : DocCast(linkDoc.anchor1)
- : LinkManager.getOppositeAnchor(linkDoc, sourceDoc) || LinkManager.getOppositeAnchor(linkDoc, Cast(linkDoc.anchor2, Doc, null).annotationOn === sourceDoc ? Cast(linkDoc.anchor2, Doc, null) : Cast(linkDoc.anchor1, Doc, null));
+ ? this.props.docView.props.LayoutTemplateString?.includes('link_anchor_1')
+ ? DocCast(linkDoc.link_anchor_2)
+ : DocCast(linkDoc.link_anchor_1)
+ : LinkManager.getOppositeAnchor(linkDoc, sourceDoc) ||
+ LinkManager.getOppositeAnchor(linkDoc, Cast(linkDoc.link_anchor_2, Doc, null).annotationOn === sourceDoc ? Cast(linkDoc.link_anchor_2, Doc, null) : Cast(linkDoc.link_anchor_1, Doc, null));
return !destDoc || !sourceDoc ? null : (
<LinkMenuItem
key={linkDoc[Id]}
diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx
index 19d6c2ae2..5af05e491 100644
--- a/src/client/views/linking/LinkMenuItem.tsx
+++ b/src/client/views/linking/LinkMenuItem.tsx
@@ -8,15 +8,13 @@ import { Cast, DocCast, StrCast } from '../../../fields/Types';
import { WebField } from '../../../fields/URLField';
import { emptyFunction, returnFalse, setupMoveUpEvents } from '../../../Utils';
import { DocumentType } from '../../documents/DocumentTypes';
-import { DocumentManager } from '../../util/DocumentManager';
import { DragManager } from '../../util/DragManager';
import { LinkFollower } from '../../util/LinkFollower';
import { LinkManager } from '../../util/LinkManager';
import { SelectionManager } from '../../util/SelectionManager';
import { SettingsManager } from '../../util/SettingsManager';
import { undoBatch } from '../../util/UndoManager';
-import { MainView } from '../MainView';
-import { DocumentView, OpenWhere } from '../nodes/DocumentView';
+import { DocumentView, DocumentViewInternal, OpenWhere } from '../nodes/DocumentView';
import { LinkDocPreview } from '../nodes/LinkDocPreview';
import './LinkMenuItem.scss';
import React = require('react');
@@ -32,7 +30,7 @@ interface LinkMenuItemProps {
itemHandler?: (doc: Doc) => void;
}
-// drag links and drop link targets (aliasing them if needed)
+// drag links and drop link targets (embedding them if needed)
export async function StartLinkTargetsDrag(dragEle: HTMLElement, docView: DocumentView, downX: number, downY: number, sourceDoc: Doc, specificLinks?: Doc[]) {
const draggedDocs = (specificLinks ? specificLinks : LinkManager.Links(sourceDoc)).map(link => LinkManager.getOppositeAnchor(link, sourceDoc)).filter(l => l) as Doc[];
@@ -45,7 +43,7 @@ export async function StartLinkTargetsDrag(dragEle: HTMLElement, docView: Docume
const dragData = new DragManager.DocumentDragData(moddrag.length ? moddrag : draggedDocs);
dragData.canEmbed = true;
- dragData.dropAction = 'alias';
+ dragData.dropAction = 'embed';
DragManager.StartDocumentDrag([dragEle], dragData, downX, downY, undefined);
}
@@ -65,9 +63,9 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
@computed get sourceAnchor() {
const ldoc = this.props.linkDoc;
- if (this.props.sourceDoc !== ldoc.anchor1 && this.props.sourceDoc !== ldoc.anchor2) {
- if (Doc.AreProtosEqual(DocCast(DocCast(ldoc.anchor1).annotationOn), this.props.sourceDoc)) return DocCast(ldoc.anchor1);
- if (Doc.AreProtosEqual(DocCast(DocCast(ldoc.anchor2).annotationOn), this.props.sourceDoc)) return DocCast(ldoc.anchor2);
+ if (this.props.sourceDoc !== ldoc.link_anchor_1 && this.props.sourceDoc !== ldoc.link_anchor_2) {
+ if (Doc.AreProtosEqual(DocCast(DocCast(ldoc.link_anchor_1).annotationOn), this.props.sourceDoc)) return DocCast(ldoc.link_anchor_1);
+ if (Doc.AreProtosEqual(DocCast(DocCast(ldoc.link_anchor_2).annotationOn), this.props.sourceDoc)) return DocCast(ldoc.link_anchor_2);
}
return this.props.sourceDoc;
}
@@ -79,7 +77,7 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
this,
e,
e => {
- const dragData = new DragManager.DocumentDragData([this.props.linkDoc], 'alias');
+ const dragData = new DragManager.DocumentDragData([this.props.linkDoc], 'embed');
dragData.removeDropProperties = ['hidden'];
DragManager.StartDocumentDrag([this._editRef.current!], dragData, e.x, e.y);
return true;
@@ -89,7 +87,7 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
const trail = DocCast(this.props.docView.rootDoc.presTrail);
if (trail) {
Doc.ActivePresentation = trail;
- MainView.addDocTabFunc(trail, OpenWhere.replaceRight);
+ DocumentViewInternal.addDocTabFunc(trail, OpenWhere.replaceRight);
} else {
SelectionManager.SelectView(this.props.docView, false);
if ((SettingsManager.propertiesWidth ?? 0) < 100) {
@@ -118,10 +116,10 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
this.props.itemHandler?.(this.props.linkDoc);
} else {
const focusDoc =
- Cast(this.props.linkDoc.anchor1, Doc, null)?.annotationOn === this.props.sourceDoc
- ? Cast(this.props.linkDoc.anchor1, Doc, null)
- : Cast(this.props.linkDoc.anchor2, Doc, null)?.annotationOn === this.props.sourceDoc
- ? Cast(this.props.linkDoc.anchor12, Doc, null)
+ Cast(this.props.linkDoc.link_anchor_1, Doc, null)?.annotationOn === this.props.sourceDoc
+ ? Cast(this.props.linkDoc.link_anchor_1, Doc, null)
+ : Cast(this.props.linkDoc.link_anchor_2, Doc, null)?.annotationOn === this.props.sourceDoc
+ ? Cast(this.props.linkDoc.link_anchor_12, Doc, null)
: undefined;
if (focusDoc) this.props.docView.props.focus(focusDoc, { instant: true });
@@ -149,7 +147,7 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
return (
<div className="linkMenu-item" style={{ background: LinkManager.currentLink === this.props.linkDoc ? 'lightBlue' : undefined }}>
- <div className={'linkMenu-item-content expand-two'}>
+ <div className="linkMenu-item-content expand-two">
<div
ref={this._drag}
className="linkMenu-name" //title="drag to view target. click to customize."
@@ -190,7 +188,7 @@ export class LinkMenuItem extends React.Component<LinkMenuItemProps> {
{this.props.linkDoc.linksToAnnotation && Cast(this.props.destinationDoc.data, WebField)?.url.href === this.props.linkDoc.annotationUri ? 'Annotation in' : ''} {StrCast(title)}
</p>
</div>
- {!this.props.linkDoc.description ? null : <p className="linkMenu-description">{StrCast(this.props.linkDoc.description)}</p>}
+ {!this.props.linkDoc.link_description ? null : <p className="linkMenu-description">{StrCast(this.props.linkDoc.link_description)}</p>}
</div>
<div className="linkMenu-item-buttons">
diff --git a/src/client/views/linking/LinkRelationshipSearch.tsx b/src/client/views/linking/LinkRelationshipSearch.tsx
index 53da880e4..9662b2fea 100644
--- a/src/client/views/linking/LinkRelationshipSearch.tsx
+++ b/src/client/views/linking/LinkRelationshipSearch.tsx
@@ -1,8 +1,8 @@
-import { observer } from "mobx-react";
+import { observer } from 'mobx-react';
import './LinkEditor.scss';
-import React = require("react");
+import React = require('react');
-interface LinkRelationshipSearchProps {
+interface link_relationshipSearchProps {
results: string[] | undefined;
display: string;
//callback fn to set rel + hide dropdown upon setting
@@ -10,48 +10,48 @@ interface LinkRelationshipSearchProps {
toggleSearch: () => void;
}
@observer
-export class LinkRelationshipSearch extends React.Component<LinkRelationshipSearchProps> {
-
+export class link_relationshipSearch extends React.Component<link_relationshipSearchProps> {
handleResultClick = (e: React.MouseEvent) => {
const relationship = (e.target as HTMLParagraphElement).textContent;
if (relationship) {
this.props.handleRelationshipSearchChange(relationship);
}
- }
+ };
handleMouseEnter = () => {
this.props.toggleSearch();
- }
+ };
handleMouseLeave = () => {
this.props.toggleSearch();
- }
+ };
/**
- * Render an empty div to increase the height of LinkEditor to accommodate 2+ results
- */
+ * Render an empty div to increase the height of LinkEditor to accommodate 2+ results
+ */
emptyDiv = () => {
- if (this.props.results && this.props.results.length > 2 && this.props.display === "block") {
- return <div style={{ height: "50px" }} />;
+ if (this.props.results && this.props.results.length > 2 && this.props.display === 'block') {
+ return <div style={{ height: '50px' }} />;
}
- }
+ };
render() {
return (
<div className="linkEditor-relationship-dropdown-container">
- <div className="linkEditor-relationship-dropdown"
- style={{ display: this.props.display }}
- onMouseEnter={this.handleMouseEnter}
- onMouseLeave={this.handleMouseLeave}
- >
- { // return a dropdown of relationship results if there exist results
- this.props.results
- ? this.props.results.map(result => {
- return <p key={result} onClick={this.handleResultClick}>
- {result}
- </p>;
+ <div className="linkEditor-relationship-dropdown" style={{ display: this.props.display }} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
+ {
+ // return a dropdown of relationship results if there exist results
+ this.props.results ? (
+ this.props.results.map(result => {
+ return (
+ <p key={result} onClick={this.handleResultClick}>
+ {result}
+ </p>
+ );
})
- : <p>No matching relationships</p>
+ ) : (
+ <p>No matching relationships</p>
+ )
}
</div>
@@ -60,4 +60,4 @@ export class LinkRelationshipSearch extends React.Component<LinkRelationshipSear
</div>
);
}
-} \ No newline at end of file
+}