-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorytelling.html
50 lines (47 loc) · 1.37 KB
/
storytelling.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<title>Preview</title>
<style>
#storytelling-preview eox-storytelling-editor {
display: none;
}
</style>
</head>
<body>
<eox-storytelling disable-autosave no-shadow show-editor id="storytelling-preview"></eox-storytelling>
<script type="module">
import "https://unpkg.com/@eox/storytelling/dist/eox-storytelling.js";
import "https://unpkg.com/@eox/jsonform/dist/eox-jsonform.js";
import "https://unpkg.com/@eox/map/dist/eox-map.js";
</script>
<script>
let previousMarkdown;
// Listen for messages from parent
window.onload = function() {
window.addEventListener('message', function (event) {
if (event.data && event.data.type === "SCHEMA_DATA_EDITOR_UPDATE") {
const preview = document.querySelector("#storytelling-preview")
if(preview.markdown !== event.data.detail.Story) {
previousMarkdown = event.data.detail.Story
preview.markdown = previousMarkdown
}
}
});
}
// Send messages to parent
document.querySelector('#storytelling-preview')
.addEventListener('changed', (e) => {
if(previousMarkdown !== e.detail) {
const message = {
type: 'SCHEMA_DATA_PREVIEW_UPDATE',
detail: {
Story: e.detail
}
};
window.parent.postMessage(message, "*");
}
});
</script>
</body>
</html>