@difizen/libro-core 0.1.18 → 0.1.19
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/es/cell/libro-cell-view.js +2 -2
- package/es/command/document-commands.d.ts.map +1 -1
- package/es/command/document-commands.js +6 -1
- package/es/command/libro-command-contribution.d.ts.map +1 -1
- package/es/command/libro-command-contribution.js +75 -45
- package/es/libro-model.d.ts +6 -6
- package/es/libro-model.d.ts.map +1 -1
- package/es/libro-model.js +18 -9
- package/es/libro-protocol.d.ts +26 -3
- package/es/libro-protocol.d.ts.map +1 -1
- package/es/libro-service.d.ts +36 -3
- package/es/libro-service.d.ts.map +1 -1
- package/es/libro-service.js +97 -2
- package/es/libro-view.d.ts +5 -0
- package/es/libro-view.d.ts.map +1 -1
- package/es/libro-view.js +13 -2
- package/es/toolbar/libro-toolbar.d.ts.map +1 -1
- package/es/toolbar/libro-toolbar.js +16 -0
- package/package.json +5 -5
- package/src/cell/libro-cell-view.tsx +2 -2
- package/src/command/document-commands.ts +6 -1
- package/src/command/libro-command-contribution.ts +20 -1
- package/src/libro-model.ts +16 -8
- package/src/libro-protocol.ts +29 -4
- package/src/libro-service.ts +109 -3
- package/src/libro-view.tsx +9 -1
- package/src/toolbar/libro-toolbar.tsx +13 -0
package/es/libro-service.js
CHANGED
|
@@ -14,7 +14,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
14
14
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
15
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
16
16
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
17
|
-
import { Emitter } from '@difizen/mana-app';
|
|
17
|
+
import { DisposableCollection, Emitter } from '@difizen/mana-app';
|
|
18
18
|
import { ThemeService, ViewManager } from '@difizen/mana-app';
|
|
19
19
|
import { inject, singleton } from '@difizen/mana-app';
|
|
20
20
|
import { prop } from '@difizen/mana-app';
|
|
@@ -26,6 +26,7 @@ export var LibroService = (_dec = singleton({
|
|
|
26
26
|
function LibroService(themeService) {
|
|
27
27
|
var _this = this;
|
|
28
28
|
_classCallCheck(this, LibroService);
|
|
29
|
+
this.toDispose = new DisposableCollection();
|
|
29
30
|
_initializerDefineProperty(this, "libroModelFactory", _descriptor, this);
|
|
30
31
|
_initializerDefineProperty(this, "viewManager", _descriptor2, this);
|
|
31
32
|
_initializerDefineProperty(this, "libroViewTracker", _descriptor3, this);
|
|
@@ -36,7 +37,15 @@ export var LibroService = (_dec = singleton({
|
|
|
36
37
|
_initializerDefineProperty(this, "_focus", _descriptor6, this);
|
|
37
38
|
this.onFocusChangedEmitter = new Emitter();
|
|
38
39
|
this.onNotebookViewCreatedEmitter = new Emitter();
|
|
40
|
+
this.onNotebookViewSavedEmitter = new Emitter();
|
|
41
|
+
this.onNotebookViewChangedEmitter = new Emitter();
|
|
42
|
+
this.onNotebookViewClosedEmitter = new Emitter();
|
|
43
|
+
this.onNotebookCellCreatedEmitter = new Emitter();
|
|
44
|
+
this.onNotebookCellSavedEmitter = new Emitter();
|
|
45
|
+
this.onNotebookCellChangedEmitter = new Emitter();
|
|
46
|
+
this.onNotebookCellDeletedEmitter = new Emitter();
|
|
39
47
|
_initializerDefineProperty(this, "_hasFocus", _descriptor7, this);
|
|
48
|
+
this.isDisposed = false;
|
|
40
49
|
this.themeService = themeService;
|
|
41
50
|
this.themeMode = this.themeService.getCurrentTheme().type;
|
|
42
51
|
this.themeService.onDidColorThemeChange(function (e) {
|
|
@@ -68,6 +77,41 @@ export var LibroService = (_dec = singleton({
|
|
|
68
77
|
get: function get() {
|
|
69
78
|
return this.onNotebookViewCreatedEmitter.event;
|
|
70
79
|
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "onNotebookViewSaved",
|
|
82
|
+
get: function get() {
|
|
83
|
+
return this.onNotebookViewSavedEmitter.event;
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "onNotebookViewChanged",
|
|
87
|
+
get: function get() {
|
|
88
|
+
return this.onNotebookViewChangedEmitter.event;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "onNotebookViewClosed",
|
|
92
|
+
get: function get() {
|
|
93
|
+
return this.onNotebookViewClosedEmitter.event;
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "onNotebookCellCreated",
|
|
97
|
+
get: function get() {
|
|
98
|
+
return this.onNotebookCellCreatedEmitter.event;
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "onNotebookCellSaved",
|
|
102
|
+
get: function get() {
|
|
103
|
+
return this.onNotebookCellSavedEmitter.event;
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "onNotebookCellChanged",
|
|
107
|
+
get: function get() {
|
|
108
|
+
return this.onNotebookCellChangedEmitter.event;
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "onNotebookCellDeleted",
|
|
112
|
+
get: function get() {
|
|
113
|
+
return this.onNotebookCellDeletedEmitter.event;
|
|
114
|
+
}
|
|
71
115
|
}, {
|
|
72
116
|
key: "focus",
|
|
73
117
|
get: function get() {
|
|
@@ -90,6 +134,7 @@ export var LibroService = (_dec = singleton({
|
|
|
90
134
|
}, {
|
|
91
135
|
key: "deleteLibroViewFromCache",
|
|
92
136
|
value: function deleteLibroViewFromCache(instance) {
|
|
137
|
+
this.onNotebookViewClosedEmitter.fire(instance);
|
|
93
138
|
this.libroViewTracker.viewCache.delete(instance.id);
|
|
94
139
|
this.libroViewTracker.modelCache.delete(instance.model.id);
|
|
95
140
|
}
|
|
@@ -110,6 +155,7 @@ export var LibroService = (_dec = singleton({
|
|
|
110
155
|
key: "getOrCreateView",
|
|
111
156
|
value: function () {
|
|
112
157
|
var _getOrCreateView = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
158
|
+
var _this2 = this;
|
|
113
159
|
var model, notebookViewPromise, notebookView;
|
|
114
160
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
115
161
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -124,8 +170,46 @@ export var LibroService = (_dec = singleton({
|
|
|
124
170
|
notebookView = _context.sent;
|
|
125
171
|
this.libroViewTracker.viewCache.set(notebookView.id, notebookView);
|
|
126
172
|
this.onNotebookViewCreatedEmitter.fire(notebookView);
|
|
173
|
+
this.toDispose.push(notebookView.onSave(function () {
|
|
174
|
+
_this2.onNotebookViewSavedEmitter.fire(notebookView);
|
|
175
|
+
}));
|
|
176
|
+
this.toDispose.push(notebookView.model.onCellContentChanged(function (e) {
|
|
177
|
+
_this2.onNotebookCellChangedEmitter.fire(e);
|
|
178
|
+
}));
|
|
179
|
+
this.toDispose.push(notebookView.model.onCellViewChanged(function (e) {
|
|
180
|
+
var changes = {
|
|
181
|
+
libroView: notebookView,
|
|
182
|
+
cellChanges: [],
|
|
183
|
+
contentChanges: []
|
|
184
|
+
};
|
|
185
|
+
if (e.delete) {
|
|
186
|
+
var _e$delete;
|
|
187
|
+
changes.contentChanges.push({
|
|
188
|
+
range: {
|
|
189
|
+
start: e.delete.index,
|
|
190
|
+
end: e.delete.index + ((_e$delete = e.delete) === null || _e$delete === void 0 ? void 0 : _e$delete.number)
|
|
191
|
+
},
|
|
192
|
+
removedCells: e.delete.cells,
|
|
193
|
+
addedCells: []
|
|
194
|
+
});
|
|
195
|
+
_this2.onNotebookCellDeletedEmitter.fire(e.delete.cells);
|
|
196
|
+
}
|
|
197
|
+
if (e.insert) {
|
|
198
|
+
var _e$insert;
|
|
199
|
+
changes.contentChanges.push({
|
|
200
|
+
range: {
|
|
201
|
+
start: e.insert.index,
|
|
202
|
+
end: e.insert.index + ((_e$insert = e.insert) === null || _e$insert === void 0 ? void 0 : _e$insert.cells.length)
|
|
203
|
+
},
|
|
204
|
+
removedCells: [],
|
|
205
|
+
addedCells: e.insert.cells
|
|
206
|
+
});
|
|
207
|
+
_this2.onNotebookCellCreatedEmitter.fire(e.insert.cells);
|
|
208
|
+
}
|
|
209
|
+
_this2.onNotebookViewChangedEmitter.fire(changes);
|
|
210
|
+
}));
|
|
127
211
|
return _context.abrupt("return", notebookViewPromise);
|
|
128
|
-
case
|
|
212
|
+
case 11:
|
|
129
213
|
case "end":
|
|
130
214
|
return _context.stop();
|
|
131
215
|
}
|
|
@@ -147,6 +231,17 @@ export var LibroService = (_dec = singleton({
|
|
|
147
231
|
value: function setHasFocus(hasFocus) {
|
|
148
232
|
this._hasFocus = hasFocus;
|
|
149
233
|
}
|
|
234
|
+
}, {
|
|
235
|
+
key: "disposed",
|
|
236
|
+
get: function get() {
|
|
237
|
+
return this.isDisposed;
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
key: "dispose",
|
|
241
|
+
value: function dispose() {
|
|
242
|
+
this.toDispose.dispose();
|
|
243
|
+
this.isDisposed = true;
|
|
244
|
+
}
|
|
150
245
|
}]);
|
|
151
246
|
return LibroService;
|
|
152
247
|
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroModelFactory", [_dec2], {
|
package/es/libro-view.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IModelContentChange } from '@difizen/libro-code-editor';
|
|
1
2
|
import { BaseView, ViewManager, Deferred, DisposableCollection, Emitter, ConfigurationService } from '@difizen/mana-app';
|
|
2
3
|
import type { FC, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
3
4
|
import { CellService } from './cell/index.js';
|
|
@@ -27,6 +28,8 @@ export declare class LibroView extends BaseView implements NotebookView {
|
|
|
27
28
|
dndItemRender: ForwardRefExoticComponent<DndItemProps & RefAttributes<HTMLDivElement>>;
|
|
28
29
|
protected onCellCreateEmitter: Emitter<CellView>;
|
|
29
30
|
get onCellCreate(): import("@difizen/mana-app").Event<CellView>;
|
|
31
|
+
protected onCellDeleteEmitter: Emitter<CellView>;
|
|
32
|
+
get onCellDelete(): import("@difizen/mana-app").Event<CellView>;
|
|
30
33
|
onBlurEmitter: Emitter;
|
|
31
34
|
get onBlur(): import("@difizen/mana-app").Event<any>;
|
|
32
35
|
cellService: CellService;
|
|
@@ -46,6 +49,8 @@ export declare class LibroView extends BaseView implements NotebookView {
|
|
|
46
49
|
saving?: boolean;
|
|
47
50
|
onSaveEmitter: Emitter<boolean>;
|
|
48
51
|
get onSave(): import("@difizen/mana-app").Event<boolean>;
|
|
52
|
+
onCellContentChangedEmitter: Emitter<IModelContentChange[]>;
|
|
53
|
+
get onCellContentChanged(): import("@difizen/mana-app").Event<IModelContentChange[]>;
|
|
49
54
|
runCellEmitter: Emitter<CellView>;
|
|
50
55
|
get onRunCell(): import("@difizen/mana-app").Event<CellView>;
|
|
51
56
|
cellScrollEmitter: Emitter<void>;
|
package/es/libro-view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-view.d.ts","sourceRoot":"","sources":["../src/libro-view.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libro-view.d.ts","sourceRoot":"","sources":["../src/libro-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;A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,gBAAgB,aAId;IAEF;;OAEG;IACH,iBAAiB,SAAgB,QAAQ,SAAS,MAAM,mBAqEtD;IAEF,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO;IAI9C,IAAI;CAYL"}
|
package/es/libro-view.js
CHANGED
|
@@ -214,6 +214,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
214
214
|
_this.dndContentRender = DndCellContainer;
|
|
215
215
|
_this.dndItemRender = DndCellItemRender;
|
|
216
216
|
_this.onCellCreateEmitter = new Emitter();
|
|
217
|
+
_this.onCellDeleteEmitter = new Emitter();
|
|
217
218
|
_this.onBlurEmitter = new Emitter();
|
|
218
219
|
_initializerDefineProperty(_this, "cellService", _descriptor, _assertThisInitialized(_this));
|
|
219
220
|
_initializerDefineProperty(_this, "libroService", _descriptor2, _assertThisInitialized(_this));
|
|
@@ -230,6 +231,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
230
231
|
_initializerDefineProperty(_this, "outputsScroll", _descriptor8, _assertThisInitialized(_this));
|
|
231
232
|
_initializerDefineProperty(_this, "saving", _descriptor9, _assertThisInitialized(_this));
|
|
232
233
|
_this.onSaveEmitter = new Emitter();
|
|
234
|
+
_this.onCellContentChangedEmitter = new Emitter();
|
|
233
235
|
_this.runCellEmitter = new Emitter();
|
|
234
236
|
_this.cellScrollEmitter = new Emitter();
|
|
235
237
|
_this.initializedDefer = new Deferred();
|
|
@@ -1728,6 +1730,11 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1728
1730
|
get: function get() {
|
|
1729
1731
|
return this.onCellCreateEmitter.event;
|
|
1730
1732
|
}
|
|
1733
|
+
}, {
|
|
1734
|
+
key: "onCellDelete",
|
|
1735
|
+
get: function get() {
|
|
1736
|
+
return this.onCellDeleteEmitter.event;
|
|
1737
|
+
}
|
|
1731
1738
|
}, {
|
|
1732
1739
|
key: "onBlur",
|
|
1733
1740
|
get: function get() {
|
|
@@ -1745,6 +1752,11 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1745
1752
|
get: function get() {
|
|
1746
1753
|
return this.onSaveEmitter.event;
|
|
1747
1754
|
}
|
|
1755
|
+
}, {
|
|
1756
|
+
key: "onCellContentChanged",
|
|
1757
|
+
get: function get() {
|
|
1758
|
+
return this.onCellContentChangedEmitter.event;
|
|
1759
|
+
}
|
|
1748
1760
|
}, {
|
|
1749
1761
|
key: "onRunCell",
|
|
1750
1762
|
get: function get() {
|
|
@@ -1824,9 +1836,8 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1824
1836
|
//
|
|
1825
1837
|
});
|
|
1826
1838
|
_this2.toDispose.push(watch(_this2.model, 'cells', function () {
|
|
1827
|
-
var _this2$model$onChange, _this2$model
|
|
1839
|
+
var _this2$model$onChange, _this2$model;
|
|
1828
1840
|
(_this2$model$onChange = (_this2$model = _this2.model).onChange) === null || _this2$model$onChange === void 0 || _this2$model$onChange.call(_this2$model);
|
|
1829
|
-
(_this2$model$onSource = (_this2$model2 = _this2.model).onSourceChange) === null || _this2$model$onSource === void 0 || _this2$model$onSource.call(_this2$model2);
|
|
1830
1841
|
}));
|
|
1831
1842
|
_this2.initializedDefer.resolve();
|
|
1832
1843
|
}, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/libro-toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAEL,YAAY,EAEZ,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA0BnD,qBACa,wBAAyB,YAAW,mBAAmB;IAC5C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAC9C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpE,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"libro-toolbar.d.ts","sourceRoot":"","sources":["../../src/toolbar/libro-toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAEL,YAAY,EAEZ,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA0BnD,qBACa,wBAAyB,YAAW,mBAAmB;IAC5C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAC9C,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpE,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;CA2LtD"}
|
|
@@ -103,6 +103,22 @@ export var LibroToolbarContribution = (_dec = singleton({
|
|
|
103
103
|
group: ['group2'],
|
|
104
104
|
order: 'c-all'
|
|
105
105
|
});
|
|
106
|
+
registry.registerItem({
|
|
107
|
+
id: DocumentCommands['FormatCell'].id,
|
|
108
|
+
command: DocumentCommands['FormatCell'].id,
|
|
109
|
+
tooltip: /*#__PURE__*/_jsxs("div", {
|
|
110
|
+
className: "libro-side-tooltip",
|
|
111
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
112
|
+
className: "libro-tooltip-text",
|
|
113
|
+
children: l10n.t('格式化代码')
|
|
114
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
115
|
+
className: "libro-tooltip-keybind",
|
|
116
|
+
children: "Shift+Option+F"
|
|
117
|
+
})]
|
|
118
|
+
}),
|
|
119
|
+
group: ['sidetoolbar1'],
|
|
120
|
+
order: 'd'
|
|
121
|
+
});
|
|
106
122
|
registry.registerItem({
|
|
107
123
|
id: NotebookCommands['MoveCellUp'].id,
|
|
108
124
|
command: NotebookCommands['MoveCellUp'].id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@ant-design/icons": "^5.1.0",
|
|
37
|
-
"@difizen/libro-code-editor": "^0.1.
|
|
38
|
-
"@difizen/libro-common": "^0.1.
|
|
39
|
-
"@difizen/libro-shared-model": "^0.1.
|
|
40
|
-
"@difizen/libro-virtualized": "^0.1.
|
|
37
|
+
"@difizen/libro-code-editor": "^0.1.19",
|
|
38
|
+
"@difizen/libro-common": "^0.1.19",
|
|
39
|
+
"@difizen/libro-shared-model": "^0.1.19",
|
|
40
|
+
"@difizen/libro-virtualized": "^0.1.19",
|
|
41
41
|
"@difizen/mana-app": "latest",
|
|
42
42
|
"@difizen/mana-l10n": "latest",
|
|
43
43
|
"@difizen/mana-react": "latest",
|
|
@@ -71,13 +71,13 @@ export class LibroCellView extends BaseView implements CellView {
|
|
|
71
71
|
this.toDispose.push(
|
|
72
72
|
watch(this.model, 'value', () => {
|
|
73
73
|
this.parent.model.onChange?.();
|
|
74
|
-
this.parent.model.onSourceChange?.();
|
|
74
|
+
this.parent.model.onSourceChange?.([this]);
|
|
75
75
|
}),
|
|
76
76
|
);
|
|
77
77
|
this.toDispose.push(
|
|
78
78
|
watch(this.model, 'type', () => {
|
|
79
79
|
this.parent.model.onChange?.();
|
|
80
|
-
this.parent.model.onSourceChange?.();
|
|
80
|
+
this.parent.model.onSourceChange?.([this]);
|
|
81
81
|
}),
|
|
82
82
|
);
|
|
83
83
|
if (ExecutableCellModel.is(this.model)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SaveOutlined, SettingOutlined } from '@ant-design/icons';
|
|
1
|
+
import { ClearOutlined, SaveOutlined, SettingOutlined } from '@ant-design/icons';
|
|
2
2
|
import type { Command } from '@difizen/mana-app';
|
|
3
3
|
|
|
4
4
|
export const DocumentCommands: Record<string, Command & { keybind?: string }> = {
|
|
@@ -13,4 +13,9 @@ export const DocumentCommands: Record<string, Command & { keybind?: string }> =
|
|
|
13
13
|
icon: SettingOutlined,
|
|
14
14
|
label: 'Setting',
|
|
15
15
|
},
|
|
16
|
+
FormatCell: {
|
|
17
|
+
id: 'document.notebook.format_cell',
|
|
18
|
+
icon: ClearOutlined,
|
|
19
|
+
label: 'format cell code',
|
|
20
|
+
},
|
|
16
21
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MIME } from '@difizen/libro-common';
|
|
1
2
|
import type { CommandRegistry } from '@difizen/mana-app';
|
|
2
3
|
import {
|
|
3
4
|
inject,
|
|
@@ -8,7 +9,7 @@ import {
|
|
|
8
9
|
import { equals } from '@difizen/mana-app';
|
|
9
10
|
import { v4 } from 'uuid';
|
|
10
11
|
|
|
11
|
-
import { LibroCellView, ExecutableCellModel } from '../cell/index.js';
|
|
12
|
+
import { LibroCellView, ExecutableCellModel, EditorCellView } from '../cell/index.js';
|
|
12
13
|
import type { LibroEditorCellView } from '../cell/index.js';
|
|
13
14
|
import { LirboContextKey } from '../libro-context-key.js';
|
|
14
15
|
import type { CellView, NotebookView } from '../libro-protocol.js';
|
|
@@ -1101,6 +1102,24 @@ export class LibroCommandContribution implements CommandContribution {
|
|
|
1101
1102
|
return !libro?.model.readOnly && path === LibroToolbarArea.HeaderRight;
|
|
1102
1103
|
},
|
|
1103
1104
|
});
|
|
1105
|
+
this.libroCommand.registerLibroCommand(command, DocumentCommands['FormatCell'], {
|
|
1106
|
+
execute: async (cell) => {
|
|
1107
|
+
if (EditorCellView.is(cell) && cell.editor?.model.mimeType === MIME.python) {
|
|
1108
|
+
cell.editor?.format();
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
isVisible: (cell, libro, path) => {
|
|
1112
|
+
if (!libro || !(libro instanceof LibroView)) {
|
|
1113
|
+
return false;
|
|
1114
|
+
}
|
|
1115
|
+
return (
|
|
1116
|
+
!libro?.model.readOnly &&
|
|
1117
|
+
EditorCellView.is(cell) &&
|
|
1118
|
+
cell.model.mimeType === MIME.python &&
|
|
1119
|
+
path === LibroToolbarArea.CellRight
|
|
1120
|
+
);
|
|
1121
|
+
},
|
|
1122
|
+
});
|
|
1104
1123
|
this.libroCommand.registerLibroCommand(
|
|
1105
1124
|
command,
|
|
1106
1125
|
NotebookCommands['UndoCellAction'],
|
package/src/libro-model.ts
CHANGED
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
ScrollParams,
|
|
27
27
|
CellView,
|
|
28
28
|
MouseMode,
|
|
29
|
+
ICellContentChange,
|
|
29
30
|
} from './libro-protocol.js';
|
|
30
31
|
import { EnterEditModeWhenAddCell } from './libro-setting.js';
|
|
31
32
|
import { VirtualizedManagerHelper } from './virtualized-manager-helper.js';
|
|
@@ -60,9 +61,9 @@ export class LibroModel implements NotebookModel, DndListModel {
|
|
|
60
61
|
return this.onCommandModeChangedEmitter.event;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
protected
|
|
64
|
-
get
|
|
65
|
-
return this.
|
|
64
|
+
protected onChangedEmitter: Emitter<boolean> = new Emitter();
|
|
65
|
+
get onChanged() {
|
|
66
|
+
return this.onChangedEmitter.event;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
protected onSourceChangedEmitter: Emitter<boolean> = new Emitter();
|
|
@@ -70,6 +71,15 @@ export class LibroModel implements NotebookModel, DndListModel {
|
|
|
70
71
|
return this.onSourceChangedEmitter.event;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
protected onCellContentChangedEmitter: Emitter<ICellContentChange> = new Emitter();
|
|
75
|
+
get onCellContentChanged() {
|
|
76
|
+
return this.onCellContentChangedEmitter.event;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onCellContentChange(change: ICellContentChange) {
|
|
80
|
+
this.onCellContentChangedEmitter.fire(change);
|
|
81
|
+
}
|
|
82
|
+
|
|
73
83
|
id: string;
|
|
74
84
|
|
|
75
85
|
/**
|
|
@@ -219,9 +229,10 @@ export class LibroModel implements NotebookModel, DndListModel {
|
|
|
219
229
|
insert: { index: currpos, cells: cellViews },
|
|
220
230
|
});
|
|
221
231
|
} else if (delta.delete !== null && delta.delete !== undefined) {
|
|
232
|
+
const cellViews = this.cells.slice(currpos, currpos + delta.delete);
|
|
222
233
|
this.removeRange(currpos, currpos + delta.delete);
|
|
223
234
|
this.cellViewChangeEmitter.fire({
|
|
224
|
-
delete: { index: currpos, number: delta.delete },
|
|
235
|
+
delete: { index: currpos, number: delta.delete, cells: cellViews },
|
|
225
236
|
});
|
|
226
237
|
} else if (delta.retain !== null && delta.retain !== undefined) {
|
|
227
238
|
currpos += delta.retain;
|
|
@@ -290,12 +301,9 @@ export class LibroModel implements NotebookModel, DndListModel {
|
|
|
290
301
|
});
|
|
291
302
|
}
|
|
292
303
|
|
|
293
|
-
/**
|
|
294
|
-
* cell list change or cell content change
|
|
295
|
-
*/
|
|
296
304
|
onChange() {
|
|
297
305
|
this.dirty = true;
|
|
298
|
-
this.
|
|
306
|
+
this.onChangedEmitter.fire(true);
|
|
299
307
|
}
|
|
300
308
|
|
|
301
309
|
onSourceChange() {
|
package/src/libro-protocol.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/unified-signatures */
|
|
2
|
-
import type { IModel } from '@difizen/libro-code-editor';
|
|
2
|
+
import type { IModel, IModelContentChange } from '@difizen/libro-code-editor';
|
|
3
3
|
import type {
|
|
4
4
|
CellType,
|
|
5
5
|
ICell,
|
|
@@ -64,6 +64,11 @@ export interface ScrollParams {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export type NotebookModel = BaseNotebookModel & DndListModel;
|
|
67
|
+
|
|
68
|
+
export interface ICellContentChange {
|
|
69
|
+
cell: CellView;
|
|
70
|
+
changes: IModelContentChange[];
|
|
71
|
+
}
|
|
67
72
|
export interface BaseNotebookModel {
|
|
68
73
|
id: string;
|
|
69
74
|
/**
|
|
@@ -98,12 +103,26 @@ export interface BaseNotebookModel {
|
|
|
98
103
|
|
|
99
104
|
onCommandModeChanged: Event<boolean>;
|
|
100
105
|
|
|
101
|
-
|
|
106
|
+
/**
|
|
107
|
+
* all changes
|
|
108
|
+
*/
|
|
109
|
+
onChanged: Event<boolean>;
|
|
102
110
|
|
|
111
|
+
/**
|
|
112
|
+
* cell content & type
|
|
113
|
+
*/
|
|
103
114
|
onSourceChanged: Event<boolean>;
|
|
104
115
|
|
|
116
|
+
/**
|
|
117
|
+
* cell create & delete
|
|
118
|
+
*/
|
|
105
119
|
onCellViewChanged: Event<CellViewChange>;
|
|
106
120
|
|
|
121
|
+
/**
|
|
122
|
+
* cell content change detail
|
|
123
|
+
*/
|
|
124
|
+
onCellContentChanged: Event<ICellContentChange>;
|
|
125
|
+
|
|
107
126
|
getCells: () => CellView[];
|
|
108
127
|
|
|
109
128
|
/**
|
|
@@ -171,9 +190,15 @@ export interface BaseNotebookModel {
|
|
|
171
190
|
|
|
172
191
|
enterEditMode?: () => void;
|
|
173
192
|
|
|
193
|
+
/**
|
|
194
|
+
* all changes: cell value\cell type\cell output\ cell executecount\ cell or notebook metadata\cell create & delete
|
|
195
|
+
* @returns
|
|
196
|
+
*/
|
|
174
197
|
onChange?: () => void;
|
|
175
198
|
|
|
176
|
-
onSourceChange?: () => void;
|
|
199
|
+
onSourceChange?: (cells: CellView[]) => void;
|
|
200
|
+
|
|
201
|
+
onCellContentChange: (changes: ICellContentChange) => void;
|
|
177
202
|
|
|
178
203
|
interrupt?: () => void;
|
|
179
204
|
|
|
@@ -290,7 +315,7 @@ export interface CellViewOptions {
|
|
|
290
315
|
|
|
291
316
|
export interface CellViewChange {
|
|
292
317
|
insert?: { cells: CellView[]; index: number };
|
|
293
|
-
delete?: { index: number; number: number };
|
|
318
|
+
delete?: { index: number; number: number; cells: CellView[] };
|
|
294
319
|
}
|
|
295
320
|
|
|
296
321
|
export interface CellModel extends IModel, Disposable {
|
package/src/libro-service.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Disposable } from '@difizen/mana-app';
|
|
2
|
+
import { DisposableCollection, Emitter } from '@difizen/mana-app';
|
|
2
3
|
import { ThemeService, ViewManager } from '@difizen/mana-app';
|
|
3
4
|
import { inject, singleton } from '@difizen/mana-app';
|
|
4
5
|
import { prop } from '@difizen/mana-app';
|
|
5
6
|
|
|
6
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
CellView,
|
|
9
|
+
ICellContentChange,
|
|
10
|
+
NotebookOption,
|
|
11
|
+
NotebookView,
|
|
12
|
+
} from './libro-protocol.js';
|
|
7
13
|
import {
|
|
8
14
|
notebookViewFactoryId,
|
|
9
15
|
ModelFactory,
|
|
@@ -11,8 +17,24 @@ import {
|
|
|
11
17
|
} from './libro-protocol.js';
|
|
12
18
|
import { LibroViewTracker } from './libro-view-tracker.js';
|
|
13
19
|
|
|
20
|
+
export interface NotebookViewChange {
|
|
21
|
+
libroView: NotebookView;
|
|
22
|
+
contentChanges: Array<{
|
|
23
|
+
range: {
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
};
|
|
27
|
+
addedCells: CellView[];
|
|
28
|
+
removedCells: CellView[];
|
|
29
|
+
}>;
|
|
30
|
+
cellChanges: Array<{
|
|
31
|
+
cell: CellView;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
|
|
14
35
|
@singleton({ contrib: NotebookService })
|
|
15
|
-
export class LibroService implements NotebookService {
|
|
36
|
+
export class LibroService implements NotebookService, Disposable {
|
|
37
|
+
protected toDispose = new DisposableCollection();
|
|
16
38
|
@inject(ModelFactory) protected libroModelFactory: ModelFactory;
|
|
17
39
|
@inject(ViewManager) protected viewManager: ViewManager;
|
|
18
40
|
@inject(LibroViewTracker) protected libroViewTracker: LibroViewTracker;
|
|
@@ -50,6 +72,34 @@ export class LibroService implements NotebookService {
|
|
|
50
72
|
get onNotebookViewCreated() {
|
|
51
73
|
return this.onNotebookViewCreatedEmitter.event;
|
|
52
74
|
}
|
|
75
|
+
protected onNotebookViewSavedEmitter: Emitter<NotebookView> = new Emitter();
|
|
76
|
+
get onNotebookViewSaved() {
|
|
77
|
+
return this.onNotebookViewSavedEmitter.event;
|
|
78
|
+
}
|
|
79
|
+
protected onNotebookViewChangedEmitter: Emitter<NotebookViewChange> = new Emitter();
|
|
80
|
+
get onNotebookViewChanged() {
|
|
81
|
+
return this.onNotebookViewChangedEmitter.event;
|
|
82
|
+
}
|
|
83
|
+
protected onNotebookViewClosedEmitter: Emitter<NotebookView> = new Emitter();
|
|
84
|
+
get onNotebookViewClosed() {
|
|
85
|
+
return this.onNotebookViewClosedEmitter.event;
|
|
86
|
+
}
|
|
87
|
+
protected onNotebookCellCreatedEmitter: Emitter<CellView[]> = new Emitter();
|
|
88
|
+
get onNotebookCellCreated() {
|
|
89
|
+
return this.onNotebookCellCreatedEmitter.event;
|
|
90
|
+
}
|
|
91
|
+
protected onNotebookCellSavedEmitter: Emitter<CellView[]> = new Emitter();
|
|
92
|
+
get onNotebookCellSaved() {
|
|
93
|
+
return this.onNotebookCellSavedEmitter.event;
|
|
94
|
+
}
|
|
95
|
+
protected onNotebookCellChangedEmitter: Emitter<ICellContentChange> = new Emitter();
|
|
96
|
+
get onNotebookCellChanged() {
|
|
97
|
+
return this.onNotebookCellChangedEmitter.event;
|
|
98
|
+
}
|
|
99
|
+
protected onNotebookCellDeletedEmitter: Emitter<CellView[]> = new Emitter();
|
|
100
|
+
get onNotebookCellDeleted() {
|
|
101
|
+
return this.onNotebookCellDeletedEmitter.event;
|
|
102
|
+
}
|
|
53
103
|
|
|
54
104
|
get focus(): NotebookView | undefined {
|
|
55
105
|
return this._focus;
|
|
@@ -68,6 +118,7 @@ export class LibroService implements NotebookService {
|
|
|
68
118
|
}
|
|
69
119
|
|
|
70
120
|
deleteLibroViewFromCache(instance: NotebookView) {
|
|
121
|
+
this.onNotebookViewClosedEmitter.fire(instance);
|
|
71
122
|
this.libroViewTracker.viewCache.delete(instance.id);
|
|
72
123
|
this.libroViewTracker.modelCache.delete(instance.model.id);
|
|
73
124
|
}
|
|
@@ -98,6 +149,52 @@ export class LibroService implements NotebookService {
|
|
|
98
149
|
const notebookView = await notebookViewPromise;
|
|
99
150
|
this.libroViewTracker.viewCache.set(notebookView.id, notebookView);
|
|
100
151
|
this.onNotebookViewCreatedEmitter.fire(notebookView);
|
|
152
|
+
this.toDispose.push(
|
|
153
|
+
notebookView.onSave(() => {
|
|
154
|
+
this.onNotebookViewSavedEmitter.fire(notebookView);
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
157
|
+
this.toDispose.push(
|
|
158
|
+
notebookView.model.onCellContentChanged((e) => {
|
|
159
|
+
this.onNotebookCellChangedEmitter.fire(e);
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
162
|
+
this.toDispose.push(
|
|
163
|
+
notebookView.model.onCellViewChanged((e) => {
|
|
164
|
+
const changes: NotebookViewChange = {
|
|
165
|
+
libroView: notebookView,
|
|
166
|
+
cellChanges: [],
|
|
167
|
+
contentChanges: [],
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
if (e.delete) {
|
|
171
|
+
changes.contentChanges.push({
|
|
172
|
+
range: {
|
|
173
|
+
start: e.delete.index,
|
|
174
|
+
end: e.delete.index + e.delete?.number,
|
|
175
|
+
},
|
|
176
|
+
removedCells: e.delete.cells,
|
|
177
|
+
addedCells: [],
|
|
178
|
+
});
|
|
179
|
+
this.onNotebookCellDeletedEmitter.fire(e.delete.cells);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (e.insert) {
|
|
183
|
+
changes.contentChanges.push({
|
|
184
|
+
range: {
|
|
185
|
+
start: e.insert.index,
|
|
186
|
+
end: e.insert.index + e.insert?.cells.length,
|
|
187
|
+
},
|
|
188
|
+
removedCells: [],
|
|
189
|
+
addedCells: e.insert.cells,
|
|
190
|
+
});
|
|
191
|
+
this.onNotebookCellCreatedEmitter.fire(e.insert.cells);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
this.onNotebookViewChangedEmitter.fire(changes);
|
|
195
|
+
}),
|
|
196
|
+
);
|
|
197
|
+
|
|
101
198
|
return notebookViewPromise;
|
|
102
199
|
}
|
|
103
200
|
|
|
@@ -109,4 +206,13 @@ export class LibroService implements NotebookService {
|
|
|
109
206
|
setHasFocus(hasFocus: boolean): void {
|
|
110
207
|
this._hasFocus = hasFocus;
|
|
111
208
|
}
|
|
209
|
+
|
|
210
|
+
protected isDisposed = false;
|
|
211
|
+
get disposed() {
|
|
212
|
+
return this.isDisposed;
|
|
213
|
+
}
|
|
214
|
+
dispose() {
|
|
215
|
+
this.toDispose.dispose();
|
|
216
|
+
this.isDisposed = true;
|
|
217
|
+
}
|
|
112
218
|
}
|