aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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/client/views/collections/CollectionDockingView.tsx8
-rw-r--r--src/client/views/collections/collectionFreeForm/FormatShapePane.tsx2
-rw-r--r--src/fields/InkField.ts5
6 files changed, 17 insertions, 13 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 0afc71e9b..f0505ed95 100644
--- a/src/client/views/InkingStroke.tsx
+++ b/src/client/views/InkingStroke.tsx
@@ -107,10 +107,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/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 533c8bffe..75a4bda14 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -793,10 +793,10 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
let scaling = 1;
if (!this.layoutDoc?._fitWidth && (!nativeW || !nativeH)) {
scaling = 1;
- } else if ((this.layoutDoc?._fitWidth) ||
- this._panelHeight / NumCast(this.layoutDoc!._nativeHeight) > this._panelWidth / NumCast(this.layoutDoc!._nativeWidth)) {
+ } else if (NumCast(this.layoutDoc!._nativeWidth) && ((this.layoutDoc?._fitWidth) ||
+ this._panelHeight / NumCast(this.layoutDoc!._nativeHeight) > this._panelWidth / NumCast(this.layoutDoc!._nativeWidth))) {
scaling = this._panelWidth / NumCast(this.layoutDoc!._nativeWidth);
- } else {
+ } else if (nativeW && nativeH) {
// if (this.layoutDoc!.type === DocumentType.PDF || this.layoutDoc!.type === DocumentType.WEB) {
// if ((this.layoutDoc?._fitWidth) ||
// this._panelHeight / NumCast(this.layoutDoc!._nativeHeight) > this._panelWidth / NumCast(this.layoutDoc!._nativeWidth)) {
@@ -807,7 +807,7 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
// }
const wscale = this.panelWidth() / nativeW;
scaling = wscale * nativeH > this._panelHeight ? this._panelHeight / nativeH : wscale;
- }
+ } else scaling = 1;
return scaling;
}
diff --git a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
index e805f9282..c53e4de0f 100644
--- a/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
+++ b/src/client/views/collections/collectionFreeForm/FormatShapePane.tsx
@@ -290,7 +290,6 @@ export default class FormatShapePane extends AntimodeMenu {
@undoBatch
@action
control = (xDiff: number, yDiff: number, controlNum: number) => {
- // console.log(controlNum, ink.length);
this.selectedInk?.forEach(action(inkView => {
if (this.selectedInk?.length === 1) {
const doc = Document(inkView.rootDoc);
@@ -298,7 +297,6 @@ export default class FormatShapePane extends AntimodeMenu {
const ink = Cast(doc.data, InkField)?.inkData;
if (ink) {
-
const newPoints: { X: number, Y: number }[] = [];
const order = controlNum % 4;
for (var i = 0; i < ink.length; i++) {
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