"use strict"; //! {"require": ["ui"]} terminal.setEcho(false); terminal.setTitle("Live Markdeep Editor"); let gEditEvent = null; function back() { terminal.split([{name: "terminal"}]); if (gEditEvent) { gEditEvent.back(); } } core.register("onWindowMessage", function(event) { if (event.message.ready) { core.broadcast({title: gEditEvent.name, sync: true}); terminal.postMessageToIframe("iframe", {title: gEditEvent.name, contents: gEditEvent.value}); } else if (event.message.index) { back(); } else if (event.message.cursor) { core.broadcast({title: gEditEvent.name, user: core.user.index, cursor: event.message.cursor}); } else if (event.message.change) { core.broadcast({title: gEditEvent.name, user: core.user.index, change: event.message.change}); } else if (event.message.sync) { core.broadcast({title: event.message.title, user: core.user.index, contents: event.message.contents}); } else { gEditEvent.save(event.message.title, event.message.contents).then(function() { return core.broadcast({title: gEditEvent.name, contents: event.message.contents, sync: true}); }).then(back); } }); core.register("onMessage", function(sender, message) { if (!gEditEvent || message.title == gEditEvent.name) { terminal.postMessageToIframe("iframe", message); } }); core.register("onSessionEnd", function(process) { terminal.postMessageToIframe("iframe", {user: process.index, cursor: {}}); }); function editPage(event) { gEditEvent = event; terminal.split([{name: "terminal", type: "vertical"}]); terminal.clear(); terminal.print({iframe: `