aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/type_decls.d5
-rw-r--r--src/client/views/DocumentDecorations.tsx2
-rw-r--r--src/client/views/InkingStroke.tsx8
-rw-r--r--src/fields/InkField.ts5
4 files changed, 13 insertions, 7 deletions
diff --git a/src/client/util/type_decls.d b/src/client/util/type_decls.d
index 08aec3724..ab6c94f83 100644
--- a/src/client/util/type_decls.d
+++ b/src/client/util/type_decls.d
@@ -187,6 +187,11 @@ declare class List<T extends Field> extends ObjectField {
[Copy](): ObjectField;
}
+declare class InkField extends ObjectField {
+ constructor(data:Array<{X:number, Y:number}>);
+ [Copy](): ObjectField;
+}
+
// @ts-ignore
declare const console: any;
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 1ae7d6617..005df6fe0 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -68,8 +68,6 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
private _prevY = 0;
private _centerPoints: { X: number, Y: number }[] = [];
private _inkDocs: { x: number, y: number, width: number, height: number }[] = [];
- private _natWid = 0;
- private _natHei = 0;
@observable private _accumulatedTitle = "";
@observable private _titleControlString: string = "#title";
diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx
index fe5bf1eb2..6c5eda256 100644
--- a/src/client/views/InkingStroke.tsx
+++ b/src/client/views/InkingStroke.tsx
@@ -99,10 +99,10 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume
const top = Math.min(...ys) - strokeWidth / 2;
const right = Math.max(...xs) + strokeWidth / 2;
const bottom = Math.max(...ys) + strokeWidth / 2;
- const width = right - left;
- const height = bottom - top;
- const scaleX = (this.props.PanelWidth() - strokeWidth) / (width - strokeWidth);
- const scaleY = (this.props.PanelHeight() - strokeWidth) / (height - strokeWidth);
+ const width = Math.max(right - left);
+ const height = Math.max(1, bottom - top);
+ const scaleX = width === strokeWidth ? 1 : (this.props.PanelWidth() - strokeWidth) / (width - strokeWidth);
+ const scaleY = height === strokeWidth ? 1 : (this.props.PanelHeight() - strokeWidth) / (height - strokeWidth);
const strokeColor = StrCast(this.layoutDoc.color, "");
const points = InteractionUtils.CreatePolyline(data, left, top, strokeColor, strokeWidth, strokeWidth,
diff --git a/src/fields/InkField.ts b/src/fields/InkField.ts
index 7cfd74cc4..dbe51b24a 100644
--- a/src/fields/InkField.ts
+++ b/src/fields/InkField.ts
@@ -2,6 +2,7 @@ import { Deserializable } from "../client/util/SerializationHelper";
import { serializable, custom, createSimpleSchema, list, object, map } from "serializr";
import { ObjectField } from "./ObjectField";
import { Copy, ToScriptString, ToString, Update } from "./FieldSymbols";
+import { Scripting } from "../client/util/Scripting";
export enum InkTool {
None = "none",
@@ -44,9 +45,11 @@ export class InkField extends ObjectField {
}
[ToScriptString]() {
- return "invalid";
+ return "new InkField([" + this.inkData.map(i => `{X: ${i.X}, Y: ${i.Y}} `) + "])";
}
[ToString]() {
return "InkField";
}
}
+
+Scripting.addGlobal("InkField", InkField); \ No newline at end of file