-
-
Save fskpf/1568f491bc00f1ebfc0a93db310b6460 to your computer and use it in GitHub Desktop.
yEd Live postMessage GraphML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const YED_LIVE_URL = 'https://www.yworks.com/yed-live/' | |
const yedLive = window.open(YED_LIVE_URL)! | |
// wait for page load before sending the data (i.e. 'yed-live-listening') | |
const messageHandler = async (e: MessageEvent) => { | |
if ( | |
YED_LIVE_URL.startsWith(e.origin) && | |
e.data === 'yed-live-listening' | |
) { | |
// send the actual graphml | |
setTimeout(async () => { | |
yedLive.postMessage( | |
{ | |
source: 'an-external-application-name', // a hint to where it came from | |
graphml: '<?xml ...... >', | |
}, | |
YED_LIVE_URL | |
) | |
}, 500) | |
} | |
window.removeEventListener('message', messageHandler) | |
} | |
window.addEventListener('message', messageHandler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment