diff --git a/entities/ProcessedText.go b/entities/ProcessedText.go index 69f9cda..961105b 100644 --- a/entities/ProcessedText.go +++ b/entities/ProcessedText.go @@ -23,14 +23,12 @@ type ProcessedWord struct { } type ProcessedLine struct { - FullText string `json:"fullText"` - Words []ProcessedWord `json:"words"` + Words []ProcessedWord `json:"words"` } type ProcessedArea struct { Id string `json:"id"` DocumentId string `json:"documentId"` - FullText string `json:"fullText"` Order int `json:"order"` Lines []ProcessedLine `json:"lines"` } diff --git a/frontend/components/DocumentCanvas/konva/AreaContextMenu/index.tsx b/frontend/components/DocumentCanvas/konva/AreaContextMenu/index.tsx index 16cac56..b438556 100644 --- a/frontend/components/DocumentCanvas/konva/AreaContextMenu/index.tsx +++ b/frontend/components/DocumentCanvas/konva/AreaContextMenu/index.tsx @@ -35,10 +35,10 @@ const AreaContextMenu = (props: Props) => { const handleCopyButtonClick = async () => { const processedArea = await getProcessedAreaById(area.id) - console.log(processedArea) - const fullText = processedArea?.fullText // TODO: change when `fullText` is calculated from processed words - console.log('fullText: ', fullText) + const wordsOfProcessedArea = processedArea?.lines.flatMap(l => l.words.map(w => w.fullText)) + const fullText = wordsOfProcessedArea?.join(' ') if (!fullText) return // TODO: change to show notification when copy fails + await navigator.clipboard.writeText(fullText) setIsAreaContextMenuOpen(false) } @@ -46,12 +46,14 @@ const AreaContextMenu = (props: Props) => { const handleDeleteButtonClick = async () => { const response = await requestDeleteAreaById(area.id) if (!response) return // TODO: change to show notification when copy fails + setIsAreaContextMenuOpen(false) } const handleReprocessButtonClick = async () => { - const documentId = await getSelectedDocument()?.id + const documentId = getSelectedDocument()?.id if (!documentId) return // TODO: change to show notification when copy fails + setIsAreaContextMenuOpen(false) // TODO: possibly have loading animation and wait until after process await processImageArea(documentId, area.id) } diff --git a/frontend/wailsjs/wailsjs/go/models.ts b/frontend/wailsjs/wailsjs/go/models.ts index c8dff58..8230fb8 100755 --- a/frontend/wailsjs/wailsjs/go/models.ts +++ b/frontend/wailsjs/wailsjs/go/models.ts @@ -278,7 +278,6 @@ export namespace entities { } } export class ProcessedLine { - fullText: string; words: ProcessedWord[]; static createFrom(source: any = {}) { @@ -287,7 +286,6 @@ export namespace entities { constructor(source: any = {}) { if ('string' === typeof source) source = JSON.parse(source); - this.fullText = source["fullText"]; this.words = this.convertValues(source["words"], ProcessedWord); } @@ -312,7 +310,6 @@ export namespace entities { export class ProcessedArea { id: string; documentId: string; - fullText: string; order: number; lines: ProcessedLine[]; @@ -324,7 +321,6 @@ export namespace entities { if ('string' === typeof source) source = JSON.parse(source); this.id = source["id"]; this.documentId = source["documentId"]; - this.fullText = source["fullText"]; this.order = source["order"]; this.lines = this.convertValues(source["lines"], ProcessedLine); }