* feat: add interactive mode * feat: add TeacherActions for interactive mode * fix: better prompt for ultra mode * feat: upgrade normal mode's interactive generation with 5 widget type and actions * feat: make interactive mode button clear * fix: remove unused TeacherOverlay * fix: resolve PR #458 review feedback - Revert unrelated infra changes (Dockerfile, docker-compose.yml) - Fix placeholder strings in generateWidgetContent - Rename ultraMode to interactiveMode consistently across codebase - Extract duplicated patchHtmlForIframe to shared utility - Fix widget store race condition by keying callbacks by sceneId - Fix teacher-action ID collisions by using descriptive IDs in prompt - Relax outline prompt constraints for flexibility - Optimize sidebar thumbnail with IntersectionObserver lazy loading - Add trailing newlines to modified files Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: update generateSceneActions call signatures The function signature changed to individual parameters instead of options object pattern after cherry-pick. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * style: fix prettier formatting Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: removed extra language arg * style: fix prettier formatting v2 * fix: add missing i18n keys --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
/**
|
|
* Patch embedded HTML to display correctly inside an iframe.
|
|
*
|
|
* Injects CSS that ensures proper sizing and scrolling behavior
|
|
* when HTML content is rendered via srcDoc in an iframe.
|
|
*/
|
|
export function patchHtmlForIframe(html: string): string {
|
|
const iframeCss = `<style data-iframe-patch>
|
|
html, body {
|
|
width: 100%;
|
|
height: 100%;
|
|
margin: 0;
|
|
padding: 0;
|
|
overflow-x: hidden;
|
|
overflow-y: auto;
|
|
}
|
|
/* Fix min-h-screen: in iframes 100vh is the iframe height, which is correct,
|
|
but ensure body actually fills it */
|
|
body { min-height: 100vh; }
|
|
</style>`;
|
|
|
|
// Insert right after <head> or at the start of the document
|
|
const headIdx = html.indexOf('<head>');
|
|
if (headIdx !== -1) {
|
|
const insertPos = headIdx + 6; // after <head>
|
|
return html.substring(0, insertPos) + '\n' + iframeCss + html.substring(insertPos);
|
|
}
|
|
|
|
const headWithAttrs = html.indexOf('<head ');
|
|
if (headWithAttrs !== -1) {
|
|
const closeAngle = html.indexOf('>', headWithAttrs);
|
|
if (closeAngle !== -1) {
|
|
const insertPos = closeAngle + 1;
|
|
return html.substring(0, insertPos) + '\n' + iframeCss + html.substring(insertPos);
|
|
}
|
|
}
|
|
|
|
// Fallback: prepend
|
|
return iframeCss + html;
|
|
}
|