diff options
-rw-r--r-- | src/client/views/InkTranscription.tsx | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/client/views/InkTranscription.tsx b/src/client/views/InkTranscription.tsx index e1a80ae50..75e246cda 100644 --- a/src/client/views/InkTranscription.tsx +++ b/src/client/views/InkTranscription.tsx @@ -13,6 +13,9 @@ import { InkingStroke } from './InkingStroke'; import { CurrentUserUtils } from '../util/CurrentUserUtils'; +/** + * Class component that handles inking in writing mode + */ export class InkTranscription extends React.Component { static Instance: InkTranscription; @@ -105,7 +108,15 @@ export class InkTranscription extends React.Component { return this._textRef = r; } - transcribeInk = (groupDoc: Doc | undefined, containingLayout: Doc, inkDocs: Doc[], math: boolean, ffView?: CollectionFreeFormView) => { + /** + * Handles processing Dash Doc data for ink transcription. + * + * @param groupDoc the group which contains the ink strokes we want to transcribe + * @param containingLayout the layout which contains the group + * @param inkDocs the ink docs contained within the selected group + * @param math boolean whether to do math transcription or not + */ + transcribeInk = (groupDoc: Doc | undefined, containingLayout: Doc, inkDocs: Doc[], math: boolean) => { if (!groupDoc) return; const validInks = inkDocs.filter(s => s.type === DocumentType.INK); @@ -132,6 +143,13 @@ export class InkTranscription extends React.Component { } } + /** + * Converts the Dash Ink Data to JSON. + * + * @param stroke The dash ink data + * @param time the time of the stroke + * @returns json object representation of ink data + */ inkJSON = (stroke: InkData, time: number) => { return { "pointerType": "PEN", @@ -143,28 +161,17 @@ export class InkTranscription extends React.Component { }; } - mmToPixel = (mm: number) => { - return ((96 * mm) / 25.4); - } - - calcBounds = (coords: any) => { - // find max and min x values and subtract - const max = Math.max(...coords); - const min = Math.min(...coords); - return max - min; - } - + /** + * Creates subgroups for each word for the whole text transcription + * @param wordInkDocMap the mapping of words to ink strokes (Ink Docs) + */ subgroupsTranscriptions = (wordInkDocMap: Map<string, Doc[]>) => { - // loop through the words in wordInkDocMap - // for each word, get the inkDocs - // iterate through the keys of wordInkDocMap wordInkDocMap.forEach(async (inkDocs: Doc[], word: string) => { const selected = inkDocs.slice(); if (!selected) { return; } - // TODO: nda - probably have to cast this to an actual Doc const ctx = await Cast(selected[0].context, Doc); if (!ctx) { return; @@ -178,6 +185,12 @@ export class InkTranscription extends React.Component { }); } + /** + * Event listener function for when the 'exported' event is heard. + * + * @param e the event objects + * @param ref the ref to the editor + */ exportInk = (e: any, ref: any) => { const exports = e.detail.exports; if (exports) { @@ -239,8 +252,8 @@ export class InkTranscription extends React.Component { } } - /** - * Creates the ink grouping once the user leaves the writing mode +/** + * Creates the ink grouping once the user leaves the writing mode. */ createInkGroup() { // TODO nda - if document being added to is a inkGrouping then we can just add to that group @@ -251,7 +264,7 @@ createInkGroup() { const newCollection = this.groupInkDocs(selected, ffView); ffView.unprocessedDocs = []; - InkTranscription.Instance.transcribeInk(newCollection, ffView.layoutDoc, selected, false, ffView); + InkTranscription.Instance.transcribeInk(newCollection, ffView.layoutDoc, selected, false); }); } CollectionFreeFormView.collectionsWithUnprocessedInk.clear(); |