aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authorGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2020-08-09 13:17:14 +0800
committerGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2020-08-09 13:17:14 +0800
commitd5d4d642189886d646324cc74483c91983458585 (patch)
tree975dd2c16137bb2167172883745f99d9e582fe07 /src/client/views/collections
parentca8566598d2ae9c85b1ea9418fced7261a7f11e2 (diff)
parent9f4a7ec5f79d9dec3a0ffb0b633197216cbefec8 (diff)
Merge branch 'master' into presentation_updates
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionLinearView.tsx2
-rw-r--r--src/client/views/collections/CollectionSubView.tsx32
-rw-r--r--src/client/views/collections/CollectionView.tsx2
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeView.tsx2
-rw-r--r--src/client/views/collections/collectionFreeForm/PropertiesView.scss66
-rw-r--r--src/client/views/collections/collectionFreeForm/PropertiesView.tsx83
6 files changed, 106 insertions, 81 deletions
diff --git a/src/client/views/collections/CollectionLinearView.tsx b/src/client/views/collections/CollectionLinearView.tsx
index a9e812ad3..3cf46dbed 100644
--- a/src/client/views/collections/CollectionLinearView.tsx
+++ b/src/client/views/collections/CollectionLinearView.tsx
@@ -176,7 +176,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
}}
onPointerDown={e => e.stopPropagation()} >
<span className="bottomPopup-text" >
- Creating link from: {DocumentLinksButton.StartLink.props.Document.title}
+ Creating link from: {DocumentLinksButton.AnnotationId ? "Annotation in " : " "} {StrCast(DocumentLinksButton.StartLink.title).length < 51 ? DocumentLinksButton.StartLink.title : StrCast(DocumentLinksButton.StartLink.title).slice(0, 50) + '...'}
</span>
<Tooltip title={<><div className="dash-tooltip">{LinkDescriptionPopup.showDescriptions ? "Turn off description pop-up" :
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 0e40cd21c..72aece284 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -402,14 +402,28 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
// }
}
if (uriList) {
- this.addDocument(Docs.Create.WebDocument(uriList, {
- ...options,
- title: uriList,
- _width: 400,
- _height: 315,
- _nativeWidth: 850,
- _nativeHeight: 962
- }));
+ const existingWebDoc = await Hypothesis.findWebDoc(uriList);
+ if (existingWebDoc) {
+ const alias = Doc.MakeAlias(existingWebDoc);
+ alias.x = options.x;
+ alias.y = options.y;
+ alias._nativeWidth = 850;
+ alias._nativeHeight = 962;
+ alias._width = 400;
+ this.addDocument(alias);
+ } else {
+ const newDoc = Docs.Create.WebDocument(uriList, {
+ ...options,
+ title: uriList.split("#annotations:")[0],
+ _width: 400,
+ _height: 315,
+ _nativeWidth: 850,
+ _nativeHeight: 962,
+ UseCors: true
+ });
+ newDoc.data = new WebField(uriList.split("#annotations:")[0]); // clean hypothes.is URLs that reference a specific annotation (eg. https://en.wikipedia.org/wiki/Cartoon#annotations:t7qAeNbCEeqfG5972KR2Ig)
+ this.addDocument(newDoc);
+ }
return;
}
@@ -492,3 +506,5 @@ import { CollectionView, CollectionViewType } from "./CollectionView";
import { SelectionManager } from "../../util/SelectionManager";
import { OverlayView } from "../OverlayView";
import { setTimeout } from "timers";
+import { Hypothesis } from "../../util/HypothesisUtils";
+
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 4d1cb670c..837ae7e86 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -594,7 +594,7 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
""))}
{(Doc.UserDoc()?.noviceMode || !this.props.isSelected() && !this.props.Document.forceActive) || this.props.Document.hideFilterView ? (null) :
<div className="collectionView-filterDragger" title="library View Dragger" onPointerDown={this.onPointerDown}
- style={{ right: this.facetWidth() - 1, top: this.props.Document._viewType === CollectionViewType.Docking ? "25%" : "55%" }} />
+ style={{ right: this.facetWidth() - 1, top: this.props.Document._viewType === CollectionViewType.Docking ? "25%" : "60%" }} />
}
{Doc.UserDoc()?.noviceMode || this.facetWidth() < 10 ? (null) : this.filterView}
</div>);
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 88fe03efd..858f33291 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -74,7 +74,7 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
if (e.key === "?") {
ContextMenu.Instance.setDefaultItem("?", (str: string) => {
const textDoc = Docs.Create.WebDocument(`https://bing.com/search?q=${str}`, {
- _width: 200, x, y, _nativeHeight: 962, _nativeWidth: 800, isAnnotating: false,
+ _width: 200, x, y, _nativeHeight: 962, _nativeWidth: 850, isAnnotating: false,
title: "bing", UseCors: true
});
this.props.addDocTab(textDoc, "onRight");
diff --git a/src/client/views/collections/collectionFreeForm/PropertiesView.scss b/src/client/views/collections/collectionFreeForm/PropertiesView.scss
index 5e0c9fcbb..aee28366a 100644
--- a/src/client/views/collections/collectionFreeForm/PropertiesView.scss
+++ b/src/client/views/collections/collectionFreeForm/PropertiesView.scss
@@ -23,8 +23,9 @@
height: 20px;
padding-left: 38px;
margin-top: -5px;
- right: 19;
- position: absolute;
+ align-items: flex-end;
+ margin-left: auto;
+ margin-right: 10px;
&:hover {
color: grey;
@@ -66,9 +67,9 @@
.propertiesView-settings-title-icon {
float: right;
- right: 0;
- position: absolute;
- margin-left: 2px;
+ justify-items: right;
+ align-items: flex-end;
+ margin-left: auto;
margin-right: 9px;
&:hover {
@@ -104,9 +105,9 @@
.propertiesView-sharing-title-icon {
float: right;
- right: 0;
- position: absolute;
- margin-left: 2px;
+ justify-items: right;
+ align-items: flex-end;
+ margin-left: auto;
margin-right: 9px;
&:hover {
@@ -154,9 +155,9 @@
.propertiesView-appearance-title-icon {
float: right;
- right: 0;
- position: absolute;
- margin-left: 2px;
+ justify-items: right;
+ align-items: flex-end;
+ margin-left: auto;
margin-right: 9px;
&:hover {
@@ -191,9 +192,9 @@
.propertiesView-transform-title-icon {
float: right;
- right: 0;
- position: absolute;
- margin-left: 2px;
+ justify-items: right;
+ align-items: flex-end;
+ margin-left: auto;
margin-right: 9px;
&:hover {
@@ -285,9 +286,8 @@
.propertiesView-sharingTable-item-permission {
display: flex;
- right: 34;
- float: right;
- position: absolute;
+ align-items: flex-end;
+ margin-left: auto;
.permissions-select {
z-index: 1;
@@ -326,25 +326,18 @@
cursor: pointer;
}
- .propertiesView-fields-title-name {
- font-size: 12.5px;
- font-weight: bold;
- white-space: nowrap;
- width: 35px;
- display: flex;
- }
-
.propertiesView-fields-title-icon {
float: right;
- right: 0;
- position: absolute;
- margin-left: 2px;
+ justify-items: right;
+ align-items: flex-end;
+ margin-left: auto;
margin-right: 9px;
&:hover {
cursor: pointer;
}
}
+
}
.propertiesView-fields-checkbox {
@@ -407,9 +400,9 @@
.propertiesView-layout-title-icon {
float: right;
- right: 0;
- position: absolute;
- margin-left: 2px;
+ justify-items: right;
+ align-items: flex-end;
+ margin-left: auto;
margin-right: 9px;
&:hover {
@@ -444,9 +437,9 @@
.propertiesView-presTrails-title-icon {
float: right;
- right: 0;
- position: absolute;
- margin-left: 2px;
+ justify-items: right;
+ align-items: flex-end;
+ margin-left: auto;
margin-right: 9px;
&:hover {
@@ -730,4 +723,9 @@
&:hover {
border: 0.75px solid rgb(122, 28, 28);
}
+}
+
+
+.properties-flyout {
+ grid-column: 2/4;
} \ No newline at end of file
diff --git a/src/client/views/collections/collectionFreeForm/PropertiesView.tsx b/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
index 1a8ee3ea1..b1c3d3dc5 100644
--- a/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
+++ b/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
@@ -22,13 +22,13 @@ import { InkField } from "../../../../fields/InkField";
import { undoBatch, UndoManager } from "../../../util/UndoManager";
import { ColorState, SketchPicker } from "react-color";
import "./FormatShapePane.scss";
-import { discovery_v1 } from "googleapis";
import { PresBox } from "../../nodes/PresBox";
import { DocumentManager } from "../../../util/DocumentManager";
import FormatShapePane from "./FormatShapePane";
const higflyout = require("@hig/flyout");
export const { anchorPoints } = higflyout;
export const Flyout = higflyout.default;
+const _global = (window /* browser */ || global /* node */) as any;
// import * as fa from '@fortawesome/free-solid-svg-icons';
// import { library } from "@fortawesome/fontawesome-svg-core";
@@ -52,7 +52,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@computed get selectedDocumentView() {
if (SelectionManager.SelectedDocuments().length) {
return SelectionManager.SelectedDocuments()[0];
- } else if (PresBox.Instance._selectedArray.length) {
+ } else if (PresBox.Instance && PresBox.Instance._selectedArray.length) {
return DocumentManager.Instance.getDocumentView(PresBox.Instance.rootDoc);
} else { return undefined; }
}
@@ -247,12 +247,23 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
return false;
}
+ @observable transform: Transform = Transform.Identity();
+ getTransform = () => this.transform;
+ propertiesDocViewRef = (ref: HTMLDivElement) => {
+ const observer = new _global.ResizeObserver(action((entries: any) => {
+ const cliRect = ref.getBoundingClientRect();
+ this.transform = new Transform(-cliRect.x, -cliRect.y, 1);
+ }));
+ ref && observer.observe(ref);
+ }
+
+ previewBackground = () => "lightgrey";
@computed get layoutPreview() {
if (this.selectedDoc) {
const layoutDoc = Doc.Layout(this.selectedDoc);
const panelHeight = StrCast(Doc.LayoutField(layoutDoc)).includes("FormattedTextBox") ? this.rtfHeight : this.docHeight;
const panelWidth = StrCast(Doc.LayoutField(layoutDoc)).includes("FormattedTextBox") ? this.rtfWidth : this.docWidth;
- return <div style={{ display: "inline-block", height: panelHeight() }} key={this.selectedDoc[Id]}>
+ return <div ref={this.propertiesDocViewRef} style={{ pointerEvents: "none", display: "inline-block", height: panelHeight() }} key={this.selectedDoc[Id]}>
<ContentFittingDocumentView
Document={layoutDoc}
DataDoc={this.dataDoc}
@@ -260,7 +271,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
renderDepth={this.props.renderDepth + 1}
rootSelected={returnFalse}
treeViewDoc={undefined}
- backgroundColor={() => "lightgrey"}
+ backgroundColor={this.previewBackground}
fitToBox={true}
FreezeDimensions={true}
NativeWidth={layoutDoc.type ===
@@ -270,7 +281,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
PanelWidth={panelWidth}
PanelHeight={panelHeight}
focus={returnFalse}
- ScreenToLocalTransform={this.props.ScreenToLocalTransform}
+ ScreenToLocalTransform={this.getTransform}
docFilters={returnEmptyFilter}
ContainingCollectionDoc={undefined}
ContainingCollectionView={undefined}
@@ -320,7 +331,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
* @returns the notification icon. On clicking, it should notify someone of a document been shared with them.
*/
@computed get notifyIcon() {
- return <Tooltip title={<><div className="dash-tooltip">Notify with message</div></>}>
+ return <Tooltip title={<div className="dash-tooltip">Notify with message</div>}>
<div className="notify-button">
<FontAwesomeIcon className="notify-button-icon" icon="bell" color="white" size="sm" />
</div>
@@ -331,7 +342,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
* ... next to the owner that opens the main SharingManager interface on click.
*/
@computed get expansionIcon() {
- return <Tooltip title={<><div className="dash-tooltip">{"Show more permissions"}</div></>}>
+ return <Tooltip title={<div className="dash-tooltip">{"Show more permissions"}</div>}>
<div className="expansion-button" onPointerDown={() => {
if (this.selectedDocumentView) {
SharingManager.Instance.open(this.selectedDocumentView);
@@ -346,7 +357,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
* @returns a row of the permissions panel
*/
sharingItem(name: string, effectiveAcl: symbol, permission: string) {
- return <div className="propertiesView-sharingTable-item"
+ return <div className="propertiesView-sharingTable-item" key={name + permission}
// style={{ backgroundColor: this.selectedUser === name ? "#bcecfc" : "" }}
// onPointerDown={action(() => this.selectedUser = this.selectedUser === name ? "" : name)}
>
@@ -378,7 +389,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
if (this.selectedDoc![AclSym]) {
for (const [key, value] of Object.entries(this.selectedDoc![AclSym])) {
const name = key.substring(4).replace("_", ".");
- if (name !== Doc.CurrentUserEmail && name !== this.selectedDoc!.author/* && sidebarUsersDisplayed![name] !== false*/) tableEntries.push(this.sharingItem(name, effectiveAcl, AclMap.get(value)!));
+ if (name !== Doc.CurrentUserEmail && name !== this.selectedDoc!.author/* && sidebarUsersDisplayed![name] !== false*/) {
+ tableEntries.push(this.sharingItem(name, effectiveAcl, AclMap.get(value)!));
+ }
}
}
@@ -484,17 +497,17 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@computed
get controlPointsButton() {
return <div className="inking-button">
- <Tooltip title={<><div className="dash-tooltip">{"Edit points"}</div></>}>
+ <Tooltip title={<div className="dash-tooltip">{"Edit points"}</div>}>
<div className="inking-button-points" onPointerDown={action(() => FormatShapePane.Instance._controlBtn = !FormatShapePane.Instance._controlBtn)} style={{ backgroundColor: FormatShapePane.Instance._controlBtn ? "black" : "" }}>
<FontAwesomeIcon icon="bezier-curve" color="white" size="lg" />
</div>
</Tooltip>
- <Tooltip title={<><div className="dash-tooltip">{FormatShapePane.Instance._lock ? "Unlock ratio" : "Lock ratio"}</div></>}>
+ <Tooltip title={<div className="dash-tooltip">{FormatShapePane.Instance._lock ? "Unlock ratio" : "Lock ratio"}</div>}>
<div className="inking-button-lock" onPointerDown={action(() => FormatShapePane.Instance._lock = !FormatShapePane.Instance._lock)} >
<FontAwesomeIcon icon={FormatShapePane.Instance._lock ? "lock" : "unlock"} color="white" size="lg" />
</div>
</Tooltip>
- <Tooltip title={<><div className="dash-tooltip">{"Rotate 90˚"}</div></>}>
+ <Tooltip title={<div className="dash-tooltip">{"Rotate 90˚"}</div>}>
<div className="inking-button-rotate" onPointerDown={action(() => this.rotate(Math.PI / 2))}>
<FontAwesomeIcon icon="undo" color="white" size="lg" />
</div>
@@ -632,16 +645,19 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
set colorStk(value) { value && (this._lastLine = value); this.selectedDoc && (this.selectedDoc.color = value ? value : undefined); }
colorButton(value: string, type: string, setter: () => {}) {
- return <Flyout anchorPoint={anchorPoints.LEFT_TOP}
- content={type === "fill" ? this.fillPicker : this.linePicker}>
- <div className="color-button" key="color" onPointerDown={undoBatch(action(e => setter()))}>
- <div className="color-button-preview" style={{
- backgroundColor: value ?? "121212", width: 15, height: 15,
- display: value === "" || value === "transparent" ? "none" : ""
- }} />
- {value === "" || value === "transparent" ? <p style={{ fontSize: 25, color: "red", marginTop: -14, position: "fixed" }}>☒</p> : ""}
- </div>
- </Flyout>;
+ // return <div className="properties-flyout" onPointerEnter={e => this.changeScrolling(false)}
+ // onPointerLeave={e => this.changeScrolling(true)}>
+ // <Flyout anchorPoint={anchorPoints.LEFT_TOP}
+ // content={type === "fill" ? this.fillPicker : this.linePicker}>
+ return <div className="color-button" key="color" onPointerDown={undoBatch(action(e => setter()))}>
+ <div className="color-button-preview" style={{
+ backgroundColor: value ?? "121212", width: 15, height: 15,
+ display: value === "" || value === "transparent" ? "none" : ""
+ }} />
+ {value === "" || value === "transparent" ? <p style={{ fontSize: 25, color: "red", marginTop: -14 }}>☒</p> : ""}
+ </div>;
+ // </Flyout>
+ // </div>;
}
@@ -686,8 +702,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
<div className="stroke-button">{this.lineButton}</div>
</div>
</div>
- {/* {this._fillBtn ? this.fillPicker : ""}
- {this._lineBtn ? this.linePicker : ""} */}
+ {this._fillBtn ? this.fillPicker : ""}
+ {this._lineBtn ? this.linePicker : ""}
</div>;
}
@@ -813,7 +829,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
if (this.selectedDoc && !this.isPres) {
return <div className="propertiesView" style={{
width: this.props.width,
- // overflowY: this.inActions ? "visible" : "scroll"
+ //overflowY: this.scrolling ? "scroll" : "visible"
}} >
<div className="propertiesView-title" style={{ width: this.props.width }}>
Properties
@@ -918,11 +934,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
<div className="propertiesView-fields-title"
onPointerDown={() => runInAction(() => { this.openFields = !this.openFields; })}
style={{ backgroundColor: this.openFields ? "black" : "" }}>
- <div className="propertiesView-fields-title-name">
- Fields {"&"} Tags
+ Fields {"&"} Tags
<div className="propertiesView-fields-title-icon">
- <FontAwesomeIcon icon={this.openFields ? "caret-down" : "caret-right"} size="lg" color="white" />
- </div>
+ <FontAwesomeIcon icon={this.openFields ? "caret-down" : "caret-right"} size="lg" color="white" />
</div>
</div>
{!novice && this.openFields ? <div className="propertiesView-fields-checkbox">
@@ -943,18 +957,15 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
<FontAwesomeIcon icon={this.openLayout ? "caret-down" : "caret-right"} size="lg" color="white" />
</div>
</div>
- {this.openLayout ? <div className="propertiesView-layout-content">{this.layoutPreview}</div> : null}
+ {this.openLayout ? <div className="propertiesView-layout-content" >{this.layoutPreview}</div> : null}
</div>
</div>;
}
if (this.isPres) {
- const selectedItem: boolean = PresBox.Instance._selectedArray.length > 0;
- return <div className="propertiesView" style={{ width: this.props.width }} >
- <div className="propertiesView-title" style={{ width: this.props.width }}>
+ const selectedItem: boolean = PresBox.Instance?._selectedArray.length > 0;
+ return <div className="propertiesView">
+ <div className="propertiesView-title">
Presentation
- <div className="propertiesView-title-icon" onPointerDown={this.props.onDown}>
- <FontAwesomeIcon icon="times" color="black" size="sm" />
- </div>
</div>
<div className="propertiesView-name">
{this.editableTitle}