From 028dce485e9fce6df1515af013468bd97174c648 Mon Sep 17 00:00:00 2001 From: Bryan Haberberger Date: Fri, 17 Apr 2026 14:38:20 -0500 Subject: [PATCH 1/6] Ability to add TPEN Prompts manually and communicate context with postMessage() --- components/simple-transcription/index.js | 14 +++++++++++++- interfaces/transcription/index.js | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/components/simple-transcription/index.js b/components/simple-transcription/index.js index 769dd9fd..192cf926 100644 --- a/components/simple-transcription/index.js +++ b/components/simple-transcription/index.js @@ -872,7 +872,19 @@ export default class SimpleTranscriptionInterface extends HTMLElement { const projectPage = TPEN.activeProject?.layers ?.flatMap(layer => layer.pages || []) .find(p => p.id.split('/').pop() === currentPageId) - + + if (tool.toolName === 'tpen-prompts') { + iframe.contentWindow?.postMessage( + { + type: "AUTH_TOKEN", + token: this.userToken ?? null, + projectID: TPEN.screen?.projectInQuery ?? null, + pageID: currentPageId ?? null + }, + this._iframeOrigin + ) + } + iframe.contentWindow?.postMessage( { type: "MANIFEST_CANVAS_ANNOTATIONPAGE_ANNOTATION", diff --git a/interfaces/transcription/index.js b/interfaces/transcription/index.js index d9b9609b..d979e6a0 100644 --- a/interfaces/transcription/index.js +++ b/interfaces/transcription/index.js @@ -402,6 +402,19 @@ export default class TranscriptionInterface extends HTMLElement { this._iframeOrigin = new URL(tool.url).origin iframe.addEventListener('load', () => { + // Forward auth to TPEN-Prompts only; other tools do not receive the token. + if (tool.toolName === 'tpen-prompts') { + iframe.contentWindow?.postMessage( + { + type: "AUTH_TOKEN", + token: TPEN.getAuthorization?.() ?? null, + projectID: TPEN.screen?.projectInQuery ?? null, + pageID: TPEN.screen?.pageInQuery ?? null + }, + this._iframeOrigin + ) + } + iframe.contentWindow?.postMessage( { type: "MANIFEST_CANVAS_ANNOTATIONPAGE_ANNOTATION", From b84a05c700821801442a756b1985e7008a1801a8 Mon Sep 17 00:00:00 2001 From: Bryan Haberberger Date: Fri, 17 Apr 2026 15:12:30 -0500 Subject: [PATCH 2/6] changes while testing --- components/simple-transcription/index.js | 1 + interfaces/transcription/index.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/simple-transcription/index.js b/components/simple-transcription/index.js index 192cf926..d6138436 100644 --- a/components/simple-transcription/index.js +++ b/components/simple-transcription/index.js @@ -873,6 +873,7 @@ export default class SimpleTranscriptionInterface extends HTMLElement { ?.flatMap(layer => layer.pages || []) .find(p => p.id.split('/').pop() === currentPageId) + // Forward auth to TPEN-Prompts only; other tools do not receive the token. if (tool.toolName === 'tpen-prompts') { iframe.contentWindow?.postMessage( { diff --git a/interfaces/transcription/index.js b/interfaces/transcription/index.js index d979e6a0..74cbb702 100644 --- a/interfaces/transcription/index.js +++ b/interfaces/transcription/index.js @@ -407,7 +407,7 @@ export default class TranscriptionInterface extends HTMLElement { iframe.contentWindow?.postMessage( { type: "AUTH_TOKEN", - token: TPEN.getAuthorization?.() ?? null, + token: this.userToken ?? null, projectID: TPEN.screen?.projectInQuery ?? null, pageID: TPEN.screen?.pageInQuery ?? null }, From 0d5400f45800cd17edcd7494d271b72321076741 Mon Sep 17 00:00:00 2001 From: Bryan Haberberger Date: Mon, 20 Apr 2026 12:55:35 -0500 Subject: [PATCH 3/6] Should get both now, should be able to unravel the redundancies and cherry pick from here --- components/simple-transcription/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/simple-transcription/index.js b/components/simple-transcription/index.js index 7fe97211..55295dd2 100644 --- a/components/simple-transcription/index.js +++ b/components/simple-transcription/index.js @@ -981,9 +981,10 @@ export default class SimpleTranscriptionInterface extends HTMLElement { this._iframeOrigin ) } - - // New consolidated context payload for pane tools. - // this.#sendTPENContextToTool(iframe.contentWindow) + else { + // New consolidated context payload for pane tools. + this.#sendTPENContextToTool(iframe.contentWindow) + } iframe.contentWindow?.postMessage( { From 5042b87dddbfed3bc222bc268ab31c49437eedf6 Mon Sep 17 00:00:00 2001 From: Bryan Haberberger Date: Mon, 20 Apr 2026 16:24:39 -0500 Subject: [PATCH 4/6] synced --- components/simple-transcription/index.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/components/simple-transcription/index.js b/components/simple-transcription/index.js index 55295dd2..d331f0b2 100644 --- a/components/simple-transcription/index.js +++ b/components/simple-transcription/index.js @@ -856,11 +856,15 @@ export default class SimpleTranscriptionInterface extends HTMLElement { return { type: 'TPEN_CONTEXT', projectId: TPEN.activeProject?.id ?? TPEN.activeProject?._id ?? TPEN.screen?.projectInQuery ?? null, + projectLabel: TPEN.activeProject?.label ?? TPEN.activeProject?.title ?? null, manifest: manifestUri, manifestUri, canvasManifestUri: manifestUri, pageId: this.fetchCurrentPageId() ?? this.#page?.id ?? currentPageId ?? null, + pageLabel: projectPage?.label ?? this.#page?.label ?? null, canvasId: this.#getCanvasId(), + canvasWidth: this.#canvas?.width ?? null, + canvasHeight: this.#canvas?.height ?? null, imageUrl: this.#getCanvasImageUrl(), currentLineId: this.#getCurrentLineId(), columns: projectPage?.columns || [] @@ -969,22 +973,7 @@ export default class SimpleTranscriptionInterface extends HTMLElement { ?.flatMap(layer => layer.pages || []) .find(p => p.id.split('/').pop() === currentPageId) - // Forward auth to TPEN-Prompts only; other tools do not receive the token. - if (tool.toolName === 'tpen-prompts') { - iframe.contentWindow?.postMessage( - { - type: "AUTH_TOKEN", - token: this.userToken ?? null, - projectID: TPEN.screen?.projectInQuery ?? null, - pageID: currentPageId ?? null - }, - this._iframeOrigin - ) - } - else { - // New consolidated context payload for pane tools. - this.#sendTPENContextToTool(iframe.contentWindow) - } + this.#sendTPENContextToTool(iframe.contentWindow) iframe.contentWindow?.postMessage( { From 7a8a392a500edf3d4d9f6c9314d813a8314f080f Mon Sep 17 00:00:00 2001 From: Bryan Haberberger Date: Mon, 20 Apr 2026 16:45:00 -0500 Subject: [PATCH 5/6] undiff --- interfaces/transcription/index.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/interfaces/transcription/index.js b/interfaces/transcription/index.js index 74cbb702..d9b9609b 100644 --- a/interfaces/transcription/index.js +++ b/interfaces/transcription/index.js @@ -402,19 +402,6 @@ export default class TranscriptionInterface extends HTMLElement { this._iframeOrigin = new URL(tool.url).origin iframe.addEventListener('load', () => { - // Forward auth to TPEN-Prompts only; other tools do not receive the token. - if (tool.toolName === 'tpen-prompts') { - iframe.contentWindow?.postMessage( - { - type: "AUTH_TOKEN", - token: this.userToken ?? null, - projectID: TPEN.screen?.projectInQuery ?? null, - pageID: TPEN.screen?.pageInQuery ?? null - }, - this._iframeOrigin - ) - } - iframe.contentWindow?.postMessage( { type: "MANIFEST_CANVAS_ANNOTATIONPAGE_ANNOTATION", From 9a7d1565cbd33f40ac5cd479ea0d5d8460e00cb5 Mon Sep 17 00:00:00 2001 From: Bryan Haberberger Date: Mon, 20 Apr 2026 16:48:03 -0500 Subject: [PATCH 6/6] extra --- components/simple-transcription/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/simple-transcription/index.js b/components/simple-transcription/index.js index d331f0b2..b248a0c8 100644 --- a/components/simple-transcription/index.js +++ b/components/simple-transcription/index.js @@ -856,7 +856,7 @@ export default class SimpleTranscriptionInterface extends HTMLElement { return { type: 'TPEN_CONTEXT', projectId: TPEN.activeProject?.id ?? TPEN.activeProject?._id ?? TPEN.screen?.projectInQuery ?? null, - projectLabel: TPEN.activeProject?.label ?? TPEN.activeProject?.title ?? null, + projectLabel: TPEN.activeProject?.label ?? null, manifest: manifestUri, manifestUri, canvasManifestUri: manifestUri,