Skip to content

Instantly share code, notes, and snippets.

@fskpf
Created July 8, 2022 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fskpf/1568f491bc00f1ebfc0a93db310b6460 to your computer and use it in GitHub Desktop.
Save fskpf/1568f491bc00f1ebfc0a93db310b6460 to your computer and use it in GitHub Desktop.
yEd Live postMessage GraphML
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