hyperbook 0.90.0 → 0.91.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/code-input/auto-close-brackets.min.js +1 -1
- package/dist/assets/code-input/code-input.min.css +1 -1
- package/dist/assets/code-input/code-input.min.js +12 -1
- package/dist/assets/code-input/indent.min.js +1 -1
- package/dist/assets/directive-excalidraw/hyperbook-excalidraw.umd.js +1 -1
- package/dist/assets/directive-onlineide/style.css +8 -0
- package/dist/assets/directive-p5/client.js +113 -0
- package/dist/assets/directive-p5/style.css +67 -3
- package/dist/assets/directive-pyide/client.js +1226 -146
- package/dist/assets/directive-pyide/style.css +183 -6
- package/dist/assets/directive-sqlide/style.css +8 -0
- package/dist/assets/directive-typst/client.js +154 -14
- package/dist/assets/directive-typst/style.css +65 -4
- package/dist/assets/directive-webide/client.js +114 -0
- package/dist/assets/directive-webide/style.css +61 -3
- package/dist/index.js +252 -54
- package/dist/locales/de.json +12 -0
- package/dist/locales/en.json +12 -0
- package/package.json +3 -3
- package/dist/assets/directive-pyide/webworker.js +0 -86
|
@@ -16,7 +16,107 @@ hyperbook.webide = (function () {
|
|
|
16
16
|
]),
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
+
function setupSplitter(elem, container, editorContainer, splitter) {
|
|
20
|
+
if (!container || !editorContainer || !splitter) return;
|
|
21
|
+
|
|
22
|
+
const minPanelSize = 120;
|
|
23
|
+
|
|
24
|
+
const getIsHorizontal = () =>
|
|
25
|
+
getComputedStyle(elem).flexDirection.startsWith("row");
|
|
26
|
+
|
|
27
|
+
const applySplitSize = (rawSize, isHorizontal) => {
|
|
28
|
+
const total = isHorizontal ? elem.clientWidth : elem.clientHeight;
|
|
29
|
+
const splitterSize = isHorizontal ? splitter.offsetWidth : splitter.offsetHeight;
|
|
30
|
+
const maxSize = Math.max(minPanelSize, total - splitterSize - minPanelSize);
|
|
31
|
+
const clamped = Math.max(minPanelSize, Math.min(rawSize, maxSize));
|
|
32
|
+
container.style.flex = `0 0 ${clamped}px`;
|
|
33
|
+
return clamped;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const applyStoredSplitSize = () => {
|
|
37
|
+
const isHorizontal = getIsHorizontal();
|
|
38
|
+
elem.classList.toggle("split-horizontal", isHorizontal);
|
|
39
|
+
elem.classList.toggle("split-vertical", !isHorizontal);
|
|
40
|
+
const key = isHorizontal ? "splitHorizontal" : "splitVertical";
|
|
41
|
+
const rawStored = Number(elem.dataset[key]);
|
|
42
|
+
if (!Number.isFinite(rawStored) || rawStored <= 0) {
|
|
43
|
+
container.style.flex = "";
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
applySplitSize(rawStored, isHorizontal);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
applyStoredSplitSize();
|
|
50
|
+
|
|
51
|
+
splitter.addEventListener("pointerdown", (event) => {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
splitter.setPointerCapture(event.pointerId);
|
|
54
|
+
|
|
55
|
+
const isHorizontal = getIsHorizontal();
|
|
56
|
+
const key = isHorizontal ? "splitHorizontal" : "splitVertical";
|
|
57
|
+
const startPointer = isHorizontal ? event.clientX : event.clientY;
|
|
58
|
+
const startSize = isHorizontal
|
|
59
|
+
? container.getBoundingClientRect().width
|
|
60
|
+
: container.getBoundingClientRect().height;
|
|
61
|
+
|
|
62
|
+
elem.classList.add("resizing");
|
|
63
|
+
|
|
64
|
+
const onPointerMove = (moveEvent) => {
|
|
65
|
+
const pointer = isHorizontal ? moveEvent.clientX : moveEvent.clientY;
|
|
66
|
+
const delta = pointer - startPointer;
|
|
67
|
+
const size = applySplitSize(startSize + delta, isHorizontal);
|
|
68
|
+
elem.dataset[key] = String(Math.round(size));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const onPointerUp = () => {
|
|
72
|
+
elem.classList.remove("resizing");
|
|
73
|
+
splitter.removeEventListener("pointermove", onPointerMove);
|
|
74
|
+
splitter.removeEventListener("pointerup", onPointerUp);
|
|
75
|
+
splitter.removeEventListener("pointercancel", onPointerUp);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
splitter.addEventListener("pointermove", onPointerMove);
|
|
79
|
+
splitter.addEventListener("pointerup", onPointerUp);
|
|
80
|
+
splitter.addEventListener("pointercancel", onPointerUp);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
window.addEventListener("resize", applyStoredSplitSize);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const updateFullscreenButtonState = (elem, button) => {
|
|
87
|
+
if (!elem || !button) return;
|
|
88
|
+
const isFullscreen = document.fullscreenElement === elem;
|
|
89
|
+
const label = hyperbook.i18n.get("ide-fullscreen-enter");
|
|
90
|
+
button.textContent = "⛶";
|
|
91
|
+
button.title = label;
|
|
92
|
+
button.setAttribute("aria-label", label);
|
|
93
|
+
button.classList.toggle("active", isFullscreen);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const toggleFullscreen = async (elem) => {
|
|
97
|
+
if (!elem) return;
|
|
98
|
+
if (document.fullscreenElement === elem) {
|
|
99
|
+
await document.exitFullscreen();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
await elem.requestFullscreen();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const syncFullscreenButtons = () => {
|
|
106
|
+
const elems = document.querySelectorAll(".directive-webide");
|
|
107
|
+
elems.forEach((elem) => {
|
|
108
|
+
const fullscreen = elem.querySelector("button.fullscreen");
|
|
109
|
+
updateFullscreenButtonState(elem, fullscreen);
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
19
113
|
function initElement(elem) {
|
|
114
|
+
if (elem.getAttribute("data-webide-initialized") === "true") return;
|
|
115
|
+
elem.setAttribute("data-webide-initialized", "true");
|
|
116
|
+
|
|
117
|
+
const container = elem.querySelector(".container");
|
|
118
|
+
const editorContainer = elem.querySelector(".editor-container");
|
|
119
|
+
const splitter = elem.querySelector(".splitter");
|
|
20
120
|
const title = elem.getElementsByClassName("container-title")[0];
|
|
21
121
|
/** @type {HTMLTextAreaElement | null} */
|
|
22
122
|
const editorHTML = elem.querySelector(".editor.html");
|
|
@@ -38,6 +138,19 @@ hyperbook.webide = (function () {
|
|
|
38
138
|
const resetEl = elem.querySelector("button.reset");
|
|
39
139
|
/** @type {HTMLButtonElement} */
|
|
40
140
|
const downloadEl = elem.querySelector("button.download");
|
|
141
|
+
/** @type {HTMLButtonElement} */
|
|
142
|
+
const fullscreenEl = elem.querySelector("button.fullscreen");
|
|
143
|
+
|
|
144
|
+
setupSplitter(elem, container, editorContainer, splitter);
|
|
145
|
+
|
|
146
|
+
fullscreenEl?.addEventListener("click", async () => {
|
|
147
|
+
try {
|
|
148
|
+
await toggleFullscreen(elem);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error(error.message);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
updateFullscreenButtonState(elem, fullscreenEl);
|
|
41
154
|
|
|
42
155
|
resetEl?.addEventListener("click", () => {
|
|
43
156
|
if (window.confirm(hyperbook.i18n.get("webide-reset-prompt"))) {
|
|
@@ -166,6 +279,7 @@ hyperbook.webide = (function () {
|
|
|
166
279
|
document.addEventListener("DOMContentLoaded", () => {
|
|
167
280
|
init(document);
|
|
168
281
|
});
|
|
282
|
+
document.addEventListener("fullscreenchange", syncFullscreenButtons);
|
|
169
283
|
|
|
170
284
|
// Observe for new elements added to the DOM
|
|
171
285
|
const observer = new MutationObserver((mutations) => {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
overflow: hidden;
|
|
7
7
|
gap: 8px;
|
|
8
|
+
height: var(--webide-height, calc(100dvh - 80px));
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
code-input {
|
|
@@ -13,9 +14,12 @@ code-input {
|
|
|
13
14
|
|
|
14
15
|
.directive-webide .container {
|
|
15
16
|
width: 100%;
|
|
17
|
+
min-height: 120px;
|
|
18
|
+
min-width: 120px;
|
|
16
19
|
border: 1px solid var(--color-spacer);
|
|
17
20
|
border-radius: 8px;
|
|
18
21
|
overflow: hidden;
|
|
22
|
+
flex: 1 1 0;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
.directive-webide .container-title {
|
|
@@ -47,7 +51,42 @@ code-input {
|
|
|
47
51
|
width: 100%;
|
|
48
52
|
display: flex;
|
|
49
53
|
flex-direction: column;
|
|
50
|
-
height:
|
|
54
|
+
min-height: 120px;
|
|
55
|
+
min-width: 120px;
|
|
56
|
+
flex: 1 1 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.directive-webide .splitter {
|
|
60
|
+
background: var(--color-spacer);
|
|
61
|
+
border-radius: 999px;
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
touch-action: none;
|
|
64
|
+
opacity: 0.45;
|
|
65
|
+
transition: opacity 0.15s ease-in-out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.directive-webide .splitter:hover {
|
|
69
|
+
opacity: 0.65;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.directive-webide.split-vertical .splitter {
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 4px;
|
|
75
|
+
cursor: row-resize;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.directive-webide.split-horizontal .splitter {
|
|
79
|
+
width: 4px;
|
|
80
|
+
height: 100%;
|
|
81
|
+
cursor: col-resize;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.directive-webide.resizing {
|
|
85
|
+
user-select: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.directive-webide.resizing .splitter {
|
|
89
|
+
opacity: 0.75;
|
|
51
90
|
}
|
|
52
91
|
|
|
53
92
|
.directive-webide .editor {
|
|
@@ -67,6 +106,7 @@ code-input {
|
|
|
67
106
|
border-bottom: none;
|
|
68
107
|
border-bottom-left-radius: 0;
|
|
69
108
|
border-bottom-right-radius: 0;
|
|
109
|
+
overflow: hidden;
|
|
70
110
|
}
|
|
71
111
|
|
|
72
112
|
.directive-webide .buttons.bottom {
|
|
@@ -91,10 +131,17 @@ code-input {
|
|
|
91
131
|
opacity: 0.6;
|
|
92
132
|
}
|
|
93
133
|
|
|
94
|
-
.directive-webide .buttons:last-child {
|
|
134
|
+
.directive-webide .buttons button:last-child {
|
|
95
135
|
border-right: none;
|
|
96
136
|
}
|
|
97
137
|
|
|
138
|
+
.directive-webide button.fullscreen {
|
|
139
|
+
flex: 0 0 auto;
|
|
140
|
+
min-width: 42px;
|
|
141
|
+
width: 42px;
|
|
142
|
+
padding: 8px 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
98
145
|
.directive-webide button:hover {
|
|
99
146
|
background-color: var(--color-spacer);
|
|
100
147
|
}
|
|
@@ -106,10 +153,21 @@ code-input {
|
|
|
106
153
|
background-color: white;
|
|
107
154
|
}
|
|
108
155
|
|
|
156
|
+
.directive-webide:fullscreen {
|
|
157
|
+
width: 100vw;
|
|
158
|
+
height: 100dvh !important;
|
|
159
|
+
padding: 12px;
|
|
160
|
+
box-sizing: border-box;
|
|
161
|
+
background-color: var(--color-background, var(--color--background, #fff));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.directive-webide:fullscreen::backdrop {
|
|
165
|
+
background-color: var(--color-background, var(--color--background, #fff));
|
|
166
|
+
}
|
|
167
|
+
|
|
109
168
|
@media screen and (min-width: 1024px) {
|
|
110
169
|
.directive-webide:not(.standalone) {
|
|
111
170
|
flex-direction: row;
|
|
112
|
-
height: calc(100dvh - 128px);
|
|
113
171
|
.container {
|
|
114
172
|
flex: 1;
|
|
115
173
|
height: 100% !important;
|