@zikojs/notebook 0.7.0 → 0.7.2
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/package.json +1 -1
- package/src/components.js +1 -1
- package/src/index.css +66 -68
- package/src/index.d.ts +4 -1
- package/src/main.js +0 -1
- package/src/notebook.js +10 -3
package/package.json
CHANGED
package/src/components.js
CHANGED
|
@@ -34,7 +34,7 @@ export function Header({ store, actions }) {
|
|
|
34
34
|
const statusBadge = span({ class: "status-badge" }, Loader2(), span('Loading ...')).element;
|
|
35
35
|
const runAllBtn = Button({ class: "btn-primary", onclick: actions.runAll }, PlayForward(), "Run All");
|
|
36
36
|
const clearBtn = Button({ onclick: actions.clearOutputs }, Eraser(), "Clear Outputs");
|
|
37
|
-
const addCodeBtn = Button({ onclick: actions.addCode },
|
|
37
|
+
const addCodeBtn = Button({ onclick: actions.addCode }, Plus(), "Add Code");
|
|
38
38
|
const addMdBtn = Button({ onclick: actions.addMarkdown }, FileText(), "Add Markdown");
|
|
39
39
|
const deleteActiveBtn = Button({ onclick: actions.deleteActive }, Trash2(), "Delete Active");
|
|
40
40
|
const exportBtn = Button({ onclick: actions.exportData }, Download(), "Export Data");
|
package/src/index.css
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
.ziko-notebook {
|
|
2
2
|
--primary: #0284c7;
|
|
3
3
|
--primary-hover: #0369a1;
|
|
4
4
|
--border-color: #e2e8f0;
|
|
5
5
|
--prompt-in: #303f9f;
|
|
6
6
|
--prompt-out: #d62728;
|
|
7
7
|
--bg-editor: #f8fafc;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
* {
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
margin: 0;
|
|
13
|
-
padding: 0;
|
|
14
|
-
}
|
|
15
8
|
|
|
16
|
-
body {
|
|
17
9
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
18
|
-
background: #ffffff;
|
|
19
10
|
color: #1e293b;
|
|
20
11
|
}
|
|
21
12
|
|
|
22
13
|
/* --- HEADER & TOOLBAR --- */
|
|
23
14
|
|
|
24
|
-
.header {
|
|
15
|
+
.ziko-notebook .header {
|
|
25
16
|
border-bottom: 1px solid var(--border-color);
|
|
26
17
|
background: #ffffff;
|
|
27
18
|
padding: 10px 16px;
|
|
@@ -37,7 +28,7 @@ body {
|
|
|
37
28
|
width: 100%;
|
|
38
29
|
}
|
|
39
30
|
|
|
40
|
-
.brand {
|
|
31
|
+
.ziko-notebook .brand {
|
|
41
32
|
font-weight: 600;
|
|
42
33
|
font-size: 16px;
|
|
43
34
|
color: #0f172a;
|
|
@@ -47,7 +38,7 @@ body {
|
|
|
47
38
|
flex-shrink: 0;
|
|
48
39
|
}
|
|
49
40
|
|
|
50
|
-
.toolbar {
|
|
41
|
+
.ziko-notebook .toolbar {
|
|
51
42
|
display: flex;
|
|
52
43
|
gap: 6px;
|
|
53
44
|
align-items: center;
|
|
@@ -55,10 +46,10 @@ body {
|
|
|
55
46
|
max-width: 100%;
|
|
56
47
|
}
|
|
57
48
|
|
|
58
|
-
.status-badge {
|
|
49
|
+
.ziko-notebook .status-badge {
|
|
59
50
|
font-size: 12px;
|
|
60
51
|
font-weight: 500;
|
|
61
|
-
color:
|
|
52
|
+
color: var(--primary);
|
|
62
53
|
background: #e0f2fe;
|
|
63
54
|
padding: 4px 8px;
|
|
64
55
|
border-radius: 4px;
|
|
@@ -69,7 +60,7 @@ body {
|
|
|
69
60
|
|
|
70
61
|
/* --- NOTEBOOK & CELLS --- */
|
|
71
62
|
|
|
72
|
-
.notebook {
|
|
63
|
+
.ziko-notebook .notebook {
|
|
73
64
|
max-width: 900px;
|
|
74
65
|
margin: 16px auto;
|
|
75
66
|
padding: 0 8px;
|
|
@@ -78,7 +69,7 @@ body {
|
|
|
78
69
|
gap: 12px;
|
|
79
70
|
}
|
|
80
71
|
|
|
81
|
-
.cell {
|
|
72
|
+
.ziko-notebook .cell {
|
|
82
73
|
display: flex;
|
|
83
74
|
flex-direction: column;
|
|
84
75
|
border: 1px solid var(--border-color);
|
|
@@ -91,12 +82,12 @@ body {
|
|
|
91
82
|
position: relative;
|
|
92
83
|
}
|
|
93
84
|
|
|
94
|
-
.cell.active {
|
|
85
|
+
.ziko-notebook .cell.active {
|
|
95
86
|
border-left-color: var(--primary);
|
|
96
87
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
|
97
88
|
}
|
|
98
89
|
|
|
99
|
-
.cell-input-grid {
|
|
90
|
+
.ziko-notebook .cell-input-grid {
|
|
100
91
|
display: grid;
|
|
101
92
|
grid-template-columns: 56px 1fr auto;
|
|
102
93
|
align-items: flex-start;
|
|
@@ -104,7 +95,7 @@ body {
|
|
|
104
95
|
width: 100%;
|
|
105
96
|
}
|
|
106
97
|
|
|
107
|
-
.cell-output-grid {
|
|
98
|
+
.ziko-notebook .cell-output-grid {
|
|
108
99
|
display: grid;
|
|
109
100
|
grid-template-columns: 56px 1fr;
|
|
110
101
|
align-items: flex-start;
|
|
@@ -112,7 +103,7 @@ body {
|
|
|
112
103
|
width: 100%;
|
|
113
104
|
}
|
|
114
105
|
|
|
115
|
-
.prompt {
|
|
106
|
+
.ziko-notebook .prompt {
|
|
116
107
|
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
117
108
|
font-size: 11px;
|
|
118
109
|
color: var(--prompt-in);
|
|
@@ -123,13 +114,13 @@ body {
|
|
|
123
114
|
font-weight: 700;
|
|
124
115
|
}
|
|
125
116
|
|
|
126
|
-
.prompt.out {
|
|
117
|
+
.ziko-notebook .prompt.out {
|
|
127
118
|
color: var(--prompt-out);
|
|
128
119
|
}
|
|
129
120
|
|
|
130
|
-
/* ---
|
|
121
|
+
/* --- INPUT --- */
|
|
131
122
|
|
|
132
|
-
.input-wrapper {
|
|
123
|
+
.ziko-notebook .input-wrapper {
|
|
133
124
|
border: 1px solid var(--border-color);
|
|
134
125
|
border-radius: 4px;
|
|
135
126
|
background: var(--bg-editor);
|
|
@@ -138,11 +129,17 @@ body {
|
|
|
138
129
|
transition: border-color 0.15s ease;
|
|
139
130
|
}
|
|
140
131
|
|
|
141
|
-
.cell.active .input-wrapper {
|
|
132
|
+
.ziko-notebook .cell.active .input-wrapper {
|
|
142
133
|
border-color: #cbd5e1;
|
|
143
134
|
}
|
|
144
135
|
|
|
145
|
-
|
|
136
|
+
/*
|
|
137
|
+
* CodeMirror is an external component.
|
|
138
|
+
*
|
|
139
|
+
* Don't globally style .CodeMirror.
|
|
140
|
+
* Scope only the CodeMirror instances owned by the notebook.
|
|
141
|
+
*/
|
|
142
|
+
.ziko-notebook .input-wrapper .CodeMirror {
|
|
146
143
|
font-family: "Fira Code", SFMono-Regular, Consolas, monospace;
|
|
147
144
|
font-size: 13px;
|
|
148
145
|
height: auto !important;
|
|
@@ -150,17 +147,16 @@ body {
|
|
|
150
147
|
border-radius: 4px;
|
|
151
148
|
}
|
|
152
149
|
|
|
153
|
-
.CodeMirror-scroll {
|
|
154
|
-
/* Overflow reset ensures height auto-fits custom minLines properly */
|
|
150
|
+
.ziko-notebook .input-wrapper .CodeMirror-scroll {
|
|
155
151
|
overflow-y: hidden !important;
|
|
156
152
|
overflow-x: auto !important;
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
.CodeMirror-activeline-background {
|
|
155
|
+
.ziko-notebook .input-wrapper .CodeMirror-activeline-background {
|
|
160
156
|
background: rgba(2, 132, 199, 0.05);
|
|
161
157
|
}
|
|
162
158
|
|
|
163
|
-
.cell-controls {
|
|
159
|
+
.ziko-notebook .cell-controls {
|
|
164
160
|
display: flex;
|
|
165
161
|
align-items: center;
|
|
166
162
|
gap: 4px;
|
|
@@ -169,19 +165,19 @@ body {
|
|
|
169
165
|
max-width: 120px;
|
|
170
166
|
}
|
|
171
167
|
|
|
172
|
-
/* ---
|
|
168
|
+
/* --- OUTPUT --- */
|
|
173
169
|
|
|
174
|
-
.output-wrapper {
|
|
170
|
+
.ziko-notebook .output-wrapper {
|
|
175
171
|
width: 100%;
|
|
176
172
|
padding: 4px 0;
|
|
177
173
|
}
|
|
178
174
|
|
|
179
|
-
.output-area {
|
|
175
|
+
.ziko-notebook .output-area {
|
|
180
176
|
font-size: 14px;
|
|
181
177
|
word-break: break-word;
|
|
182
178
|
}
|
|
183
179
|
|
|
184
|
-
.error-output {
|
|
180
|
+
.ziko-notebook .error-output {
|
|
185
181
|
color: #e11d48;
|
|
186
182
|
font-family: ui-monospace, SFMono-Regular, monospace;
|
|
187
183
|
white-space: pre-wrap;
|
|
@@ -192,7 +188,9 @@ body {
|
|
|
192
188
|
border: 1px solid #fecdd3;
|
|
193
189
|
}
|
|
194
190
|
|
|
195
|
-
|
|
191
|
+
/* --- MARKDOWN --- */
|
|
192
|
+
|
|
193
|
+
.ziko-notebook .markdown-rendered-cell {
|
|
196
194
|
grid-column: 1 / 3;
|
|
197
195
|
padding: 8px 12px;
|
|
198
196
|
cursor: pointer;
|
|
@@ -202,56 +200,56 @@ body {
|
|
|
202
200
|
transition: background 0.15s ease, border-color 0.15s ease;
|
|
203
201
|
}
|
|
204
202
|
|
|
205
|
-
.markdown-rendered-cell:hover {
|
|
203
|
+
.ziko-notebook .markdown-rendered-cell:hover {
|
|
206
204
|
background: #f8fafc;
|
|
207
205
|
border-color: #cbd5e1;
|
|
208
206
|
}
|
|
209
207
|
|
|
210
|
-
.cell.active .markdown-rendered-cell {
|
|
208
|
+
.ziko-notebook .cell.active .markdown-rendered-cell {
|
|
211
209
|
border-color: #94a3b8;
|
|
212
210
|
}
|
|
213
211
|
|
|
214
|
-
.markdown-body {
|
|
212
|
+
.ziko-notebook .markdown-body {
|
|
215
213
|
line-height: 1.6;
|
|
216
214
|
}
|
|
217
215
|
|
|
218
|
-
.markdown-body h1,
|
|
219
|
-
.markdown-body h2,
|
|
220
|
-
.markdown-body h3 {
|
|
216
|
+
.ziko-notebook .markdown-body h1,
|
|
217
|
+
.ziko-notebook .markdown-body h2,
|
|
218
|
+
.ziko-notebook .markdown-body h3 {
|
|
221
219
|
margin-top: 8px;
|
|
222
220
|
margin-bottom: 8px;
|
|
223
221
|
font-weight: 600;
|
|
224
222
|
}
|
|
225
223
|
|
|
226
|
-
.markdown-body h1 {
|
|
224
|
+
.ziko-notebook .markdown-body h1 {
|
|
227
225
|
font-size: 1.5em;
|
|
228
226
|
border-bottom: 1px solid var(--border-color);
|
|
229
227
|
padding-bottom: 4px;
|
|
230
228
|
}
|
|
231
229
|
|
|
232
|
-
.markdown-body h2 {
|
|
230
|
+
.ziko-notebook .markdown-body h2 {
|
|
233
231
|
font-size: 1.25em;
|
|
234
232
|
}
|
|
235
233
|
|
|
236
|
-
.markdown-body h3 {
|
|
234
|
+
.ziko-notebook .markdown-body h3 {
|
|
237
235
|
font-size: 1.1em;
|
|
238
236
|
}
|
|
239
237
|
|
|
240
|
-
.markdown-body p {
|
|
238
|
+
.ziko-notebook .markdown-body p {
|
|
241
239
|
margin-bottom: 8px;
|
|
242
240
|
}
|
|
243
241
|
|
|
244
|
-
.markdown-body p:last-child {
|
|
242
|
+
.ziko-notebook .markdown-body p:last-child {
|
|
245
243
|
margin-bottom: 0;
|
|
246
244
|
}
|
|
247
245
|
|
|
248
|
-
.markdown-body ul,
|
|
249
|
-
.markdown-body ol {
|
|
246
|
+
.ziko-notebook .markdown-body ul,
|
|
247
|
+
.ziko-notebook .markdown-body ol {
|
|
250
248
|
padding-left: 20px;
|
|
251
249
|
margin-bottom: 8px;
|
|
252
250
|
}
|
|
253
251
|
|
|
254
|
-
.markdown-body code {
|
|
252
|
+
.ziko-notebook .markdown-body code {
|
|
255
253
|
background: #f1f5f9;
|
|
256
254
|
padding: 2px 4px;
|
|
257
255
|
border-radius: 4px;
|
|
@@ -259,7 +257,7 @@ body {
|
|
|
259
257
|
font-size: 0.9em;
|
|
260
258
|
}
|
|
261
259
|
|
|
262
|
-
.markdown-body pre {
|
|
260
|
+
.ziko-notebook .markdown-body pre {
|
|
263
261
|
background: #1e293b;
|
|
264
262
|
color: #f8fafc;
|
|
265
263
|
padding: 10px;
|
|
@@ -268,22 +266,22 @@ body {
|
|
|
268
266
|
margin: 8px 0;
|
|
269
267
|
}
|
|
270
268
|
|
|
271
|
-
.markdown-body pre code {
|
|
269
|
+
.ziko-notebook .markdown-body pre code {
|
|
272
270
|
background: transparent;
|
|
273
271
|
color: inherit;
|
|
274
272
|
padding: 0;
|
|
275
273
|
}
|
|
276
274
|
|
|
277
|
-
.markdown-body blockquote {
|
|
275
|
+
.ziko-notebook .markdown-body blockquote {
|
|
278
276
|
border-left: 4px solid var(--primary);
|
|
279
277
|
padding-left: 10px;
|
|
280
278
|
color: #64748b;
|
|
281
279
|
margin: 8px 0;
|
|
282
280
|
}
|
|
283
281
|
|
|
284
|
-
/* --- BUTTONS
|
|
282
|
+
/* --- BUTTONS --- */
|
|
285
283
|
|
|
286
|
-
.btn {
|
|
284
|
+
.ziko-notebook .btn {
|
|
287
285
|
display: inline-flex;
|
|
288
286
|
align-items: center;
|
|
289
287
|
justify-content: center;
|
|
@@ -301,60 +299,60 @@ body {
|
|
|
301
299
|
transition: background 0.12s ease, border-color 0.12s ease;
|
|
302
300
|
}
|
|
303
301
|
|
|
304
|
-
.btn:hover {
|
|
302
|
+
.ziko-notebook .btn:hover {
|
|
305
303
|
background: #f1f5f9;
|
|
306
304
|
}
|
|
307
305
|
|
|
308
|
-
.btn:disabled {
|
|
306
|
+
.ziko-notebook .btn:disabled {
|
|
309
307
|
opacity: 0.5;
|
|
310
308
|
cursor: not-allowed;
|
|
311
309
|
}
|
|
312
310
|
|
|
313
|
-
.btn-icon {
|
|
311
|
+
.ziko-notebook .btn-icon {
|
|
314
312
|
padding: 6px;
|
|
315
313
|
border-radius: 4px;
|
|
316
314
|
}
|
|
317
315
|
|
|
318
|
-
.btn-primary {
|
|
316
|
+
.ziko-notebook .btn-primary {
|
|
319
317
|
background: var(--primary);
|
|
320
318
|
color: #ffffff;
|
|
321
319
|
border-color: var(--primary);
|
|
322
320
|
}
|
|
323
321
|
|
|
324
|
-
.btn-primary:hover {
|
|
322
|
+
.ziko-notebook .btn-primary:hover {
|
|
325
323
|
background: var(--primary-hover);
|
|
326
324
|
border-color: var(--primary-hover);
|
|
327
325
|
}
|
|
328
326
|
|
|
329
|
-
.btn-active {
|
|
327
|
+
.ziko-notebook .btn-active {
|
|
330
328
|
background: #e2e8f0;
|
|
331
329
|
border-color: #cbd5e1;
|
|
332
330
|
}
|
|
333
331
|
|
|
334
|
-
.icon {
|
|
332
|
+
.ziko-notebook .icon {
|
|
335
333
|
width: 14px;
|
|
336
334
|
height: 14px;
|
|
337
335
|
stroke-width: 2;
|
|
338
336
|
}
|
|
339
337
|
|
|
340
|
-
/* --- MOBILE
|
|
338
|
+
/* --- MOBILE --- */
|
|
341
339
|
|
|
342
340
|
@media (max-width: 640px) {
|
|
343
|
-
.header {
|
|
341
|
+
.ziko-notebook .header {
|
|
344
342
|
padding: 8px 12px;
|
|
345
343
|
}
|
|
346
344
|
|
|
347
|
-
.toolbar {
|
|
345
|
+
.ziko-notebook .toolbar {
|
|
348
346
|
width: 100%;
|
|
349
347
|
justify-content: flex-start;
|
|
350
348
|
}
|
|
351
349
|
|
|
352
|
-
.cell-input-grid {
|
|
350
|
+
.ziko-notebook .cell-input-grid {
|
|
353
351
|
grid-template-columns: 42px 1fr;
|
|
354
352
|
grid-template-rows: auto auto;
|
|
355
353
|
}
|
|
356
354
|
|
|
357
|
-
.cell-controls {
|
|
355
|
+
.ziko-notebook .cell-controls {
|
|
358
356
|
grid-column: 1 / -1;
|
|
359
357
|
justify-content: flex-end;
|
|
360
358
|
border-bottom: 1px solid #f1f5f9;
|
|
@@ -363,11 +361,11 @@ body {
|
|
|
363
361
|
max-width: 100%;
|
|
364
362
|
}
|
|
365
363
|
|
|
366
|
-
.cell-output-grid {
|
|
364
|
+
.ziko-notebook .cell-output-grid {
|
|
367
365
|
grid-template-columns: 42px 1fr;
|
|
368
366
|
}
|
|
369
367
|
|
|
370
|
-
.prompt {
|
|
368
|
+
.ziko-notebook .prompt {
|
|
371
369
|
font-size: 10px;
|
|
372
370
|
padding-top: 6px;
|
|
373
371
|
}
|
package/src/index.d.ts
CHANGED
package/src/main.js
CHANGED
package/src/notebook.js
CHANGED
|
@@ -2,6 +2,7 @@ import { NotebookStore } from "./store.js";
|
|
|
2
2
|
import { Header, CellItem, MarkdownView } from "./components.js";
|
|
3
3
|
import { evaluateCodeAsync } from "./transform.js";
|
|
4
4
|
import { tags, UIElement } from "ziko/dom";
|
|
5
|
+
import { call_with_optional_props } from 'ziko/dom/internal-utils'
|
|
5
6
|
|
|
6
7
|
export class UINotebook extends UIElement{
|
|
7
8
|
constructor({
|
|
@@ -11,9 +12,11 @@ export class UINotebook extends UIElement{
|
|
|
11
12
|
codeMirrorConfig = {},
|
|
12
13
|
codeMirrorPlugins = [],
|
|
13
14
|
minLines = 3,
|
|
14
|
-
maxCells = Infinity
|
|
15
|
+
maxCells = Infinity,
|
|
16
|
+
showHeader = false
|
|
15
17
|
} = {}) {
|
|
16
18
|
super({ element : 'div'})
|
|
19
|
+
this.setAttr({class : 'ziko-notebook'})
|
|
17
20
|
this.id = crypto.randomUUID ? crypto.randomUUID() : 'nb_' + Math.random().toString(36).substring(2, 9);
|
|
18
21
|
|
|
19
22
|
if (!window.__notebook_scope_map) {
|
|
@@ -28,7 +31,7 @@ export class UINotebook extends UIElement{
|
|
|
28
31
|
this.maxCells = maxCells;
|
|
29
32
|
|
|
30
33
|
const startingCells = maxCells !== Infinity ? initialCells.slice(0, maxCells) : initialCells;
|
|
31
|
-
|
|
34
|
+
let nextCellId = startingCells.length ? Math.max(...startingCells.map(c => c.id || 0)) + 1 : 1;
|
|
32
35
|
|
|
33
36
|
this.store = new NotebookStore({
|
|
34
37
|
cells: startingCells.map(cell => ({
|
|
@@ -71,6 +74,8 @@ export class UINotebook extends UIElement{
|
|
|
71
74
|
}
|
|
72
75
|
});
|
|
73
76
|
|
|
77
|
+
if(!showHeader) this.header.style.display = 'none'
|
|
78
|
+
|
|
74
79
|
this.append(
|
|
75
80
|
this.header,
|
|
76
81
|
tags.div({ class: "notebook" },
|
|
@@ -341,4 +346,6 @@ export class UINotebook extends UIElement{
|
|
|
341
346
|
return exportedCell;
|
|
342
347
|
});
|
|
343
348
|
}
|
|
344
|
-
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export const Notebook = call_with_optional_props(UINotebook)
|