aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/GestureOverlay.tsx37
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx14
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeView.tsx66
-rw-r--r--src/client/views/nodes/DocumentView.tsx17
-rw-r--r--src/client/views/nodes/RadialMenu.tsx8
-rw-r--r--src/mobile/MobileInterface.scss1
-rw-r--r--src/server/DashSession/DashSessionAgent.ts4
7 files changed, 83 insertions, 64 deletions
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index e8e9e8c28..11ad26cbe 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -27,6 +27,7 @@ import { listSpec } from "../../new_fields/Schema";
import { List } from "../../new_fields/List";
import { CollectionViewType } from "./collections/CollectionView";
import TouchScrollableMenu, { TouchScrollableMenuItem } from "./TouchScrollableMenu";
+import { RadialMenu } from "./nodes/RadialMenu";
import MobileInterface from "../../mobile/MobileInterface";
import { MobileInkOverlayContent } from "../../server/Message";
import MobileInkOverlay from "../../mobile/MobileInkOverlay";
@@ -56,7 +57,7 @@ export default class GestureOverlay extends Touchable {
@observable private _clipboardDoc?: JSX.Element;
@observable private _possibilities: JSX.Element[] = [];
- @computed private get height(): number { return 2 * Math.max(this._pointerY && this._thumbY ? this._thumbY - this._pointerY : 300, 300); }
+ @computed private get height(): number { return 2 * Math.max(this._pointerY && this._thumbY ? this._thumbY - this._pointerY : 100, 100); }
@computed private get showBounds() { return this.Tool !== ToolglassTools.None; }
@observable private showMobileInkOverlay: boolean = false;
@@ -79,7 +80,7 @@ export default class GestureOverlay extends Touchable {
componentDidMount = () => {
this._thumbDoc = FieldValue(Cast(CurrentUserUtils.setupThumbDoc(CurrentUserUtils.UserDocument), Doc));
- this._inkToTextDoc = FieldValue(Cast(this._thumbDoc ?.inkToTextDoc, Doc));
+ this._inkToTextDoc = FieldValue(Cast(this._thumbDoc?.inkToTextDoc, Doc));
}
getNewTouches(e: React.TouchEvent | TouchEvent) {
@@ -146,9 +147,7 @@ export default class GestureOverlay extends Touchable {
const nts = this.getNewTouches(te);
if (nts.nt.length < 5) {
const target = document.elementFromPoint(te.changedTouches.item(0).clientX, te.changedTouches.item(0).clientY);
- te.changedTouches.item(0).identifier;
- console.log(te.touches);
- target ?.dispatchEvent(
+ target?.dispatchEvent(
new CustomEvent<InteractionUtils.MultiTouchEvent<React.TouchEvent>>("dashOnTouchStart",
{
bubbles: true,
@@ -169,7 +168,7 @@ export default class GestureOverlay extends Touchable {
const target = document.elementFromPoint(te.changedTouches.item(0).clientX, te.changedTouches.item(0).clientY);
let pt: any = te.touches[te.touches.length - 1];
if (nts.nt.length === 1 && pt.radiusX > 1 && pt.radiusY > 1) {
- target ?.dispatchEvent(
+ target?.dispatchEvent(
new CustomEvent<InteractionUtils.MultiTouchEvent<React.TouchEvent>>("dashOnTouchHoldStart",
{
bubbles: true,
@@ -332,7 +331,7 @@ export default class GestureOverlay extends Touchable {
if (pt.radiusX > 1 && pt.radiusY > 1) {
for (let j = 0; j < e.targetTouches.length; j++) {
const tPt = e.targetTouches.item(j);
- if (tPt ?.screenX === pt ?.screenX && tPt ?.screenY === pt ?.screenY) {
+ if (tPt?.screenX === pt?.screenX && tPt?.screenY === pt?.screenY) {
if (pt && this.prevPoints.has(pt.identifier)) {
fingers.push(pt);
}
@@ -355,9 +354,9 @@ export default class GestureOverlay extends Touchable {
else {
console.log("not hand");
}
- this.pointerIdentifier = pointer ?.identifier;
+ this.pointerIdentifier = pointer?.identifier;
runInAction(() => {
- this._pointerY = pointer ?.clientY;
+ this._pointerY = pointer?.clientY;
if (thumb.identifier === this.thumbIdentifier) {
this._thumbX = thumb.clientX;
this._thumbY = thumb.clientY;
@@ -366,7 +365,7 @@ export default class GestureOverlay extends Touchable {
}
});
- this.thumbIdentifier = thumb ?.identifier;
+ this.thumbIdentifier = thumb?.identifier;
this._hands.set(thumb.identifier, fingers);
const others = fingers.filter(f => f !== thumb);
const minX = Math.min(...others.map(f => f.clientX));
@@ -401,7 +400,7 @@ export default class GestureOverlay extends Touchable {
if (pt.radiusX > 1 && pt.radiusY > 1) {
for (let j = 0; j < e.targetTouches.length; j++) {
const tPt = e.targetTouches.item(j);
- if (tPt ?.screenX === pt ?.screenX && tPt ?.screenY === pt ?.screenY) {
+ if (tPt?.screenX === pt?.screenX && tPt?.screenY === pt?.screenY) {
if (pt && this.prevPoints.has(pt.identifier)) {
this._hands.forEach(hand => hand.some(f => {
if (f.identifier === pt.identifier) {
@@ -414,7 +413,7 @@ export default class GestureOverlay extends Touchable {
}
}
const thumb = fingers.reduce((a, v) => a.clientY > v.clientY ? a : v, fingers[0]);
- if (thumb ?.identifier && thumb ?.identifier === this.thumbIdentifier) {
+ if (thumb?.identifier && thumb?.identifier === this.thumbIdentifier) {
this._hands.set(thumb.identifier, fingers);
}
@@ -464,7 +463,7 @@ export default class GestureOverlay extends Touchable {
this._thumbDoc = undefined;
let scriptWorked = false;
- if (NumCast(this._inkToTextDoc ?.selectedIndex) > -1) {
+ if (NumCast(this._inkToTextDoc?.selectedIndex) > -1) {
const selectedButton = this._possibilities[this._selectedIndex];
if (selectedButton) {
selectedButton.props.onClick();
@@ -552,8 +551,8 @@ export default class GestureOverlay extends Touchable {
callbackFn: callback
}
});
- target1 ?.dispatchEvent(ge);
- target2 ?.dispatchEvent(ge);
+ target1?.dispatchEvent(ge);
+ target2?.dispatchEvent(ge);
return actionPerformed;
}
@@ -590,10 +589,10 @@ export default class GestureOverlay extends Touchable {
const possibilities: string[] = [];
for (const wR of wordResults) {
console.log(wR);
- if (wR ?.recognizedText) {
- possibilities.push(wR ?.recognizedText)
+ if (wR?.recognizedText) {
+ possibilities.push(wR?.recognizedText)
}
- possibilities.push(...wR ?.alternates ?.map((a: any) => a.recognizedString));
+ possibilities.push(...wR?.alternates?.map((a: any) => a.recognizedString));
}
console.log(possibilities);
const r = Math.max(this.svgBounds.right, ...this._strokes.map(s => this.getBounds(s).right));
@@ -652,7 +651,7 @@ export default class GestureOverlay extends Touchable {
dispatchGesture = (gesture: GestureUtils.Gestures, stroke?: InkData, data?: any) => {
const target = document.elementFromPoint((stroke ?? this._points)[0].X, (stroke ?? this._points)[0].Y);
- target ?.dispatchEvent(
+ target?.dispatchEvent(
new CustomEvent<GestureUtils.GestureEvent>("dashOnGesture",
{
bubbles: true,
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 2f50fd710..047a3a1cc 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -86,7 +86,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
@observable private _pullCoords: number[] = [0, 0];
@observable private _pullDirection: string = "";
- public get displayName() { return "CollectionFreeFormView(" + this.props.Document.title ?.toString() + ")"; } // this makes mobx trace() statements more descriptive
+ public get displayName() { return "CollectionFreeFormView(" + this.props.Document.title?.toString() + ")"; } // this makes mobx trace() statements more descriptive
@observable.shallow _layoutElements: ViewDefResult[] = []; // shallow because some layout items (eg pivot labels) are just generated 'divs' and can't be frozen as observables
@observable _clusterSets: (Doc[])[] = [];
@@ -255,7 +255,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
docs.map(doc => this._clusterSets[doc.cluster = NumCast(docFirst.cluster)].push(doc));
}
childLayouts.map(child => !this._clusterSets.some((set, i) => Doc.IndexOf(child, set) !== -1 && child.cluster === i) && this.updateCluster(child));
- childLayouts.map(child => Doc.GetProto(child).clusterStr = child.cluster ?.toString());
+ childLayouts.map(child => Doc.GetProto(child).clusterStr = child.cluster?.toString());
}
}
@@ -434,9 +434,9 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
console.log("end");
if (this._inkToTextStartX && this._inkToTextStartY) {
const end = this.getTransform().transformPoint(Math.max(...ge.points.map(p => p.X)), Math.max(...ge.points.map(p => p.Y)));
- const setDocs = this.getActiveDocuments().filter(s => s.proto ?.type === "text" && s.color);
+ const setDocs = this.getActiveDocuments().filter(s => s.proto?.type === "text" && s.color);
const sets = setDocs.map((sd) => {
- return Cast(sd.data, RichTextField) ?.Text as string;
+ return Cast(sd.data, RichTextField)?.Text as string;
});
if (sets.length && sets[0]) {
this._wordPalette.clear();
@@ -883,8 +883,8 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
}
getCalculatedPositions(params: { doc: Doc, index: number, collection: Doc, docs: Doc[], state: any }): { x?: number, y?: number, z?: number, width?: number, height?: number, transition?: string, state?: any } {
- const result = this.Document.arrangeScript ?.script.run(params, console.log);
- if (result ?.success) {
+ const result = this.Document.arrangeScript?.script.run(params, console.log);
+ if (result?.success) {
return { ...result, transition: "transform 1s" };
}
const layoutDoc = Doc.Layout(params.doc);
@@ -1114,7 +1114,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
}
@computed get placeholder() {
return <div className="collectionfreeformview-placeholder" style={{ background: this.Document.backgroundColor }}>
- <span className="collectionfreeformview-placeholderSpan">{this.props.Document.title ?.toString()}</span>
+ <span className="collectionfreeformview-placeholderSpan">{this.props.Document.title?.toString()}</span>
</div>;
}
@computed get marqueeView() {
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index d4faa4dc1..fb476b54b 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -1,7 +1,7 @@
import { action, computed, observable } from "mobx";
import { observer } from "mobx-react";
import { Doc, DocListCast, DataSym, WidthSym, HeightSym } from "../../../../new_fields/Doc";
-import { InkField } from "../../../../new_fields/InkField";
+import { InkField, InkData } from "../../../../new_fields/InkField";
import { List } from "../../../../new_fields/List";
import { listSpec } from "../../../../new_fields/Schema";
import { SchemaHeaderField } from "../../../../new_fields/SchemaHeaderField";
@@ -382,8 +382,18 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
wordToColor.set(word, colors[i]);
});
});
- const inkFields = inks.map(i => Cast(i.data, InkField));
- CognitiveServices.Inking.Appliers.InterpretStrokes(inkFields.filter(i => i instanceof InkField).map(i => i!.inkData)).then((results) => {
+ const strokes: InkData[] = [];
+ inks.forEach(i => {
+ const d = Cast(i.data, InkField);
+ const x = NumCast(i.x);
+ const y = NumCast(i.y);
+ const left = Math.min(...d?.inkData.map(pd => pd.X) ?? [0]);
+ const top = Math.min(...d?.inkData.map(pd => pd.Y) ?? [0]);
+ if (d) {
+ strokes.push(d.inkData.map(pd => ({ X: pd.X + x - left, Y: pd.Y + y - top })));
+ }
+ });
+ CognitiveServices.Inking.Appliers.InterpretStrokes(strokes).then((results) => {
// const wordResults = results.filter((r: any) => r.category === "inkWord");
// console.log(wordResults);
// console.log(results);
@@ -403,29 +413,33 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
// }
// })
// }
- const wordResults = results.filter((r: any) => r.category === "inkWord");
- for (const word of wordResults) {
- const indices: number[] = word.strokeIds;
- indices.forEach(i => {
- const otherInks: Doc[] = [];
- indices.forEach(i2 => i2 !== i && otherInks.push(inks[i2]));
- inks[i].relatedInks = new List<Doc>(otherInks);
- const uniqueColors: string[] = [];
- Array.from(wordToColor.values()).forEach(c => uniqueColors.indexOf(c) === -1 && uniqueColors.push(c));
- inks[i].alternativeColors = new List<string>(uniqueColors);
- if (wordToColor.has(word.recognizedText.toLowerCase())) {
- inks[i].color = wordToColor.get(word.recognizedText.toLowerCase());
- }
- else if (word.alternates) {
- for (const alt of word.alternates) {
- if (wordToColor.has(alt.recognizedString.toLowerCase())) {
- inks[i].color = wordToColor.get(alt.recognizedString.toLowerCase());
- break;
- }
- }
- }
- });
- }
+ // const wordResults = results.filter((r: any) => r.category === "inkWord");
+ // for (const word of wordResults) {
+ // const indices: number[] = word.strokeIds;
+ // indices.forEach(i => {
+ // const otherInks: Doc[] = [];
+ // indices.forEach(i2 => i2 !== i && otherInks.push(inks[i2]));
+ // inks[i].relatedInks = new List<Doc>(otherInks);
+ // const uniqueColors: string[] = [];
+ // Array.from(wordToColor.values()).forEach(c => uniqueColors.indexOf(c) === -1 && uniqueColors.push(c));
+ // inks[i].alternativeColors = new List<string>(uniqueColors);
+ // if (wordToColor.has(word.recognizedText.toLowerCase())) {
+ // inks[i].color = wordToColor.get(word.recognizedText.toLowerCase());
+ // }
+ // else if (word.alternates) {
+ // for (const alt of word.alternates) {
+ // if (wordToColor.has(alt.recognizedString.toLowerCase())) {
+ // inks[i].color = wordToColor.get(alt.recognizedString.toLowerCase());
+ // break;
+ // }
+ // }
+ // }
+ // });
+ // }
+ const lines = results.filter((r: any) => r.category === "line");
+ console.log(lines);
+ const text = lines.map((l: any) => l.recognizedText).join("\r\n");
+ this.props.addDocument(Docs.Create.TextDocument(text, { _width: this.Bounds.width, _height: this.Bounds.height, x: this.Bounds.left + this.Bounds.width, y: this.Bounds.top, title: text }));
});
}
}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 9182eb4c0..09abd6d1d 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -165,14 +165,13 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
me.touchEvent.stopPropagation();
me.touchEvent.preventDefault();
e.stopPropagation();
-
-
+ if (RadialMenu.Instance.used) {
+ this.onContextMenu(me.touches[0]);
+ }
}
@action
onRadialMenu = (e: Event, me: InteractionUtils.MultiTouchEvent<React.TouchEvent>): void => {
- console.log("DISPLAYMENUUUU");
- console.log(me.touchEvent.touches);
// console.log(InteractionUtils.GetMyTargetTouches(me, this.prevPoints, true));
// const pt = InteractionUtils.GetMyTargetTouches(me, this.prevPoints, true)[0];
const pt = me.touchEvent.touches[me.touchEvent.touches.length - 1];
@@ -744,7 +743,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
return;
}
e.persist();
- e.stopPropagation();
+ e?.stopPropagation();
if (Math.abs(this._downX - e.clientX) > 3 || Math.abs(this._downY - e.clientY) > 3 ||
e.isDefaultPrevented()) {
e.preventDefault();
@@ -836,12 +835,12 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
ext_recommender_subitems.push({
description: "arXiv",
- event: () => this.externalRecommendation(e, "arxiv"),
+ event: () => this.externalRecommendation("arxiv"),
icon: "brain"
});
ext_recommender_subitems.push({
description: "Bing",
- event: () => this.externalRecommendation(e, "bing"),
+ event: () => this.externalRecommendation("bing"),
icon: "brain"
});
@@ -891,7 +890,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
if (!this.topMost) {
// DocumentViews should stop propagation of this event
- e.stopPropagation();
+ me?.stopPropagation();
}
ContextMenu.Instance.displayMenu(e.pageX - 15, e.pageY - 15);
if (!SelectionManager.IsSelected(this, true)) {
@@ -964,7 +963,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
}
@action
- externalRecommendation = async (e: React.MouseEvent, api: string) => {
+ externalRecommendation = async (api: string) => {
if (!ClientRecommender.Instance) new ClientRecommender({ title: "Client Recommender" });
ClientRecommender.Instance.reset_docs();
const doc = Doc.GetDataDoc(this.props.Document);
diff --git a/src/client/views/nodes/RadialMenu.tsx b/src/client/views/nodes/RadialMenu.tsx
index a6fb72a7b..d7f7c2e33 100644
--- a/src/client/views/nodes/RadialMenu.tsx
+++ b/src/client/views/nodes/RadialMenu.tsx
@@ -5,6 +5,8 @@ import { RadialMenuItem, RadialMenuProps } from "./RadialMenuItem";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import Measure from "react-measure";
import "./RadialMenu.scss";
+import MobileInkOverlay from "../../../mobile/MobileInkOverlay";
+import MobileInterface from "../../../mobile/MobileInterface";
@observer
export class RadialMenu extends React.Component {
@@ -23,6 +25,8 @@ export class RadialMenu extends React.Component {
@observable private _mouseDown: boolean = false;
private _reactionDisposer?: IReactionDisposer;
+ public used: boolean = false;
+
catchTouch = (te: React.TouchEvent) => {
console.log("caught");
@@ -35,6 +39,7 @@ export class RadialMenu extends React.Component {
this._mouseDown = true;
this._mouseX = e.clientX;
this._mouseY = e.clientY;
+ this.used = false;
document.addEventListener("pointermove", this.onPointerMove);
}
@@ -68,6 +73,7 @@ export class RadialMenu extends React.Component {
}
@action
onPointerUp = (e: PointerEvent) => {
+ this.used = true;
this._mouseDown = false;
const curX = e.clientX;
const curY = e.clientY;
@@ -213,7 +219,7 @@ export class RadialMenu extends React.Component {
render() {
- if (!this._display) {
+ if (!this._display || MobileInterface.Instance) {
return null;
}
const style = this._yRelativeToTop ? { left: this._pageX - 130, top: this._pageY - 130 } :
diff --git a/src/mobile/MobileInterface.scss b/src/mobile/MobileInterface.scss
index d0849dbc7..4d86e208f 100644
--- a/src/mobile/MobileInterface.scss
+++ b/src/mobile/MobileInterface.scss
@@ -15,4 +15,5 @@
.mobileInterface-container {
height: 100%;
position: relative;
+ touch-action: none;
} \ No newline at end of file
diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts
index 44f77c049..c74b50555 100644
--- a/src/server/DashSession/DashSessionAgent.ts
+++ b/src/server/DashSession/DashSessionAgent.ts
@@ -26,7 +26,7 @@ export class DashSessionAgent extends AppliedSessionAgent {
* Installs event hooks, repl commands and additional IPC listeners.
*/
// protected async initializeMonitor(monitor: Monitor, sessionKey: string): Promise<void> {
- protected async initializeMonitor(monitor: Monitor): Promise<string> {
+ protected async initializeMonitor(monitor: Monitor): Promise<void> {
// await this.dispatchSessionPassword(sessionKey);
// monitor.addReplCommand("pull", [], () => monitor.exec("git pull"));
@@ -36,7 +36,7 @@ export class DashSessionAgent extends AppliedSessionAgent {
// monitor.on("backup", this.backup);
// monitor.on("debug", async ({ to }) => this.dispatchZippedDebugBackup(to));
// monitor.coreHooks.onCrashDetected(this.dispatchCrashReport);
- return "";
+ return;
}
/**