diff options
Diffstat (limited to 'src/client/views/InkTranscription.tsx')
-rw-r--r-- | src/client/views/InkTranscription.tsx | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/src/client/views/InkTranscription.tsx b/src/client/views/InkTranscription.tsx index ab189c0d6..487bbcd00 100644 --- a/src/client/views/InkTranscription.tsx +++ b/src/client/views/InkTranscription.tsx @@ -10,8 +10,12 @@ import { DocumentManager } from "../util/DocumentManager"; import { CollectionFreeFormView } from './collections/collectionFreeForm'; import { InkingStroke } from './InkingStroke'; import { CurrentUserUtils } from '../util/CurrentUserUtils'; +import "./InkTranscription.scss"; +/** + * Class component that handles inking in writing mode + */ export class InkTranscription extends React.Component { static Instance: InkTranscription; @@ -103,7 +107,15 @@ export class InkTranscription extends React.Component { return this._textRef = r; } - transcribeInk = (groupDoc: Doc | undefined, 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); @@ -129,6 +141,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", @@ -140,28 +159,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; @@ -175,6 +183,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) { @@ -235,19 +249,19 @@ 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 - if (CurrentUserUtils.SelectedTool === InkTool.Write) { + if (CurrentUserUtils.ActiveTool === InkTool.Write) { CollectionFreeFormView.collectionsWithUnprocessedInk.forEach(ffView => { // TODO: nda - will probably want to go through ffView unprocessed docs and then see if any of the inksToGroup docs are in it and only use those const selected = ffView.unprocessedDocs; 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(); |