jupyter-specta 0.3.4 → 0.3.5
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/lib/components/icon/gear.js +4 -2
- package/lib/document/factory.js +1 -1
- package/lib/document/plugin.js +5 -5
- package/lib/tool.js +26 -5
- package/lib/topbar/widget.js +3 -2
- package/package.json +1 -1
- package/schema/app-meta.json +19 -0
- package/style/base.css +6 -2
- package/style/style.css +3 -2
|
@@ -12,6 +12,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from 'react';
|
|
13
13
|
export const GearIcon = (_a) => {
|
|
14
14
|
var props = __rest(_a, []);
|
|
15
|
-
return (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", height: "
|
|
16
|
-
React.createElement("path", { d: "
|
|
15
|
+
return (React.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, props),
|
|
16
|
+
React.createElement("path", { d: "M4 5h16" }),
|
|
17
|
+
React.createElement("path", { d: "M4 12h16" }),
|
|
18
|
+
React.createElement("path", { d: "M4 19h16" })));
|
|
17
19
|
};
|
package/lib/document/factory.js
CHANGED
|
@@ -34,7 +34,7 @@ export class NotebookGridWidgetFactory extends ABCWidgetFactory {
|
|
|
34
34
|
else {
|
|
35
35
|
// Specta app, add topbar to layout
|
|
36
36
|
topbar.id = 'specta-topbar-widget';
|
|
37
|
-
this._shell.add(topbar, 'top');
|
|
37
|
+
this._shell.add(topbar, 'top', { rank: 100 });
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
else if (isSpecta) {
|
package/lib/document/plugin.js
CHANGED
|
@@ -50,12 +50,10 @@ export const spectaOpener = {
|
|
|
50
50
|
],
|
|
51
51
|
activate: async (app, docManager, defaultBrowser) => {
|
|
52
52
|
const urlParams = new URLSearchParams(window.location.search);
|
|
53
|
-
const path = urlParams.get('path');
|
|
54
53
|
if (!isSpectaApp()) {
|
|
54
|
+
// Not a specta app
|
|
55
|
+
const path = urlParams.get('specta-path');
|
|
55
56
|
if (!path) {
|
|
56
|
-
app.restored.then(async () => {
|
|
57
|
-
await app.commands.execute('application:reset-layout');
|
|
58
|
-
});
|
|
59
57
|
return;
|
|
60
58
|
}
|
|
61
59
|
app.restored.then(async () => {
|
|
@@ -63,6 +61,7 @@ export const spectaOpener = {
|
|
|
63
61
|
if (PathExt.extname(path) === '.ipynb') {
|
|
64
62
|
const commands = app.commands;
|
|
65
63
|
const spectaConfig = readSpectaConfig({});
|
|
64
|
+
console.log('spectaConfig', spectaConfig);
|
|
66
65
|
await configLabLayout({
|
|
67
66
|
config: spectaConfig.labConfig,
|
|
68
67
|
labShell,
|
|
@@ -74,10 +73,11 @@ export const spectaOpener = {
|
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
});
|
|
77
|
-
// Not a specta app
|
|
78
76
|
return;
|
|
79
77
|
}
|
|
80
78
|
else {
|
|
79
|
+
// Specta app
|
|
80
|
+
const path = urlParams.get('path');
|
|
81
81
|
if (!path) {
|
|
82
82
|
const browser = createFileBrowser({ defaultBrowser });
|
|
83
83
|
app.shell.add(browser, 'main', { rank: 100 });
|
package/lib/tool.js
CHANGED
|
@@ -92,6 +92,7 @@ export function mergeObjects(...objects) {
|
|
|
92
92
|
for (const obj of objects) {
|
|
93
93
|
for (const [key, value] of Object.entries(obj)) {
|
|
94
94
|
if (value !== null && value !== undefined) {
|
|
95
|
+
console.log('setting', key, value);
|
|
95
96
|
result[key] = value;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
@@ -107,7 +108,7 @@ export function isSpectaApp() {
|
|
|
107
108
|
return !!document.querySelector('meta[name="specta-config"]');
|
|
108
109
|
}
|
|
109
110
|
export function readSpectaConfig({ nbMetadata, nbPath }) {
|
|
110
|
-
var _a;
|
|
111
|
+
var _a, _b;
|
|
111
112
|
let rawConfig = PageConfig.getOption('spectaConfig');
|
|
112
113
|
if (!rawConfig || rawConfig.length === 0) {
|
|
113
114
|
rawConfig = '{}';
|
|
@@ -117,10 +118,12 @@ export function readSpectaConfig({ nbMetadata, nbPath }) {
|
|
|
117
118
|
if (paths && paths.length > 1) {
|
|
118
119
|
pathWithoutDrive = paths[1];
|
|
119
120
|
}
|
|
120
|
-
const
|
|
121
|
+
const _c = JSON.parse(rawConfig), { perFileConfig } = _c, globalConfig = __rest(_c, ["perFileConfig"]);
|
|
121
122
|
let spectaConfig = Object.assign({}, (globalConfig !== null && globalConfig !== void 0 ? globalConfig : {}));
|
|
123
|
+
let fileConfig = {};
|
|
122
124
|
if (perFileConfig && pathWithoutDrive && perFileConfig[pathWithoutDrive]) {
|
|
123
|
-
|
|
125
|
+
fileConfig = perFileConfig[pathWithoutDrive];
|
|
126
|
+
spectaConfig = Object.assign(Object.assign({}, spectaConfig), fileConfig);
|
|
124
127
|
}
|
|
125
128
|
const spectaMetadata = JSON.parse(JSON.stringify((_a = nbMetadata === null || nbMetadata === void 0 ? void 0 : nbMetadata.specta) !== null && _a !== void 0 ? _a : {}));
|
|
126
129
|
if (spectaMetadata.hideTopbar === 'Yes') {
|
|
@@ -132,11 +135,29 @@ export function readSpectaConfig({ nbMetadata, nbPath }) {
|
|
|
132
135
|
else {
|
|
133
136
|
if (spectaConfig.hideTopbar === null ||
|
|
134
137
|
spectaConfig.hideTopbar === undefined) {
|
|
135
|
-
//
|
|
138
|
+
// Show topbar by default if not specified in the global config
|
|
136
139
|
// and notebook metadata
|
|
137
|
-
spectaMetadata.hideTopbar =
|
|
140
|
+
spectaMetadata.hideTopbar = false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (!spectaMetadata.hideTopbar) {
|
|
144
|
+
spectaMetadata.topBar = {};
|
|
145
|
+
if (spectaMetadata.topbarTitle && spectaMetadata.topbarTitle !== '') {
|
|
146
|
+
spectaMetadata.topBar.title = spectaMetadata.topbarTitle;
|
|
147
|
+
delete spectaMetadata.topbarTitle;
|
|
148
|
+
}
|
|
149
|
+
else if (!((_b = fileConfig === null || fileConfig === void 0 ? void 0 : fileConfig.topBar) === null || _b === void 0 ? void 0 : _b.title)) {
|
|
150
|
+
spectaMetadata.topBar.title = pathWithoutDrive;
|
|
151
|
+
}
|
|
152
|
+
if (spectaMetadata.topbarThemeToggle === 'No') {
|
|
153
|
+
spectaMetadata.topBar.themeToggle = false;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
spectaMetadata.topBar.themeToggle = true;
|
|
138
157
|
}
|
|
158
|
+
delete spectaMetadata.topbarThemeToggle;
|
|
139
159
|
}
|
|
160
|
+
// merge spectaConfig and spectaMetadata (spectaMetadata has higher priority
|
|
140
161
|
return mergeObjects(spectaConfig, spectaMetadata);
|
|
141
162
|
}
|
|
142
163
|
export function readCellConfig(cell) {
|
package/lib/topbar/widget.js
CHANGED
|
@@ -7,7 +7,7 @@ export function TopbarElement(props) {
|
|
|
7
7
|
const config = React.useMemo(() => {
|
|
8
8
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
9
9
|
return {
|
|
10
|
-
background: (_b = (_a = props.config) === null || _a === void 0 ? void 0 : _a.background) !== null && _b !== void 0 ? _b : 'var(--jp-layout-
|
|
10
|
+
background: (_b = (_a = props.config) === null || _a === void 0 ? void 0 : _a.background) !== null && _b !== void 0 ? _b : 'var(--jp-layout-color1)',
|
|
11
11
|
title: (_d = (_c = props.config) === null || _c === void 0 ? void 0 : _c.title) !== null && _d !== void 0 ? _d : 'Specta',
|
|
12
12
|
themeToggle: Boolean((_e = props.config) === null || _e === void 0 ? void 0 : _e.themeToggle),
|
|
13
13
|
kernelActivity: Boolean((_f = props.config) === null || _f === void 0 ? void 0 : _f.kernelActivity),
|
|
@@ -30,7 +30,8 @@ export function TopbarElement(props) {
|
|
|
30
30
|
document.addEventListener('mousedown', handleClickOutside);
|
|
31
31
|
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
32
32
|
}, []);
|
|
33
|
-
|
|
33
|
+
console.log('config.background ', config.background);
|
|
34
|
+
return (React.createElement("div", { className: "specta-topbar", style: { background: (_a = config.background) !== null && _a !== void 0 ? _a : 'var(--jp-layout-color1)' } },
|
|
34
35
|
React.createElement("div", { className: "specta-topbar-left" },
|
|
35
36
|
React.createElement("div", { className: "specta-topbar-icon-container" }, config.icon && React.createElement("img", { style: { height: '100%' }, src: config.icon })),
|
|
36
37
|
React.createElement("div", { className: "specta-topbar-title", style: { color: (_b = config.textColor) !== null && _b !== void 0 ? _b : 'var(--jp-ui-font-color1)' } }, config.title)),
|
package/package.json
CHANGED
package/schema/app-meta.json
CHANGED
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
"metadataSchema": {
|
|
10
10
|
"type": "object",
|
|
11
11
|
"properties": {
|
|
12
|
+
"/specta/topbarTitle": {
|
|
13
|
+
"title": "Top Bar Title",
|
|
14
|
+
"type": "string",
|
|
15
|
+
"default": ""
|
|
16
|
+
},
|
|
17
|
+
"/specta/topbarThemeToggle": {
|
|
18
|
+
"title": "Top Bar Theme Toggle",
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": ["Yes", "No"],
|
|
21
|
+
"default": "Yes"
|
|
22
|
+
},
|
|
12
23
|
"/specta/defaultLayout": {
|
|
13
24
|
"title": "Page layout",
|
|
14
25
|
"type": "string",
|
|
@@ -55,6 +66,14 @@
|
|
|
55
66
|
"/specta/slidesTheme": {
|
|
56
67
|
"metadataLevel": "notebook",
|
|
57
68
|
"writeDefault": false
|
|
69
|
+
},
|
|
70
|
+
"/specta/topbarTitle": {
|
|
71
|
+
"metadataLevel": "notebook",
|
|
72
|
+
"writeDefault": false
|
|
73
|
+
},
|
|
74
|
+
"/specta/topbarThemeToggle": {
|
|
75
|
+
"metadataLevel": "notebook",
|
|
76
|
+
"writeDefault": false
|
|
58
77
|
}
|
|
59
78
|
}
|
|
60
79
|
}
|
package/style/base.css
CHANGED
|
@@ -69,11 +69,13 @@
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
#specta-top-panel {
|
|
72
|
-
min-height:
|
|
72
|
+
min-height: 28px;
|
|
73
73
|
display: flex;
|
|
74
74
|
box-shadow: unset !important;
|
|
75
75
|
z-index: 100;
|
|
76
76
|
contain: unset !important;
|
|
77
|
+
border-bottom: var(--jp-border-width) solid var(--jp-border-color0);
|
|
78
|
+
background: var(--jp-layout-color1);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
.specta-topbar-element {
|
|
@@ -84,7 +86,7 @@
|
|
|
84
86
|
.specta-topbar {
|
|
85
87
|
display: flex;
|
|
86
88
|
flex-direction: row;
|
|
87
|
-
height:
|
|
89
|
+
height: 28px;
|
|
88
90
|
width: calc(100% + 20px);
|
|
89
91
|
border-bottom: solid 0.5px var(--jp-border-color1);
|
|
90
92
|
gap: 10px;
|
|
@@ -128,7 +130,9 @@
|
|
|
128
130
|
border-radius: 50% !important;
|
|
129
131
|
transition: background 0.2s ease;
|
|
130
132
|
background: transparent;
|
|
133
|
+
padding: 0 !important;
|
|
131
134
|
}
|
|
135
|
+
|
|
132
136
|
.specta-icon-button:hover {
|
|
133
137
|
background-color: var('--jp-layout-color3');
|
|
134
138
|
}
|
package/style/style.css
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
.specta-document-viewer #jp-main-content-panel jp-toolbar:first-of-type {
|
|
8
8
|
display: none;
|
|
9
|
+
height: 0px !important;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
.specta-file-browser {
|
|
@@ -28,6 +29,6 @@
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
.specta-main-content-panel {
|
|
31
|
-
padding-left:
|
|
32
|
-
padding-right:
|
|
32
|
+
padding-left: 0px;
|
|
33
|
+
padding-right: 0px;
|
|
33
34
|
}
|