@zikojs/notebook 0.15.0 → 0.15.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/src/index.css CHANGED
@@ -1,176 +1,176 @@
1
- @import '@zikojs/console/style';
2
- @import url('./components/index.css');
3
-
4
- .ziko-notebook {
5
- --primary: #0284c7;
6
- --primary-hover: #0369a1;
7
- --border-color: #e2e8f0;
8
- --prompt-in: #303f9f;
9
- --prompt-out: #d62728;
10
- --bg-editor: #f8fafc;
11
-
12
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
13
- color: #1e293b;
14
- }
15
-
16
-
17
- /* --- NOTEBOOK & CELLS --- */
18
-
19
- .ziko-notebook .notebook {
20
- max-width: 900px;
21
- margin: 16px auto;
22
- padding: 0 8px;
23
- display: flex;
24
- flex-direction: column;
25
- gap: 12px;
26
- overflow: auto;
27
- /* max-height: 100vh; */
28
- /* scrollbar-color: rebeccapurple transparent; */
29
- /* scrollbar-color: var(--prompt-in) transparent; */
30
- }
31
-
32
- .ziko-notebook .cell {
33
- display: flex;
34
- flex-direction: column;
35
- border: 1px solid var(--border-color);
36
- border-left: 4px solid transparent;
37
- border-radius: 6px;
38
- padding: 8px;
39
- gap: 2px;
40
- background: #ffffff;
41
- transition: border-color 0.15s ease, box-shadow 0.15s ease;
42
- position: relative;
43
- }
44
-
45
- .ziko-notebook .cell.active {
46
- border-left-color: var(--primary);
47
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
48
- }
49
-
50
- .ziko-notebook .cell-input-row {
51
- display: flex;
52
- align-items: flex-start;
53
- gap: 8px;
54
- width: 100%;
55
- }
56
-
57
- .ziko-notebook .cell-output-row {
58
- display: flex;
59
- align-items: flex-start;
60
- gap: 8px;
61
- width: 100%;
62
- }
63
-
64
- .ziko-notebook .prompt {
65
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
66
- font-size: 11px;
67
- color: var(--prompt-in);
68
- text-align: right;
69
- padding-top: 8px;
70
- white-space: nowrap;
71
- user-select: none;
72
- font-weight: 700;
73
- }
74
-
75
- .ziko-notebook .prompt.out {
76
- color: var(--prompt-out);
77
- }
78
-
79
- /* --- INPUT --- */
80
-
81
- .ziko-notebook .input-wrapper {
82
- border: 1px solid var(--border-color);
83
- border-radius: 4px;
84
- background: var(--bg-editor);
85
- overflow: hidden;
86
- flex: 1 1 0;
87
- min-width: 0;
88
- width: auto;
89
- transition: border-color 0.15s ease;
90
- }
91
-
92
- .ziko-notebook .cell.active .input-wrapper {
93
- border-color: #cbd5e1;
94
- }
95
-
96
- .ziko-notebook .input-wrapper .CodeMirror {
97
- font-family: "Fira Code", SFMono-Regular, Consolas, monospace;
98
- font-size: 13px;
99
- height: auto !important;
100
- background: transparent;
101
- border-radius: 4px;
102
- }
103
-
104
- .ziko-notebook .input-wrapper .CodeMirror-scroll {
105
- overflow-y: hidden !important;
106
- overflow-x: auto !important;
107
- }
108
-
109
- .ziko-notebook .input-wrapper .CodeMirror-activeline-background {
110
- background: rgba(2, 132, 199, 0.05);
111
- }
112
-
113
- .ziko-notebook .cell-controls {
114
- display: flex;
115
- /* align-items: center; */
116
- align-items: baseline;
117
- justify-content: flex-end;
118
- gap: 2px;
119
- flex-wrap: wrap;
120
- margin: 0;
121
- padding: 0;
122
- }
123
-
124
- .ziko-notebook .cm-line{
125
- line-height: 1.3 !important;
126
- }
127
-
128
- /* --- OUTPUT --- */
129
-
130
- .ziko-notebook .output-wrapper {
131
- flex: 1 1 0;
132
- min-width: 0;
133
- width: auto;
134
- padding: 4px 0;
135
- }
136
-
137
- .ziko-notebook .output-area {
138
- font-size: 14px;
139
- word-break: break-word;
140
- }
141
-
142
-
143
-
144
- /* --- MOBILE --- */
145
-
146
- @media (max-width: 640px) {
147
- .ziko-notebook .header {
148
- padding: 8px 12px;
149
- }
150
-
151
- .ziko-notebook .toolbar {
152
- width: 100%;
153
- justify-content: center;
154
- align-items: baseline;
155
- }
156
-
157
- .ziko-notebook .prompt {
158
- font-size: 10px;
159
- padding-top: 6px;
160
- }
161
- }
162
-
163
-
164
- /* TEMP */
165
-
166
- .ziko-notebook .cm-editor{
167
- margin: 1px;
168
- outline: none;
169
- }
170
- .ziko-notebook .cm-scroller{
171
- margin: 1px;
172
- outline: none;
173
- }
174
- .ziko-notebook .cm-line{
175
- margin: 1px;
176
- }
1
+ @import '@zikojs/console/style';
2
+ @import url('./components/index.css');
3
+
4
+ .ziko-notebook {
5
+ --primary: #0284c7;
6
+ --primary-hover: #0369a1;
7
+ --border-color: #e2e8f0;
8
+ --prompt-in: #303f9f;
9
+ --prompt-out: #d62728;
10
+ --bg-editor: #f8fafc;
11
+
12
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
13
+ color: #1e293b;
14
+ }
15
+
16
+
17
+ /* --- NOTEBOOK & CELLS --- */
18
+
19
+ .ziko-notebook .notebook {
20
+ max-width: 900px;
21
+ margin: 16px auto;
22
+ padding: 0 8px;
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 12px;
26
+ overflow: auto;
27
+ /* max-height: 100vh; */
28
+ /* scrollbar-color: rebeccapurple transparent; */
29
+ /* scrollbar-color: var(--prompt-in) transparent; */
30
+ }
31
+
32
+ .ziko-notebook .cell {
33
+ display: flex;
34
+ flex-direction: column;
35
+ border: 1px solid var(--border-color);
36
+ border-left: 4px solid transparent;
37
+ border-radius: 6px;
38
+ padding: 8px;
39
+ gap: 2px;
40
+ background: #ffffff;
41
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
42
+ position: relative;
43
+ }
44
+
45
+ .ziko-notebook .cell.active {
46
+ border-left-color: var(--primary);
47
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
48
+ }
49
+
50
+ .ziko-notebook .cell-input-row {
51
+ display: flex;
52
+ align-items: flex-start;
53
+ gap: 8px;
54
+ width: 100%;
55
+ }
56
+
57
+ .ziko-notebook .cell-output-row {
58
+ display: flex;
59
+ align-items: flex-start;
60
+ gap: 8px;
61
+ width: 100%;
62
+ }
63
+
64
+ .ziko-notebook .prompt {
65
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
66
+ font-size: 11px;
67
+ color: var(--prompt-in);
68
+ text-align: right;
69
+ padding-top: 8px;
70
+ white-space: nowrap;
71
+ user-select: none;
72
+ font-weight: 700;
73
+ }
74
+
75
+ .ziko-notebook .prompt.out {
76
+ color: var(--prompt-out);
77
+ }
78
+
79
+ /* --- INPUT --- */
80
+
81
+ .ziko-notebook .input-wrapper {
82
+ border: 1px solid var(--border-color);
83
+ border-radius: 4px;
84
+ background: var(--bg-editor);
85
+ overflow: hidden;
86
+ flex: 1 1 0;
87
+ min-width: 0;
88
+ width: auto;
89
+ transition: border-color 0.15s ease;
90
+ }
91
+
92
+ .ziko-notebook .cell.active .input-wrapper {
93
+ border-color: #cbd5e1;
94
+ }
95
+
96
+ .ziko-notebook .input-wrapper .CodeMirror {
97
+ font-family: "Fira Code", SFMono-Regular, Consolas, monospace;
98
+ font-size: 13px;
99
+ height: auto !important;
100
+ background: transparent;
101
+ border-radius: 4px;
102
+ }
103
+
104
+ .ziko-notebook .input-wrapper .CodeMirror-scroll {
105
+ overflow-y: hidden !important;
106
+ overflow-x: auto !important;
107
+ }
108
+
109
+ .ziko-notebook .input-wrapper .CodeMirror-activeline-background {
110
+ background: rgba(2, 132, 199, 0.05);
111
+ }
112
+
113
+ .ziko-notebook .cell-controls {
114
+ display: flex;
115
+ /* align-items: center; */
116
+ align-items: baseline;
117
+ justify-content: flex-end;
118
+ gap: 2px;
119
+ flex-wrap: wrap;
120
+ margin: 0;
121
+ padding: 0;
122
+ }
123
+
124
+ .ziko-notebook .cm-line{
125
+ line-height: 1.3 !important;
126
+ }
127
+
128
+ /* --- OUTPUT --- */
129
+
130
+ .ziko-notebook .output-wrapper {
131
+ flex: 1 1 0;
132
+ min-width: 0;
133
+ width: auto;
134
+ padding: 4px 0;
135
+ }
136
+
137
+ .ziko-notebook .output-area {
138
+ font-size: 14px;
139
+ word-break: break-word;
140
+ }
141
+
142
+
143
+
144
+ /* --- MOBILE --- */
145
+
146
+ @media (max-width: 640px) {
147
+ .ziko-notebook .header {
148
+ padding: 8px 12px;
149
+ }
150
+
151
+ .ziko-notebook .toolbar {
152
+ width: 100%;
153
+ justify-content: center;
154
+ align-items: baseline;
155
+ }
156
+
157
+ .ziko-notebook .prompt {
158
+ font-size: 10px;
159
+ padding-top: 6px;
160
+ }
161
+ }
162
+
163
+
164
+ /* TEMP */
165
+
166
+ .ziko-notebook .cm-editor{
167
+ margin: 1px;
168
+ outline: none;
169
+ }
170
+ .ziko-notebook .cm-scroller{
171
+ margin: 1px;
172
+ outline: none;
173
+ }
174
+ .ziko-notebook .cm-line{
175
+ margin: 1px;
176
+ }
package/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import './index.css'
1
+ import './index.css'
2
2
  export * from './main.js'
