mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-01-11 08:30:02 +00:00
markdown: using iframe
This commit is contained in:
parent
1e9b164c55
commit
34aba0443e
@ -4,13 +4,16 @@ import { PLATFORMS } from "../common/emu";
|
||||
import { Platform } from "../common/baseplatform";
|
||||
|
||||
class MarkdownPlatform implements Platform {
|
||||
mainElement;
|
||||
htmlDiv;
|
||||
mainElement : HTMLElement;
|
||||
iframe : HTMLIFrameElement;
|
||||
|
||||
constructor(mainElement:HTMLElement) {
|
||||
this.mainElement = mainElement;
|
||||
this.htmlDiv = $('<div class="markdown">').appendTo(mainElement);
|
||||
$(mainElement).css('overflowY', 'auto');
|
||||
this.iframe = $('<iframe sandbox seamless src="javascript:void(0);" width="100%" height="100%"/>').appendTo(mainElement)[0] as HTMLIFrameElement;
|
||||
//this.iframe = $('<iframe sandbox src="res/markdown-iframe.html" width="100%" height="100%"/>').appendTo(mainElement)[0] as HTMLIFrameElement;
|
||||
this.iframe.style.backgroundColor = 'white';
|
||||
mainElement.classList.add("vertical-scroll"); //100% height
|
||||
mainElement.style.overflowY = 'auto';
|
||||
}
|
||||
start() {
|
||||
}
|
||||
@ -20,8 +23,15 @@ class MarkdownPlatform implements Platform {
|
||||
}
|
||||
resume() {
|
||||
}
|
||||
loadROM(title, data) {
|
||||
this.htmlDiv.html(data);
|
||||
loadROM(title, data:string) {
|
||||
// have to do this b/c sandboxed without same origin
|
||||
// TODO: preserve scroll position
|
||||
if (this.iframe.srcdoc)
|
||||
this.iframe.srcdoc = data;
|
||||
else
|
||||
this.iframe.src = "data:text/html;charset=utf-8," + escape(data);
|
||||
//this.iframe.contentWindow.postMessage({body:data}, "*");
|
||||
//$(this.iframe).contents().find('body').html(data);
|
||||
}
|
||||
isRunning() {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user