diff options
| author | Stanley Yip <stanley_yip@brown.edu> | 2020-01-30 18:45:55 -0500 |
|---|---|---|
| committer | Stanley Yip <stanley_yip@brown.edu> | 2020-01-30 18:45:55 -0500 |
| commit | 76b99cf70c36ca8a691010c86f5f444dd30eb004 (patch) | |
| tree | 396d7328d46d66dc83afc7f2941d410538243bf5 /src/client/views/InkingStroke.tsx | |
| parent | 17dcf7e4d8c2f038dc3a6168b1ff6b8d3cb15536 (diff) | |
| parent | d7a076ca7315a892b6a43b0e7454abf470f48455 (diff) | |
some bugfixes
Diffstat (limited to 'src/client/views/InkingStroke.tsx')
| -rw-r--r-- | src/client/views/InkingStroke.tsx | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx index aca507147..f315ce12a 100644 --- a/src/client/views/InkingStroke.tsx +++ b/src/client/views/InkingStroke.tsx @@ -11,6 +11,12 @@ import { FieldView, FieldViewProps } from "./nodes/FieldView"; import React = require("react"); import { TraceMobx } from "../../new_fields/util"; import { InteractionUtils } from "../util/InteractionUtils"; +import { ContextMenu } from "./ContextMenu"; +import { CognitiveServices } from "../cognitive_services/CognitiveServices"; +import { faPaintBrush } from "@fortawesome/free-solid-svg-icons"; +import { library } from "@fortawesome/fontawesome-svg-core"; + +library.add(faPaintBrush); type InkDocument = makeInterface<[typeof documentSchema]>; const InkDocument = makeInterface(documentSchema); @@ -22,6 +28,11 @@ export class InkingStroke extends DocExtendableComponent<FieldViewProps, InkDocu @computed get PanelWidth() { return this.props.PanelWidth(); } @computed get PanelHeight() { return this.props.PanelHeight(); } + private analyzeStrokes = () => { + const data: InkData = Cast(this.Document.data, InkField)?.inkData ?? []; + CognitiveServices.Inking.Appliers.ConcatenateHandwriting(this.Document, ["inkAnalysis", "handwriting"], [data]); + } + render() { TraceMobx(); const data: InkData = Cast(this.Document.data, InkField)?.inkData ?? []; @@ -37,12 +48,23 @@ export class InkingStroke extends DocExtendableComponent<FieldViewProps, InkDocu const scaleX = this.PanelWidth / width; const scaleY = this.PanelHeight / height; return ( - <svg width={width} height={height} style={{ - transformOrigin: "top left", - transform: `scale(${scaleX}, ${scaleY})`, - mixBlendMode: this.Document.tool === InkTool.Highlighter ? "multiply" : "unset", - pointerEvents: "all" - }}> + <svg + width={width} + height={height} + style={{ + transformOrigin: "top left", + transform: `scale(${scaleX}, ${scaleY})`, + mixBlendMode: this.Document.tool === InkTool.Highlighter ? "multiply" : "unset", + pointerEvents: "all" + }} + onContextMenu={() => { + ContextMenu.Instance.addItem({ + description: "Analyze Stroke", + event: this.analyzeStrokes, + icon: "paint-brush" + }); + }} + > {points} </svg> ); |
