jupyterlab-pioneer 1.7.1 → 1.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/README.md +3 -1
- package/lib/index.d.ts +1 -0
- package/lib/producer.js +140 -121
- package/lib/types.d.ts +4 -0
- package/lib/utils.js +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,11 +70,13 @@ Check jupyter server [doc](https://jupyter-server.readthedocs.io/en/latest/opera
|
|
|
70
70
|
{
|
|
71
71
|
'name': # string, event name
|
|
72
72
|
'logWholeNotebook': # boolean, whether to export the entire notebook content when event is triggered
|
|
73
|
+
'logCellMetadata': # boolean, whether to export cell metadata when a cell related event is triggered
|
|
73
74
|
}
|
|
74
75
|
```
|
|
75
76
|
|
|
76
77
|
The extension would only generate and export data for valid event that has an id associated with the event class, and the event name is included in `activeEvents`.
|
|
77
78
|
The extension will export the entire notebook content only for valid events when the `logWholeNotebook` flag is True.
|
|
79
|
+
It will export the cell metadata when the `logCellMetadata` flag is True.
|
|
78
80
|
|
|
79
81
|
`exporters`: An array of exporters. Each exporter in the array should have the following structure:
|
|
80
82
|
|
|
@@ -189,7 +191,7 @@ See [RELEASE](RELEASE.md)
|
|
|
189
191
|
|
|
190
192
|
## Contributors ✨
|
|
191
193
|
|
|
192
|
-
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/
|
|
194
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/emoji-key/#natural-language-processing)):
|
|
193
195
|
|
|
194
196
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
195
197
|
<!-- prettier-ignore-start -->
|
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface IJupyterLabPioneer {
|
|
|
16
16
|
* @param {object} eventDetail An object containing event details.
|
|
17
17
|
* @param {Exporter} exporter The exporter configuration.
|
|
18
18
|
* @param {Boolean} logWholeNotebook A boolean indicating whether to log the entire notebook or not.
|
|
19
|
+
* @param {Boolean} logCellMetadata A boolean indicating whether to log the cell metadata or not.
|
|
19
20
|
*/
|
|
20
21
|
publishEvent(notebookPanel: NotebookPanel, eventDetail: object, exporter: Exporter, logWholeNotebook?: boolean): Promise<void>;
|
|
21
22
|
}
|
package/lib/producer.js
CHANGED
|
@@ -5,22 +5,24 @@ class ActiveCellChangeEventProducer {
|
|
|
5
5
|
listen(notebookPanel, pioneer) {
|
|
6
6
|
notebookPanel.content.activeCellChanged.connect(async (_, cell) => {
|
|
7
7
|
if (cell && notebookPanel.content.widgets) {
|
|
8
|
-
const activatedCell = {
|
|
9
|
-
id: cell === null || cell === void 0 ? void 0 : cell.model.id,
|
|
10
|
-
index: notebookPanel.content.widgets.findIndex(value => value === cell),
|
|
11
|
-
type: cell === null || cell === void 0 ? void 0 : cell.model.type
|
|
12
|
-
};
|
|
13
|
-
const event = {
|
|
14
|
-
eventName: ActiveCellChangeEventProducer.id,
|
|
15
|
-
eventTime: Date.now(),
|
|
16
|
-
eventInfo: {
|
|
17
|
-
cells: [activatedCell] // activated cell
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
8
|
pioneer.exporters.forEach(async (exporter) => {
|
|
21
|
-
var _a, _b, _c;
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
22
10
|
if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(ActiveCellChangeEventProducer.id)) {
|
|
23
|
-
|
|
11
|
+
const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ActiveCellChangeEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
|
|
12
|
+
const activatedCell = {
|
|
13
|
+
id: cell === null || cell === void 0 ? void 0 : cell.model.id,
|
|
14
|
+
index: notebookPanel.content.widgets.findIndex(value => value === cell),
|
|
15
|
+
type: cell === null || cell === void 0 ? void 0 : cell.model.type,
|
|
16
|
+
metadata: logCellMetadata ? cell === null || cell === void 0 ? void 0 : cell.model.metadata : null
|
|
17
|
+
};
|
|
18
|
+
const event = {
|
|
19
|
+
eventName: ActiveCellChangeEventProducer.id,
|
|
20
|
+
eventTime: Date.now(),
|
|
21
|
+
eventInfo: {
|
|
22
|
+
cells: [activatedCell] // activated cell
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
await pioneer.publishEvent(notebookPanel, event, exporter, (_e = (_d = exporter.activeEvents) === null || _d === void 0 ? void 0 : _d.find(o => o.name === ActiveCellChangeEventProducer.id)) === null || _e === void 0 ? void 0 : _e.logWholeNotebook);
|
|
24
26
|
}
|
|
25
27
|
});
|
|
26
28
|
}
|
|
@@ -34,22 +36,24 @@ class CellAddEventProducer {
|
|
|
34
36
|
var _a;
|
|
35
37
|
(_a = notebookPanel.content.model) === null || _a === void 0 ? void 0 : _a.cells.changed.connect(async (_, args) => {
|
|
36
38
|
if (args.type === 'add') {
|
|
37
|
-
const addedCell = {
|
|
38
|
-
id: args.newValues[0].id,
|
|
39
|
-
index: args.newIndex,
|
|
40
|
-
type: args.newValues[0].type
|
|
41
|
-
};
|
|
42
|
-
const event = {
|
|
43
|
-
eventName: CellAddEventProducer.id,
|
|
44
|
-
eventTime: Date.now(),
|
|
45
|
-
eventInfo: {
|
|
46
|
-
cells: [addedCell]
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
39
|
pioneer.exporters.forEach(async (exporter) => {
|
|
50
|
-
var _a, _b, _c;
|
|
40
|
+
var _a, _b, _c, _d, _e;
|
|
51
41
|
if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(CellAddEventProducer.id)) {
|
|
52
|
-
|
|
42
|
+
const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === CellAddEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
|
|
43
|
+
const addedCell = {
|
|
44
|
+
id: args.newValues[0].id,
|
|
45
|
+
index: args.newIndex,
|
|
46
|
+
type: args.newValues[0].type,
|
|
47
|
+
metadata: logCellMetadata ? args.newValues[0].metadata : null
|
|
48
|
+
};
|
|
49
|
+
const event = {
|
|
50
|
+
eventName: CellAddEventProducer.id,
|
|
51
|
+
eventTime: Date.now(),
|
|
52
|
+
eventInfo: {
|
|
53
|
+
cells: [addedCell]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
await pioneer.publishEvent(notebookPanel, event, exporter, (_e = (_d = exporter.activeEvents) === null || _d === void 0 ? void 0 : _d.find(o => o.name === CellAddEventProducer.id)) === null || _e === void 0 ? void 0 : _e.logWholeNotebook);
|
|
53
57
|
}
|
|
54
58
|
});
|
|
55
59
|
}
|
|
@@ -62,22 +66,23 @@ class CellEditEventProducer {
|
|
|
62
66
|
listen(notebookPanel, pioneer) {
|
|
63
67
|
var _a, _b;
|
|
64
68
|
const sendDoc = async (_, cell) => {
|
|
65
|
-
var _a, _b;
|
|
66
69
|
await (cell === null || cell === void 0 ? void 0 : cell.ready); // wait until cell is ready, to prevent errors when creating new cells
|
|
67
70
|
const editor = cell === null || cell === void 0 ? void 0 : cell.editor;
|
|
68
|
-
const event = {
|
|
69
|
-
eventName: CellEditEventProducer.id,
|
|
70
|
-
eventTime: Date.now(),
|
|
71
|
-
eventInfo: {
|
|
72
|
-
index: notebookPanel.content.widgets.findIndex(value => value === cell),
|
|
73
|
-
doc: (_b = (_a = editor === null || editor === void 0 ? void 0 : editor.state) === null || _a === void 0 ? void 0 : _a.doc) === null || _b === void 0 ? void 0 : _b.toJSON(),
|
|
74
|
-
type: cell === null || cell === void 0 ? void 0 : cell.model.type
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
71
|
pioneer.exporters.forEach(async (exporter) => {
|
|
78
|
-
var _a, _b, _c;
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
79
73
|
if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(CellEditEventProducer.id)) {
|
|
80
|
-
|
|
74
|
+
const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ActiveCellChangeEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
|
|
75
|
+
const event = {
|
|
76
|
+
eventName: CellEditEventProducer.id,
|
|
77
|
+
eventTime: Date.now(),
|
|
78
|
+
eventInfo: {
|
|
79
|
+
index: notebookPanel.content.widgets.findIndex(value => value === cell),
|
|
80
|
+
doc: (_e = (_d = editor === null || editor === void 0 ? void 0 : editor.state) === null || _d === void 0 ? void 0 : _d.doc) === null || _e === void 0 ? void 0 : _e.toJSON(),
|
|
81
|
+
type: cell === null || cell === void 0 ? void 0 : cell.model.type,
|
|
82
|
+
metadata: logCellMetadata ? cell === null || cell === void 0 ? void 0 : cell.model.metadata : null
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
await pioneer.publishEvent(notebookPanel, event, exporter, (_g = (_f = exporter.activeEvents) === null || _f === void 0 ? void 0 : _f.find(o => o.name === CellEditEventProducer.id)) === null || _g === void 0 ? void 0 : _g.logWholeNotebook);
|
|
81
86
|
}
|
|
82
87
|
});
|
|
83
88
|
};
|
|
@@ -124,24 +129,26 @@ class CellExecuteEventProducer {
|
|
|
124
129
|
listen(notebookPanel, pioneer) {
|
|
125
130
|
NotebookActions.executed.connect(async (_, args) => {
|
|
126
131
|
if (notebookPanel.content === args.notebook) {
|
|
127
|
-
const executedCell = {
|
|
128
|
-
id: args.cell.model.id,
|
|
129
|
-
index: args.notebook.widgets.findIndex(value => value === args.cell),
|
|
130
|
-
type: args.cell.model.type
|
|
131
|
-
};
|
|
132
|
-
const event = {
|
|
133
|
-
eventName: CellExecuteEventProducer.id,
|
|
134
|
-
eventTime: Date.now(),
|
|
135
|
-
eventInfo: {
|
|
136
|
-
cells: [executedCell],
|
|
137
|
-
success: args.success,
|
|
138
|
-
kernelError: args.success ? null : args.error
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
132
|
pioneer.exporters.forEach(async (exporter) => {
|
|
142
|
-
var _a, _b, _c;
|
|
133
|
+
var _a, _b, _c, _d, _e;
|
|
143
134
|
if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(CellExecuteEventProducer.id)) {
|
|
144
|
-
|
|
135
|
+
const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === CellExecuteEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
|
|
136
|
+
const executedCell = {
|
|
137
|
+
id: args.cell.model.id,
|
|
138
|
+
index: args.notebook.widgets.findIndex(value => value === args.cell),
|
|
139
|
+
type: args.cell.model.type,
|
|
140
|
+
metadata: logCellMetadata ? args.cell.model.metadata : null
|
|
141
|
+
};
|
|
142
|
+
const event = {
|
|
143
|
+
eventName: CellExecuteEventProducer.id,
|
|
144
|
+
eventTime: Date.now(),
|
|
145
|
+
eventInfo: {
|
|
146
|
+
cells: [executedCell],
|
|
147
|
+
success: args.success,
|
|
148
|
+
kernelError: args.success ? null : args.error
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
await pioneer.publishEvent(notebookPanel, event, exporter, (_e = (_d = exporter.activeEvents) === null || _d === void 0 ? void 0 : _d.find(o => o.name === CellExecuteEventProducer.id)) === null || _e === void 0 ? void 0 : _e.logWholeNotebook);
|
|
145
152
|
}
|
|
146
153
|
});
|
|
147
154
|
}
|
|
@@ -154,23 +161,26 @@ class CellRemoveEventProducer {
|
|
|
154
161
|
listen(notebookPanel, pioneer) {
|
|
155
162
|
var _a;
|
|
156
163
|
(_a = notebookPanel.content.model) === null || _a === void 0 ? void 0 : _a.cells.changed.connect(async (_, args) => {
|
|
157
|
-
var _a;
|
|
158
164
|
if (args.type === 'remove') {
|
|
159
|
-
const removedCell = {
|
|
160
|
-
index: args.oldIndex,
|
|
161
|
-
type: (_a = notebookPanel.content.model) === null || _a === void 0 ? void 0 : _a.cells.get(args.oldIndex).type
|
|
162
|
-
};
|
|
163
|
-
const event = {
|
|
164
|
-
eventName: CellRemoveEventProducer.id,
|
|
165
|
-
eventTime: Date.now(),
|
|
166
|
-
eventInfo: {
|
|
167
|
-
cells: [removedCell]
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
165
|
pioneer.exporters.forEach(async (exporter) => {
|
|
171
|
-
var _a, _b, _c;
|
|
166
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
172
167
|
if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(CellRemoveEventProducer.id)) {
|
|
173
|
-
|
|
168
|
+
const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === CellRemoveEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
|
|
169
|
+
const removedCell = {
|
|
170
|
+
index: args.oldIndex,
|
|
171
|
+
type: (_d = notebookPanel.content.model) === null || _d === void 0 ? void 0 : _d.cells.get(args.oldIndex).type,
|
|
172
|
+
metadata: logCellMetadata
|
|
173
|
+
? (_e = notebookPanel.content.activeCell) === null || _e === void 0 ? void 0 : _e.model.metadata
|
|
174
|
+
: null
|
|
175
|
+
};
|
|
176
|
+
const event = {
|
|
177
|
+
eventName: CellRemoveEventProducer.id,
|
|
178
|
+
eventTime: Date.now(),
|
|
179
|
+
eventInfo: {
|
|
180
|
+
cells: [removedCell]
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
await pioneer.publishEvent(notebookPanel, event, exporter, (_g = (_f = exporter.activeEvents) === null || _f === void 0 ? void 0 : _f.find(o => o.name === CellRemoveEventProducer.id)) === null || _g === void 0 ? void 0 : _g.logWholeNotebook);
|
|
174
184
|
}
|
|
175
185
|
});
|
|
176
186
|
}
|
|
@@ -182,25 +192,28 @@ export { CellRemoveEventProducer };
|
|
|
182
192
|
class ClipboardCopyEventProducer {
|
|
183
193
|
listen(notebookPanel, pioneer) {
|
|
184
194
|
notebookPanel.node.addEventListener('copy', async () => {
|
|
185
|
-
var _a, _b, _c;
|
|
186
|
-
const cell = {
|
|
187
|
-
id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
|
|
188
|
-
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
|
|
189
|
-
type: (_b = notebookPanel.content.activeCell) === null || _b === void 0 ? void 0 : _b.model.type
|
|
190
|
-
};
|
|
191
|
-
const text = (_c = document.getSelection()) === null || _c === void 0 ? void 0 : _c.toString();
|
|
192
|
-
const event = {
|
|
193
|
-
eventName: ClipboardCopyEventProducer.id,
|
|
194
|
-
eventTime: Date.now(),
|
|
195
|
-
eventInfo: {
|
|
196
|
-
cells: [cell],
|
|
197
|
-
selection: text
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
195
|
pioneer.exporters.forEach(async (exporter) => {
|
|
201
|
-
var _a, _b, _c;
|
|
196
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
202
197
|
if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(ClipboardCopyEventProducer.id)) {
|
|
203
|
-
|
|
198
|
+
const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ClipboardCopyEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
|
|
199
|
+
const cell = {
|
|
200
|
+
id: (_d = notebookPanel.content.activeCell) === null || _d === void 0 ? void 0 : _d.model.id,
|
|
201
|
+
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
|
|
202
|
+
type: (_e = notebookPanel.content.activeCell) === null || _e === void 0 ? void 0 : _e.model.type,
|
|
203
|
+
metadata: logCellMetadata
|
|
204
|
+
? (_f = notebookPanel.content.activeCell) === null || _f === void 0 ? void 0 : _f.model.metadata
|
|
205
|
+
: null
|
|
206
|
+
};
|
|
207
|
+
const text = (_g = document.getSelection()) === null || _g === void 0 ? void 0 : _g.toString();
|
|
208
|
+
const event = {
|
|
209
|
+
eventName: ClipboardCopyEventProducer.id,
|
|
210
|
+
eventTime: Date.now(),
|
|
211
|
+
eventInfo: {
|
|
212
|
+
cells: [cell],
|
|
213
|
+
selection: text
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
await pioneer.publishEvent(notebookPanel, event, exporter, (_j = (_h = exporter.activeEvents) === null || _h === void 0 ? void 0 : _h.find(o => o.name === ClipboardCopyEventProducer.id)) === null || _j === void 0 ? void 0 : _j.logWholeNotebook);
|
|
204
217
|
}
|
|
205
218
|
});
|
|
206
219
|
});
|
|
@@ -211,25 +224,28 @@ export { ClipboardCopyEventProducer };
|
|
|
211
224
|
class ClipboardCutEventProducer {
|
|
212
225
|
listen(notebookPanel, pioneer) {
|
|
213
226
|
notebookPanel.node.addEventListener('cut', async () => {
|
|
214
|
-
var _a, _b, _c;
|
|
215
|
-
const cell = {
|
|
216
|
-
id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
|
|
217
|
-
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
|
|
218
|
-
type: (_b = notebookPanel.content.activeCell) === null || _b === void 0 ? void 0 : _b.model.type
|
|
219
|
-
};
|
|
220
|
-
const text = (_c = document.getSelection()) === null || _c === void 0 ? void 0 : _c.toString();
|
|
221
|
-
const event = {
|
|
222
|
-
eventName: ClipboardCutEventProducer.id,
|
|
223
|
-
eventTime: Date.now(),
|
|
224
|
-
eventInfo: {
|
|
225
|
-
cells: [cell],
|
|
226
|
-
selection: text
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
227
|
pioneer.exporters.forEach(async (exporter) => {
|
|
230
|
-
var _a, _b, _c;
|
|
228
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
231
229
|
if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(ClipboardCutEventProducer.id)) {
|
|
232
|
-
|
|
230
|
+
const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ClipboardCutEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
|
|
231
|
+
const cell = {
|
|
232
|
+
id: (_d = notebookPanel.content.activeCell) === null || _d === void 0 ? void 0 : _d.model.id,
|
|
233
|
+
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
|
|
234
|
+
type: (_e = notebookPanel.content.activeCell) === null || _e === void 0 ? void 0 : _e.model.type,
|
|
235
|
+
metadata: logCellMetadata
|
|
236
|
+
? (_f = notebookPanel.content.activeCell) === null || _f === void 0 ? void 0 : _f.model.metadata
|
|
237
|
+
: null
|
|
238
|
+
};
|
|
239
|
+
const text = (_g = document.getSelection()) === null || _g === void 0 ? void 0 : _g.toString();
|
|
240
|
+
const event = {
|
|
241
|
+
eventName: ClipboardCutEventProducer.id,
|
|
242
|
+
eventTime: Date.now(),
|
|
243
|
+
eventInfo: {
|
|
244
|
+
cells: [cell],
|
|
245
|
+
selection: text
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
await pioneer.publishEvent(notebookPanel, event, exporter, (_j = (_h = exporter.activeEvents) === null || _h === void 0 ? void 0 : _h.find(o => o.name === ClipboardCutEventProducer.id)) === null || _j === void 0 ? void 0 : _j.logWholeNotebook);
|
|
233
249
|
}
|
|
234
250
|
});
|
|
235
251
|
});
|
|
@@ -240,25 +256,28 @@ export { ClipboardCutEventProducer };
|
|
|
240
256
|
class ClipboardPasteEventProducer {
|
|
241
257
|
listen(notebookPanel, pioneer) {
|
|
242
258
|
notebookPanel.node.addEventListener('paste', async (e) => {
|
|
243
|
-
var _a, _b;
|
|
244
|
-
const cell = {
|
|
245
|
-
id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
|
|
246
|
-
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
|
|
247
|
-
type: (_b = notebookPanel.content.activeCell) === null || _b === void 0 ? void 0 : _b.model.type
|
|
248
|
-
};
|
|
249
|
-
const text = (e.clipboardData || window.clipboardData).getData('text');
|
|
250
|
-
const event = {
|
|
251
|
-
eventName: ClipboardPasteEventProducer.id,
|
|
252
|
-
eventTime: Date.now(),
|
|
253
|
-
eventInfo: {
|
|
254
|
-
cells: [cell],
|
|
255
|
-
selection: text
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
259
|
pioneer.exporters.forEach(async (exporter) => {
|
|
259
|
-
var _a, _b, _c;
|
|
260
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
260
261
|
if ((_a = exporter.activeEvents) === null || _a === void 0 ? void 0 : _a.map(o => o.name).includes(ClipboardPasteEventProducer.id)) {
|
|
261
|
-
|
|
262
|
+
const logCellMetadata = (_c = (_b = exporter.activeEvents) === null || _b === void 0 ? void 0 : _b.find(o => o.name === ClipboardPasteEventProducer.id)) === null || _c === void 0 ? void 0 : _c.logCellMetadata;
|
|
263
|
+
const cell = {
|
|
264
|
+
id: (_d = notebookPanel.content.activeCell) === null || _d === void 0 ? void 0 : _d.model.id,
|
|
265
|
+
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell),
|
|
266
|
+
type: (_e = notebookPanel.content.activeCell) === null || _e === void 0 ? void 0 : _e.model.type,
|
|
267
|
+
metadata: logCellMetadata
|
|
268
|
+
? (_f = notebookPanel.content.activeCell) === null || _f === void 0 ? void 0 : _f.model.metadata
|
|
269
|
+
: null
|
|
270
|
+
};
|
|
271
|
+
const text = (e.clipboardData || window.clipboardData).getData('text');
|
|
272
|
+
const event = {
|
|
273
|
+
eventName: ClipboardPasteEventProducer.id,
|
|
274
|
+
eventTime: Date.now(),
|
|
275
|
+
eventInfo: {
|
|
276
|
+
cells: [cell],
|
|
277
|
+
selection: text
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
await pioneer.publishEvent(notebookPanel, event, exporter, (_h = (_g = exporter.activeEvents) === null || _g === void 0 ? void 0 : _g.find(o => o.name === ClipboardPasteEventProducer.id)) === null || _h === void 0 ? void 0 : _h.logWholeNotebook);
|
|
262
281
|
}
|
|
263
282
|
});
|
|
264
283
|
});
|
package/lib/types.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export interface ActiveEvent {
|
|
|
7
7
|
* Whether to log the whole notebook or not when the event is triggered
|
|
8
8
|
*/
|
|
9
9
|
logWholeNotebook: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to log the whole notebook or not when the event is triggered
|
|
12
|
+
*/
|
|
13
|
+
logCellMetadata: boolean;
|
|
10
14
|
}
|
|
11
15
|
export interface ExporterArgs {
|
|
12
16
|
/**
|
package/lib/utils.js
CHANGED
|
@@ -15,7 +15,21 @@ export const sendInfoNotification = (exporters, isGlobal) => {
|
|
|
15
15
|
else {
|
|
16
16
|
message = `Embedded telemetry settings loaded. Telemetry data is being logged to ${exporterMessage} now.`;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const close = localStorage.getItem('pioneer:autoClose');
|
|
19
|
+
if (close !== null) {
|
|
20
|
+
Notification.info(message, { autoClose: 0 });
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
Notification.info(message, {
|
|
24
|
+
actions: [
|
|
25
|
+
{
|
|
26
|
+
label: "Don't show again",
|
|
27
|
+
callback: () => localStorage.setItem('pioneer:autoClose', '0')
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
autoClose: 10000
|
|
31
|
+
});
|
|
32
|
+
}
|
|
19
33
|
};
|
|
20
34
|
export const addInfoToHelpMenu = (app, mainMenu, version) => {
|
|
21
35
|
// Add extension info to help menu
|