package/src/index.ts CHANGED
@@ -1,97 +1,97 @@
1
-
2
- import type { UIElement } from "ziko/dom/UIElement";
3
-
4
- export type MaybePromise<T> = T | PromiseLike<T>;
5
-
6
- export interface NotebookCell {
7
- id?: number;
8
- type?: "code" | "markdown";
9
- code?: MaybePromise<string>;
10
- readonly?: boolean;
11
- runtime?: string | null;
12
- isEditingMarkdown?: boolean;
13
- execCount?: number | null;
14
- outputNode?: HTMLElement | null;
15
- hasDomOutput?: boolean;
16
- }
17
-
18
- export type NotebookCells = MaybePromise<NotebookCell[]>;
19
-
20
- export interface NotebookOptions {
21
- /**
22
- * Initial cells, or a Promise resolving to the cells.
23
- */
24
- cells?: NotebookCells;
25
-
26
- importMap?: Record<string, string>;
27
- runCells?: boolean;
28
- minLines?: number;
29
- maxCells?: number;
30
- showHeader?: boolean;
31
- codeMirrorConfig?: unknown[] | Record<string, unknown>;
32
- codeMirrorPlugins?: unknown[];
33
- runtimePlugins?: Array<{
34
- name: string;
35
- [key: string]: unknown;
36
- }>;
37
- remarkPlugins?: unknown[];
38
- rehypePlugins?: unknown[];
39
- }
40
-
41
- export declare class UINotebook extends UIElement {
42
- constructor(options?: NotebookOptions);
43
-
44
- /**
45
- * Resolves when initial cells and Promise-based cell code
46
- * have finished loading.
47
- *
48
- * Rejects if the initial cells source fails or does not
49
- * resolve to an array. Individual code-source failures are
50
- * displayed in their respective cells.
51
- */
52
- readonly ready: Promise<this>;
53
-
54
- readonly id: string;
55
-
56
- importMap: Record<string, string>;
57
- runtimePlugins: NotebookOptions["runtimePlugins"];
58
- codeMirrorConfig: NotebookOptions["codeMirrorConfig"];
59
- codeMirrorPlugins: unknown[];
60
- remarkPlugins: unknown[];
61
- rehypePlugins: unknown[];
62
- minLines: number;
63
- maxCells: number;
64
-
65
- runCell(id: number): Promise<void>;
66
- runAllCells(): Promise<void>;
67
-
68
- addCell(
69
- type?: "code" | "markdown",
70
- initialCode?: MaybePromise<string> | null,
71
- afterId?: number | null,
72
- readonly?: boolean
73
- ): number | null;
74
-
75
- deleteCell(id: number): void;
76
- setActiveCell(id: number): void;
77
- focusCell(id: number): void;
78
- clearOutputs(): void;
79
- resetScope(): Record<string, unknown>;
80
- getScope(): Record<string, unknown>;
81
-
82
- getNotebookData(options?: {
83
- inputs?: boolean;
84
- outputs?: boolean;
85
- }): Array<{
86
- id: number;
87
- type: "code" | "markdown";
88
- readonly: boolean;
89
- order: number | null;
90
- code?: string;
91
- outputHtml?: string | null;
92
- }>;
93
- }
94
-
95
- export declare function Notebook(
96
- options?: NotebookOptions
1
+
2
+ import type { UIElement } from "ziko/dom/UIElement";
3
+
4
+ export type MaybePromise<T> = T | PromiseLike<T>;
5
+
6
+ export interface NotebookCell {
7
+ id?: number;
8
+ type?: "code" | "markdown";
9
+ code?: MaybePromise<string>;
10
+ readonly?: boolean;
11
+ runtime?: string | null;
12
+ isEditingMarkdown?: boolean;
13
+ execCount?: number | null;
14
+ outputNode?: HTMLElement | null;
15
+ hasDomOutput?: boolean;
16
+ }
17
+
18
+ export type NotebookCells = MaybePromise<NotebookCell[]>;
19
+
20
+ export interface NotebookOptions {
21
+ /**
22
+ * Initial cells, or a Promise resolving to the cells.
23
+ */
24
+ cells?: NotebookCells;
25
+
26
+ importMap?: Record<string, string>;
27
+ runCells?: boolean;
28
+ minLines?: number;
29
+ maxCells?: number;
30
+ showHeader?: boolean;
31
+ codeMirrorConfig?: unknown[] | Record<string, unknown>;
32
+ codeMirrorPlugins?: unknown[];
33
+ runtimePlugins?: Array<{
34
+ name: string;
35
+ [key: string]: unknown;
36
+ }>;
37
+ remarkPlugins?: unknown[];
38
+ rehypePlugins?: unknown[];
39
+ }
40
+
41
+ export declare class UINotebook extends UIElement {
42
+ constructor(options?: NotebookOptions);
43
+
44
+ /**
45
+ * Resolves when initial cells and Promise-based cell code
46
+ * have finished loading.
47
+ *
48
+ * Rejects if the initial cells source fails or does not
49
+ * resolve to an array. Individual code-source failures are
50
+ * displayed in their respective cells.
51
+ */
52
+ readonly ready: Promise<this>;
53
+
54
+ readonly id: string;
55
+
56
+ importMap: Record<string, string>;
57
+ runtimePlugins: NotebookOptions["runtimePlugins"];
58
+ codeMirrorConfig: NotebookOptions["codeMirrorConfig"];
59
+ codeMirrorPlugins: unknown[];
60
+ remarkPlugins: unknown[];
61
+ rehypePlugins: unknown[];
62
+ minLines: number;
63
+ maxCells: number;
64
+
65
+ runCell(id: number): Promise<void>;
66
+ runAllCells(): Promise<void>;
67
+
68
+ addCell(
69
+ type?: "code" | "markdown",
70
+ initialCode?: MaybePromise<string> | null,
71
+ afterId?: number | null,
72
+ readonly?: boolean
73
+ ): number | null;
74
+
75
+ deleteCell(id: number): void;
76
+ setActiveCell(id: number): void;
77
+ focusCell(id: number): void;
78
+ clearOutputs(): void;
79
+ resetScope(): Record<string, unknown>;
80
+ getScope(): Record<string, unknown>;
81
+
82
+ getNotebookData(options?: {
83
+ inputs?: boolean;
84
+ outputs?: boolean;
85
+ }): Array<{
86
+ id: number;
87
+ type: "code" | "markdown";
88
+ readonly: boolean;
89
+ order: number | null;
90
+ code?: string;
91
+ outputHtml?: string | null;
92
+ }>;
93
+ }
94
+
95
+ export declare function Notebook(
96
+ options?: NotebookOptions
97
97
  ): UINotebook;