-
Notifications
You must be signed in to change notification settings - Fork 0
/
mathquill_template1.html
71 lines (68 loc) · 2.45 KB
/
mathquill_template1.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MathQuill in PyQt6</title>
<link rel="stylesheet" href="resources/mathquill.min.css" />
<style>
body, html {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden; /* Prevent scrollbars */
display: flex;
justify-content: left;
align-items: center;
}
#mathquill-input {
width: 100%;
border: 0px solid #ccc; /* Make default border thicker */
min-height: 50px; /* Ensure initial and minimum height */
display: flex;
align-items: center;
justify-content: flex-start; /* Align content to the left */
padding: 10px;
}
#mathquill-input:focus {
border-color: #ffa500; /* Orange border when focused */
border-width: 2px; /* Make border thicker when focused */
}
#latex-output {
display: none;
}
</style>
</head>
<body>
<div id="mathquill-input" class="mathquill-editable"></div>
<div id="latex-output">LaTeX Output: <span id="latex"></span></div>
<script src="resources/jquery-3.6.0.min.js"></script>
<script src="resources/mathquill.min.js"></script>
<script src="resources/qwebchannel.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var MQ = MathQuill.getInterface(2);
var mathField = MQ.MathField(document.getElementById('mathquill-input'), {
spaceBehavesLikeTab: true,
handlers: {
edit: function() {
var latex = mathField.latex();
document.getElementById('latex').textContent = latex;
if (window.bridge) {
window.bridge.latexUpdated(latex);
}
}
}
});
// Setup QWebChannel communication
new QWebChannel(qt.webChannelTransport, function(channel) {
window.bridge = channel.objects.bridge;
});
// Function to update MathQuill content from PyQt6
window.updateMathQuill = function(latex) {
mathField.latex(latex);
};
});
</script>
</body>
</html>