aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-06-20 09:30:54 -0400
committerbobzel <zzzman@gmail.com>2025-06-20 09:30:54 -0400
commite7a96fa043cfc9c3c426e09bbef42c8df88a45f6 (patch)
treefa133de33383f090ff430a29c6720e11ff3385bd /src
parent21fb3a555cdd861452e2e54de3d0524e29f2bc08 (diff)
cleanup
Diffstat (limited to 'src')
-rw-r--r--src/client/views/InkTranscription.tsx21
-rw-r--r--src/client/views/nodes/ImageBox.tsx6
2 files changed, 13 insertions, 14 deletions
diff --git a/src/client/views/InkTranscription.tsx b/src/client/views/InkTranscription.tsx
index 2e6b477e9..6220033d4 100644
--- a/src/client/views/InkTranscription.tsx
+++ b/src/client/views/InkTranscription.tsx
@@ -4,8 +4,8 @@ import * as React from 'react';
import { imageUrlToBase64 } from '../../ClientUtils';
import { aggregateBounds } from '../../Utils';
import { Doc, DocListCast } from '../../fields/Doc';
-import { InkData, InkField, InkInkTool, InkTool } from '../../fields/InkField';
-import { Cast, DateCast, ImageCast, NumCast } from '../../fields/Types';
+import { InkData, InkInkTool, InkTool } from '../../fields/InkField';
+import { Cast, DateCast, ImageCast, InkCast, NumCast } from '../../fields/Types';
import { ImageField, URLField } from '../../fields/URLField';
import { gptHandwriting } from '../apis/gpt/GPT';
import { DocumentType } from '../documents/DocumentTypes';
@@ -30,7 +30,7 @@ export class InkTranscription extends React.Component {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@observable _textRef: any = undefined;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- @observable iinkEditor: any = undefined;
+ @observable _iinkEditor: any = undefined;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private lastJiix: any;
private currGroup?: Doc;
@@ -94,7 +94,7 @@ export class InkTranscription extends React.Component {
},
},
};
- this.iinkEditor = await iink.Editor.load(r, 'INKV2', options);
+ this._iinkEditor = await iink.Editor.load(r, 'INKV2', options);
this._textRegister = r;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
r?.addEventListener('exported', (e: any) => this.exportInk(e, this._textRef));
@@ -118,19 +118,20 @@ export class InkTranscription extends React.Component {
const times: number[] = [];
validInks
- .filter(i => Cast(i[Doc.LayoutDataKey(i)], InkField))
+ .filter(i => InkCast(i[Doc.LayoutDataKey(i)]))
.forEach(i => {
- const d = Cast(i[Doc.LayoutDataKey(i)], InkField, null);
+ const d = InkCast(i[Doc.LayoutDataKey(i)])!;
+ const authorTime = DateCast(i.author_date)?.getDate().getTime() ?? 0;
const inkStroke = DocumentView.getDocumentView(i)?.ComponentView as InkingStroke;
strokes.push(d.inkData.map(pd => inkStroke.ptToScreen({ X: pd.X, Y: pd.Y })));
- times.push(DateCast(i.author_date).getDate().getTime());
+ times.push(authorTime);
});
this.currGroup = groupDoc;
const pointerData = strokes.map((stroke, i) => this.inkJSON(stroke, times[i]));
if (math) {
- this.iinkEditor.importPointEvents(pointerData);
+ this._iinkEditor.importPointEvents(pointerData);
} else {
- this.iinkEditor.importPointEvents(pointerData);
+ this._iinkEditor.importPointEvents(pointerData);
}
};
convertPointsToString(points: InkData[]): string {
@@ -234,7 +235,7 @@ export class InkTranscription extends React.Component {
const docList = DocListCast(this.currGroup.data);
docList.forEach((inkDoc: Doc) => {
// just having the times match up and be a unique value (actual timestamp doesn't matter)
- const ms = DateCast(inkDoc.author_date).getDate().getTime() + 14400000;
+ const ms = (DateCast(inkDoc.author_date)?.getDate().getTime() ?? 0) + 14400000;
const word = timestampWord.get(ms);
if (!word) {
return;
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index 5b738ee19..78bacdcac 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -72,7 +72,7 @@ export class ImageEditorData {
public static set AddDoc(addDoc: Opt<(doc: Doc | Doc[], annotationKey?: string) => boolean>) { ImageEditorData.set(this.imageData.open, this.imageData.rootDoc, this.imageData.source, addDoc); } // prettier-ignore
}
-const API_URL = 'https://api.unsplash.com/search/photos';
+const UNSPLASH_API = 'https://api.unsplash.com/search/photos';
@observer
export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
public static LayoutString(fieldKey: string) {
@@ -245,7 +245,7 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
*/
fetchImages = async () => {
try {
- const { data } = await axios.get(`${API_URL}?query=${this._searchInput}&page=1&per_page=${1}&client_id=${process.env.VITE_API_KEY}`);
+ const { data } = await axios.get(`${UNSPLASH_API}?query=${this._searchInput}&page=1&per_page=${1}&client_id=${process.env.VITE_API_KEY}`);
const imageSnapshot = Docs.Create.ImageDocument(data.results[0].urls.small, {
_nativeWidth: Doc.NativeWidth(this.layoutDoc),
_nativeHeight: Doc.NativeHeight(this.layoutDoc),
@@ -262,8 +262,6 @@ export class ImageBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
}
};
- handleSelection = (selection: string) => (this._searchInput = selection);
-
drop = undoable(
action((e: Event, de: DragManager.DropEvent) => {
if (de.complete.docDragData && !this._props.rejectDrop?.(de, this.DocumentView?.())) {