@zikojs/notebook 0.7.2 → 0.7.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zikojs/notebook",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/src/codeEditor.js CHANGED
@@ -13,7 +13,7 @@ const languageFor = (type) =>
13
13
  type === "markdown" ? markdown() : javascript();
14
14
 
15
15
  export function createCodeEditor(app, cellData, actions) {
16
- const editorDom = div({ class: "input-wrapper" }).element;
16
+ const editorDom = div({ class: "input-wrapper" });
17
17
 
18
18
  const languageCompartment = new Compartment();
19
19
  const readOnlyCompartment = new Compartment();
@@ -143,7 +143,7 @@ export function createCodeEditor(app, cellData, actions) {
143
143
 
144
144
  view = new EditorView({
145
145
  state,
146
- parent: editorDom
146
+ parent: editorDom.element
147
147
  });
148
148
 
149
149
  const lineHeight = view.defaultLineHeight || 19;
@@ -159,7 +159,7 @@ export function createCodeEditor(app, cellData, actions) {
159
159
  };
160
160
 
161
161
  return {
162
- dom: editorDom,
162
+ dom: editorDom.element,
163
163
 
164
164
  getValue: () =>
165
165
  view
package/src/components.js CHANGED
@@ -31,7 +31,7 @@ export const Button = ({ class: className = "", title = "", disabled = false, on
31
31
  button({ class: `btn ${className}`, title, disabled, onclick }, ...children);
32
32
 
33
33
  export function Header({ store, actions }) {
34
- const statusBadge = span({ class: "status-badge" }, Loader2(), span('Loading ...')).element;
34
+ const statusBadge = span({ class: "status-badge" }, Loader2(), span('Loading ...'));
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
37
  const addCodeBtn = Button({ onclick: actions.addCode }, Plus(), "Add Code");
@@ -40,8 +40,8 @@ export function Header({ store, actions }) {
40
40
  const exportBtn = Button({ onclick: actions.exportData }, Download(), "Export Data");
41
41
 
42
42
  store.on('change:executionQueueState', (q) => {
43
- statusBadge.style.display = q.isRunning ? "inline-flex" : "none";
44
- statusBadge.lastChild.textContent = `Executing Queue (${q.currentIndex + 1}/${q.total})`;
43
+ statusBadge.style({display :q.isRunning ? "inline-flex" : "none" })
44
+ statusBadge.element.lastChild.textContent = `Executing Queue (${q.currentIndex + 1}/${q.total})`;
45
45
  [runAllBtn, clearBtn, deleteActiveBtn].forEach(b => { b.disabled = q.isRunning; });
46
46
  const maxReached = store.get('cells').length >= store.get('maxCells');
47
47
  addCodeBtn.disabled = q.isRunning || maxReached;
@@ -57,7 +57,7 @@ export function Header({ store, actions }) {
57
57
  }
58
58
 
59
59
  export function MarkdownView({ cellData, actions }) {
60
- const content = div().element;
60
+ const content = div();
61
61
 
62
62
  // Process Markdown asynchronously using Remark + Rehype
63
63
  remark()
@@ -65,10 +65,10 @@ export function MarkdownView({ cellData, actions }) {
65
65
  .use(rehypeStringify)
66
66
  .process(cellData.code || "*Empty Markdown Cell*")
67
67
  .then((file) => {
68
- content.innerHTML = String(file);
68
+ content.element.innerHTML = String(file);
69
69
  })
70
70
  .catch((err) => {
71
- content.innerHTML = `<div class="error-output">Markdown rendering error: ${err.message}</div>`;
71
+ content.element.innerHTML = `<div class="error-output">Markdown rendering error: ${err.message}</div>`;
72
72
  });
73
73
 
74
74
  const wrap = div({ class: "markdown-rendered-cell markdown-body" }, content);
@@ -150,30 +150,29 @@ export function CellControls({ cellData, store, actions }) {
150
150
  }
151
151
 
152
152
  export function CellItem({ cellData, app, store }) {
153
- const outputRef = div({ class: "output-area" }).element;
154
- if (cellData.outputNode) outputRef.appendChild(cellData.outputNode);
155
- cellData._outputRef = outputRef;
153
+ const outputRef = div({ class: "output-area" });
154
+ if (cellData.outputNode) outputRef.append(cellData.outputNode);
155
+ cellData._outputRef = outputRef.element;
156
156
 
157
157
  const actions = app._cellActions(cellData);
158
158
  cellData._actions = actions;
159
159
  cellData._editor = createCodeEditor(app, cellData, actions);
160
160
 
161
- const inPrompt = span({ class: "prompt" }).element;
162
- const outPrompt = span({ class: "prompt out" }).element;
163
- const bodySlot = div().style({ display : 'contents'}).element;
161
+ const inPrompt = span({ class: "prompt" });
162
+ const outPrompt = span({ class: "prompt out" });
163
+ const bodySlot = div().style({ display : 'contents'});
164
164
  const controlsEl = CellControls({ cellData, store, actions });
165
165
 
166
- const outputGrid = div({ class: "cell-output-grid" }, outPrompt, div({ class: "output-wrapper" }, outputRef)).element;
167
- const inputGrid = div({ class: "cell-input-grid" }, inPrompt, bodySlot, controlsEl).element;
166
+ const outputGrid = div({ class: "cell-output-grid" }, outPrompt, div({ class: "output-wrapper" }, outputRef));
167
+ const inputGrid = div({ class: "cell-input-grid" }, inPrompt, bodySlot, controlsEl);
168
168
  const root = div({ class: "cell" }, inputGrid, outputGrid);
169
169
  root.onClick(() => app.setActiveCell(cellData.id));
170
- // root.onclick = () => app.setActiveCell(cellData.id);
171
170
 
172
171
  cellData._dom = root.element;
173
- cellData._inPrompt = inPrompt;
174
- cellData._outPrompt = outPrompt;
175
- cellData._bodySlot = bodySlot;
176
- cellData._outputGrid = outputGrid;
172
+ cellData._inPrompt = inPrompt.element;
173
+ cellData._outPrompt = outPrompt.element;
174
+ cellData._bodySlot = bodySlot.element;
175
+ cellData._outputGrid = outputGrid.element;
177
176
 
178
177
  app._refreshCell(cellData);
179
178
  return root.element;
package/src/notebook.js CHANGED
@@ -4,6 +4,7 @@ import { evaluateCodeAsync } from "./transform.js";
4
4
  import { tags, UIElement } from "ziko/dom";
5
5
  import { call_with_optional_props } from 'ziko/dom/internal-utils'
6
6
 
7
+ const { div } = tags
7
8
  export class UINotebook extends UIElement{
8
9
  constructor({
9
10
  cells: initialCells = [],
@@ -13,7 +14,7 @@ export class UINotebook extends UIElement{
13
14
  codeMirrorPlugins = [],
14
15
  minLines = 3,
15
16
  maxCells = Infinity,
16
- showHeader = false
17
+ showHeader = true
17
18
  } = {}) {
18
19
  super({ element : 'div'})
19
20
  this.setAttr({class : 'ziko-notebook'})
@@ -61,7 +62,7 @@ export class UINotebook extends UIElement{
61
62
  addCodeBelow: () => this.addCell("code", "", this.store.get('activeCellId'))
62
63
  };
63
64
 
64
- this.cellsContainer = tags.div({ class: "cells-container" }).element;
65
+ this.cellsContainer = div({ class: "cells-container" }).element;
65
66
  this.header = Header({
66
67
  store: this.store,
67
68
  actions: {
@@ -78,7 +79,7 @@ export class UINotebook extends UIElement{
78
79
 
79
80
  this.append(
80
81
  this.header,
81
- tags.div({ class: "notebook" },
82
+ div({ class: "notebook" },
82
83
  this.cellsContainer)
83
84
  )
84
85
 
@@ -125,7 +126,7 @@ export class UINotebook extends UIElement{
125
126
  await evaluateCodeAsync(code, cellData._outputRef, app.importMap, scope);
126
127
  } catch (err) {
127
128
  hasError = true;
128
- tags.div({ class: "error-output" }, err.toString()).mount(cellData._outputRef)
129
+ div({ class: "error-output" }, err.toString()).mount(cellData._outputRef)
129
130
  }
130
131
 
131
132
  const counter = this.store.get('executionCounter');
@@ -133,7 +134,7 @@ export class UINotebook extends UIElement{
133
134
  cellData.execCount = counter;
134
135
  cellData.hasDomOutput = cellData._outputRef.childNodes.length > 0 || hasError;
135
136
 
136
- const container = tags.div({ class: "output-area" }).element;
137
+ const container = div({ class: "output-area" }).element;
137
138
  while (cellData._outputRef.firstChild) container.appendChild(cellData._outputRef.firstChild);
138
139
  cellData.outputNode = container;
139
140
  cellData._outputRef.appendChild(container);