From a7f5bd1c2438f95252f5515d7226b491dfb5183b Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 24 May 2024 11:27:56 -0400 Subject: lint fixes --- src/client/documents/Documents.ts | 20 +------ .../collectionFreeForm/CollectionFreeFormView.tsx | 66 +++++++++++----------- 2 files changed, 34 insertions(+), 52 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 640fb251d..a67e6b4f6 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -5,22 +5,7 @@ import { reaction } from 'mobx'; import { basename } from 'path'; import { ClientUtils, OmitKeys } from '../../ClientUtils'; import { DateField } from '../../fields/DateField'; -import { - ActiveArrowEnd, - ActiveArrowStart, - ActiveDash, - ActiveFillColor, - ActiveInkBezierApprox, - ActiveInkColor, - ActiveEraserWidth, - ActiveInkWidth, - ActiveIsInkMask, - CreateLinkToActiveAudio, - Doc, - FieldType, - Opt, - updateCachedAcls, -} from '../../fields/Doc'; +import { ActiveArrowEnd, ActiveArrowStart, ActiveDash, ActiveFillColor, ActiveInkBezierApprox, ActiveInkColor, ActiveInkWidth, ActiveIsInkMask, CreateLinkToActiveAudio, Doc, FieldType, Opt, updateCachedAcls } from '../../fields/Doc'; import { Initializing } from '../../fields/DocSymbols'; import { HtmlField } from '../../fields/HtmlField'; import { InkField } from '../../fields/InkField'; @@ -852,7 +837,6 @@ export namespace Docs { points: PointData[], options: DocumentOptions = {}, strokeWidth = ActiveInkWidth(), - eraserWidth = ActiveEraserWidth(), color = ActiveInkColor(), strokeBezier = ActiveInkBezierApprox(), fillColor = ActiveFillColor(), @@ -963,7 +947,7 @@ export namespace Docs { return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Carousel3D }); } - export function CardDeckDocument(documents: Array, options: DocumentOptions, id?: string) { + export function CardDeckDocument(documents: Array, options: DocumentOptions) { return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _type_collection: CollectionViewType.Card }); } diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index be96b914c..b6e1fca77 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -894,7 +894,7 @@ export class CollectionFreeFormView extends CollectionSubView Math.abs(val - (t + Math.floor(i / 4))) <= tValOffset); + const inList = inkList.some(ival => Math.abs(ival - (t + Math.floor(i / 4))) <= tValOffset); if (!inList) { inkList.push(t + Math.floor(i / 4)); } @@ -1007,7 +1007,7 @@ export class CollectionFreeFormView extends CollectionSubView { if (tVals[startIndex] >= excludeT) { return [-1, startIndex]; - } else if (tVals[endIndex] < excludeT) { + } + if (tVals[endIndex] < excludeT) { return [endIndex, -1]; - } else { - const mid = Math.floor((startIndex + endIndex) / 2); - if (excludeT >= tVals[mid]) { - if (mid + 1 <= endIndex && tVals[mid + 1] > excludeT) { - return [mid, mid + 1]; - } else { - return this.getClosestTs(tVals, excludeT, mid + 1, endIndex); - } - } else if (mid - 1 >= startIndex && tVals[mid - 1] < excludeT) { - return [mid - 1, mid]; - } else { - return this.getClosestTs(tVals, excludeT, startIndex, mid - 1); + } + const mid = Math.floor((startIndex + endIndex) / 2); + if (excludeT >= tVals[mid]) { + if (mid + 1 <= endIndex && tVals[mid + 1] > excludeT) { + return [mid, mid + 1]; } + return this.getClosestTs(tVals, excludeT, mid + 1, endIndex); + } + if (mid - 1 >= startIndex && tVals[mid - 1] < excludeT) { + return [mid - 1, mid]; } + return this.getClosestTs(tVals, excludeT, startIndex, mid - 1); }; // for some reason bezier.js doesn't handle the case of intersecting a linear curve, so we wrap the intersection @@ -1212,10 +1210,10 @@ export class CollectionFreeFormView extends CollectionSubView { + this.bintersects(curve, otherCurve).forEach((val: string | number, ival: number) => { // Converting the Bezier.js Split type to a t-value number. const t = +val.toString().split('/')[0]; - if (i % 2 === 0 && !tVals.includes(t)) tVals.push(t); // bcz: Hack! don't know why but intersection points are doubled from bezier.js (but not identical). + if (ival % 2 === 0 && !tVals.includes(t)) tVals.push(t); // bcz: Hack! don't know why but intersection points are doubled from bezier.js (but not identical). }); if (bpt.d !== undefined && bpt.d < 1 && bpt.t !== undefined && !tVals.includes(bpt.t)) { tVals.push(bpt.t); @@ -1775,8 +1773,8 @@ export class CollectionFreeFormView extends CollectionSubView { if (!code.includes('dashDiv')) { const script = CompileScript(code, { params: { docView: 'any' }, typecheck: false, editable: true }); - // eslint-disable-next-line no-eval if (script.compiled) script.run({ this: this.DocumentView?.() }); + // eslint-disable-next-line no-eval } else code && !first && eval?.(code); }, { fireImmediately: true } -- cgit v1.2.3-70-g09d2