jupyterlab-pioneer 1.4.0 → 1.6.0
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/producer.js +29 -16
- package/package.json +1 -1
package/lib/producer.js
CHANGED
|
@@ -7,7 +7,8 @@ class ActiveCellChangeEventProducer {
|
|
|
7
7
|
if (cell && notebookPanel.content.widgets) {
|
|
8
8
|
const activatedCell = {
|
|
9
9
|
id: cell === null || cell === void 0 ? void 0 : cell.model.id,
|
|
10
|
-
index: notebookPanel.content.widgets.findIndex(value => value === cell)
|
|
10
|
+
index: notebookPanel.content.widgets.findIndex(value => value === cell),
|
|
11
|
+
type: cell === null || cell === void 0 ? void 0 : cell.model.type
|
|
11
12
|
};
|
|
12
13
|
const event = {
|
|
13
14
|
eventName: ActiveCellChangeEventProducer.id,
|
|
@@ -35,7 +36,8 @@ class CellAddEventProducer {
|
|
|
35
36
|
if (args.type === 'add') {
|
|
36
37
|
const addedCell = {
|
|
37
38
|
id: args.newValues[0].id,
|
|
38
|
-
index: args.newIndex
|
|
39
|
+
index: args.newIndex,
|
|
40
|
+
type: args.newValues[0].type
|
|
39
41
|
};
|
|
40
42
|
const event = {
|
|
41
43
|
eventName: CellAddEventProducer.id,
|
|
@@ -68,7 +70,8 @@ class CellEditEventProducer {
|
|
|
68
70
|
eventTime: Date.now(),
|
|
69
71
|
eventInfo: {
|
|
70
72
|
index: notebookPanel.content.widgets.findIndex(value => value === cell),
|
|
71
|
-
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()
|
|
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
|
|
72
75
|
}
|
|
73
76
|
};
|
|
74
77
|
pioneer.exporters.forEach(async (exporter) => {
|
|
@@ -88,7 +91,8 @@ class CellEditEventProducer {
|
|
|
88
91
|
eventTime: Date.now(),
|
|
89
92
|
eventInfo: {
|
|
90
93
|
index: notebookPanel.content.widgets.findIndex(value => value === cell),
|
|
91
|
-
changes: v.changes.toJSON()
|
|
94
|
+
changes: v.changes.toJSON(),
|
|
95
|
+
type: cell === null || cell === void 0 ? void 0 : cell.model.type
|
|
92
96
|
}
|
|
93
97
|
};
|
|
94
98
|
pioneer.exporters.forEach(async (exporter) => {
|
|
@@ -122,7 +126,8 @@ class CellExecuteEventProducer {
|
|
|
122
126
|
if (notebookPanel.content === args.notebook) {
|
|
123
127
|
const executedCell = {
|
|
124
128
|
id: args.cell.model.id,
|
|
125
|
-
index: args.notebook.widgets.findIndex(value => value == args.cell)
|
|
129
|
+
index: args.notebook.widgets.findIndex(value => value == args.cell),
|
|
130
|
+
type: args.cell.model.type
|
|
126
131
|
};
|
|
127
132
|
const event = {
|
|
128
133
|
eventName: CellExecuteEventProducer.id,
|
|
@@ -149,9 +154,11 @@ class CellRemoveEventProducer {
|
|
|
149
154
|
listen(notebookPanel, pioneer) {
|
|
150
155
|
var _a;
|
|
151
156
|
(_a = notebookPanel.content.model) === null || _a === void 0 ? void 0 : _a.cells.changed.connect(async (_, args) => {
|
|
157
|
+
var _a;
|
|
152
158
|
if (args.type === 'remove') {
|
|
153
159
|
const removedCell = {
|
|
154
|
-
index: args.oldIndex
|
|
160
|
+
index: args.oldIndex,
|
|
161
|
+
type: (_a = notebookPanel.content.model) === null || _a === void 0 ? void 0 : _a.cells.get(args.oldIndex).type
|
|
155
162
|
};
|
|
156
163
|
const event = {
|
|
157
164
|
eventName: CellRemoveEventProducer.id,
|
|
@@ -175,12 +182,13 @@ export { CellRemoveEventProducer };
|
|
|
175
182
|
class ClipboardCopyEventProducer {
|
|
176
183
|
listen(notebookPanel, pioneer) {
|
|
177
184
|
notebookPanel.node.addEventListener('copy', async () => {
|
|
178
|
-
var _a, _b;
|
|
185
|
+
var _a, _b, _c;
|
|
179
186
|
const cell = {
|
|
180
187
|
id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
|
|
181
|
-
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell)
|
|
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
|
|
182
190
|
};
|
|
183
|
-
const text = (
|
|
191
|
+
const text = (_c = document.getSelection()) === null || _c === void 0 ? void 0 : _c.toString();
|
|
184
192
|
const event = {
|
|
185
193
|
eventName: ClipboardCopyEventProducer.id,
|
|
186
194
|
eventTime: Date.now(),
|
|
@@ -203,12 +211,13 @@ export { ClipboardCopyEventProducer };
|
|
|
203
211
|
class ClipboardCutEventProducer {
|
|
204
212
|
listen(notebookPanel, pioneer) {
|
|
205
213
|
notebookPanel.node.addEventListener('cut', async () => {
|
|
206
|
-
var _a, _b;
|
|
214
|
+
var _a, _b, _c;
|
|
207
215
|
const cell = {
|
|
208
216
|
id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
|
|
209
|
-
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell)
|
|
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
|
|
210
219
|
};
|
|
211
|
-
const text = (
|
|
220
|
+
const text = (_c = document.getSelection()) === null || _c === void 0 ? void 0 : _c.toString();
|
|
212
221
|
const event = {
|
|
213
222
|
eventName: ClipboardCutEventProducer.id,
|
|
214
223
|
eventTime: Date.now(),
|
|
@@ -231,10 +240,11 @@ export { ClipboardCutEventProducer };
|
|
|
231
240
|
class ClipboardPasteEventProducer {
|
|
232
241
|
listen(notebookPanel, pioneer) {
|
|
233
242
|
notebookPanel.node.addEventListener('paste', async (e) => {
|
|
234
|
-
var _a;
|
|
243
|
+
var _a, _b;
|
|
235
244
|
const cell = {
|
|
236
245
|
id: (_a = notebookPanel.content.activeCell) === null || _a === void 0 ? void 0 : _a.model.id,
|
|
237
|
-
index: notebookPanel.content.widgets.findIndex(value => value === notebookPanel.content.activeCell)
|
|
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
|
|
238
248
|
};
|
|
239
249
|
const text = (e.clipboardData || window.clipboardData).getData('text');
|
|
240
250
|
const event = {
|
|
@@ -336,7 +346,8 @@ const getVisibleCells = (notebookPanel) => {
|
|
|
336
346
|
if (cellTop <= viewBottom && cellBottom >= viewTop) {
|
|
337
347
|
visibleCells.push({
|
|
338
348
|
id: cell.model.id,
|
|
339
|
-
index: index
|
|
349
|
+
index: index,
|
|
350
|
+
type: cell.model.type
|
|
340
351
|
});
|
|
341
352
|
}
|
|
342
353
|
}
|
|
@@ -347,7 +358,9 @@ class NotebookScrollEventProducer {
|
|
|
347
358
|
this.timeout = 0;
|
|
348
359
|
}
|
|
349
360
|
listen(notebookPanel, pioneer) {
|
|
350
|
-
notebookPanel.node
|
|
361
|
+
notebookPanel.node
|
|
362
|
+
.getElementsByClassName('jp-WindowedPanel-outer')[0]
|
|
363
|
+
.addEventListener('scroll', async (e) => {
|
|
351
364
|
e.stopPropagation();
|
|
352
365
|
clearTimeout(this.timeout);
|
|
353
366
|
await new Promise(resolve => (this.timeout = window.setTimeout(resolve, 1500))); // wait 1.5 seconds before preceding
|