Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit 5f2372b

Browse files
author
steven.roulleau
committed
fix(examples): align with math jiix on MyScriptJS
1 parent a50c961 commit 5f2372b

File tree

2 files changed

+50
-16
lines changed

2 files changed

+50
-16
lines changed

src/demo-app/examples/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ <h1>Examples</h1>
8484
</div>
8585
<p><strong>Handle Jiix import</strong></p>
8686
<div class="center">
87-
<a href="non-version-specific/handle_exports.html" class="btn">
87+
<a href="v4/import_jiix_content.html" class="btn">
8888
<svg class="icn">
8989
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icn-play"></use>
9090
</svg>

src/demo-app/examples/v4/import_jiix_content.html

+49-15
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@
1818
}
1919

2020
myscript-math-web {
21-
height: calc(100% - 60px);
21+
border: 1px solid #D7DDE3;
22+
height: calc(40% - 60px);
23+
margin: 20px 0;
24+
}
25+
#editor2 {
26+
background-color: rgba(215,221,227,.3);
27+
}
28+
.btn-container {
29+
text-align: center;
2230
}
2331
</style>
2432

@@ -29,29 +37,55 @@
2937
</head>
3038

3139
<body>
32-
<nav>
33-
<span>
34-
<input type="text" class="input-field" id="importContentField" data-type="application/vnd.myscript.jiix"
35-
placeholder="e.g. \sqrt {\dfrac {2} {3}}"/>
36-
<button class="classic-btn" id="importContent">Import</button>
37-
</span>
38-
</nav>
3940
<!-- Please change applicationkey and hmackey below with those send by mail during your registration. You can re-access them by connecting to your dashboard at developer.myscript.com with your myscript account -->
40-
<myscript-math-web scheme="https"
41+
<myscript-math-web id="editor1" scheme="https"
42+
host="webdemoapi.myscript.com"
43+
applicationkey="515131ab-35fa-411c-bb4d-3917e00faf60"
44+
hmackey="54b2ca8a-6752-469d-87dd-553bb450e9ad"
45+
mimetypes='["application/x-latex", "application/vnd.myscript.jiix"]'
46+
configuration='{ "recognitionParams" : { "v4": { "export": { "jiix" : { "strokes": "true"}}}}}'
47+
touch-action="none">
48+
</myscript-math-web>
49+
<div class="btn-container">
50+
<button class="classic-btn" id="importContent">Import</button>
51+
</div>
52+
<myscript-math-web id="editor2" scheme="https"
4153
host="webdemoapi.myscript.com"
4254
applicationkey="515131ab-35fa-411c-bb4d-3917e00faf60"
4355
hmackey="54b2ca8a-6752-469d-87dd-553bb450e9ad"
4456
mimetypes='["application/x-latex", "application/vnd.myscript.jiix"]'
4557
touch-action="none">
4658
</myscript-math-web>
4759
<script>
48-
const component = document.querySelector('myscript-math-web');
49-
const importContent = document.getElementById('importContentField');
60+
const component1 = document.querySelector('#editor1');
61+
const component2 = document.querySelector('#editor2');
62+
63+
let toImport = null;
64+
65+
component1.addEventListener('exported', (event) => {
66+
const exports = event.detail.exports;
67+
if(exports && exports['application/vnd.myscript.jiix']) {
68+
toImport = exports['application/vnd.myscript.jiix'];
69+
}
70+
});
71+
72+
component2.addEventListener('exported', () => {
73+
if (toImport === null) {
74+
component2.clear();
75+
}
76+
});
5077

51-
document.getElementById('importContent').addEventListener('click', function () {
52-
component.import_(importContent.value, importContent.dataset.type);
53-
});
54-
</script>
78+
document.getElementById('importContent').addEventListener('click', () => {
79+
if(toImport !== null) {
80+
component2.clear();
81+
if(component1.editor.isEmpty) {
82+
toImport = null;
83+
} else {
84+
component2.import_(toImport, 'application/vnd.myscript.jiix');
85+
}
86+
}
87+
});
88+
</script>
5589
</body>
5690

5791
</html>

0 commit comments

Comments
 (0)