@difizen/libro-core 0.1.18 → 0.1.20
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/components/dnd-component/default-dnd-content.d.ts.map +1 -1
- package/es/components/dnd-component/default-dnd-content.js +3 -24
- package/es/components/libro-virtualized-render.js +1 -1
- package/es/libro-model.d.ts +7 -8
- package/es/libro-model.d.ts.map +1 -1
- package/es/libro-model.js +32 -21
- package/es/libro-protocol.d.ts +28 -6
- 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 +26 -61
- package/es/toolbar/libro-toolbar.d.ts.map +1 -1
- package/es/toolbar/libro-toolbar.js +16 -0
- package/es/virtualized-manager.d.ts +4 -0
- package/es/virtualized-manager.d.ts.map +1 -1
- package/es/virtualized-manager.js +7 -3
- 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/components/dnd-component/default-dnd-content.tsx +3 -19
- package/src/components/libro-virtualized-render.tsx +1 -1
- package/src/libro-model.ts +27 -20
- package/src/libro-protocol.ts +31 -8
- package/src/libro-service.ts +109 -3
- package/src/libro-view.tsx +22 -46
- package/src/toolbar/libro-toolbar.tsx +13 -0
- package/src/virtualized-manager.ts +14 -1
package/es/libro-service.d.ts
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
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
|
-
import type { NotebookOption, NotebookView } from './libro-protocol.js';
|
|
4
|
+
import type { CellView, ICellContentChange, NotebookOption, NotebookView } from './libro-protocol.js';
|
|
4
5
|
import { ModelFactory, NotebookService } from './libro-protocol.js';
|
|
5
6
|
import { LibroViewTracker } from './libro-view-tracker.js';
|
|
6
|
-
export
|
|
7
|
+
export interface NotebookViewChange {
|
|
8
|
+
libroView: NotebookView;
|
|
9
|
+
contentChanges: Array<{
|
|
10
|
+
range: {
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
};
|
|
14
|
+
addedCells: CellView[];
|
|
15
|
+
removedCells: CellView[];
|
|
16
|
+
}>;
|
|
17
|
+
cellChanges: Array<{
|
|
18
|
+
cell: CellView;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export declare class LibroService implements NotebookService, Disposable {
|
|
22
|
+
protected toDispose: DisposableCollection;
|
|
7
23
|
protected libroModelFactory: ModelFactory;
|
|
8
24
|
protected viewManager: ViewManager;
|
|
9
25
|
protected libroViewTracker: LibroViewTracker;
|
|
@@ -20,6 +36,20 @@ export declare class LibroService implements NotebookService {
|
|
|
20
36
|
get onFocusChanged(): import("@difizen/mana-app").Event<import("./libro-view.js").LibroView | undefined>;
|
|
21
37
|
protected onNotebookViewCreatedEmitter: Emitter<NotebookView>;
|
|
22
38
|
get onNotebookViewCreated(): import("@difizen/mana-app").Event<import("./libro-view.js").LibroView>;
|
|
39
|
+
protected onNotebookViewSavedEmitter: Emitter<NotebookView>;
|
|
40
|
+
get onNotebookViewSaved(): import("@difizen/mana-app").Event<import("./libro-view.js").LibroView>;
|
|
41
|
+
protected onNotebookViewChangedEmitter: Emitter<NotebookViewChange>;
|
|
42
|
+
get onNotebookViewChanged(): import("@difizen/mana-app").Event<NotebookViewChange>;
|
|
43
|
+
protected onNotebookViewClosedEmitter: Emitter<NotebookView>;
|
|
44
|
+
get onNotebookViewClosed(): import("@difizen/mana-app").Event<import("./libro-view.js").LibroView>;
|
|
45
|
+
protected onNotebookCellCreatedEmitter: Emitter<CellView[]>;
|
|
46
|
+
get onNotebookCellCreated(): import("@difizen/mana-app").Event<CellView[]>;
|
|
47
|
+
protected onNotebookCellSavedEmitter: Emitter<CellView[]>;
|
|
48
|
+
get onNotebookCellSaved(): import("@difizen/mana-app").Event<CellView[]>;
|
|
49
|
+
protected onNotebookCellChangedEmitter: Emitter<ICellContentChange>;
|
|
50
|
+
get onNotebookCellChanged(): import("@difizen/mana-app").Event<ICellContentChange>;
|
|
51
|
+
protected onNotebookCellDeletedEmitter: Emitter<CellView[]>;
|
|
52
|
+
get onNotebookCellDeleted(): import("@difizen/mana-app").Event<CellView[]>;
|
|
23
53
|
get focus(): NotebookView | undefined;
|
|
24
54
|
set focus(value: NotebookView | undefined);
|
|
25
55
|
get hasFocus(): boolean;
|
|
@@ -30,5 +60,8 @@ export declare class LibroService implements NotebookService {
|
|
|
30
60
|
getOrCreateView(options: NotebookOption): Promise<NotebookView>;
|
|
31
61
|
setActive(view?: NotebookView): void;
|
|
32
62
|
setHasFocus(hasFocus: boolean): void;
|
|
63
|
+
protected isDisposed: boolean;
|
|
64
|
+
get disposed(): boolean;
|
|
65
|
+
dispose(): void;
|
|
33
66
|
}
|
|
34
67
|
//# sourceMappingURL=libro-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-service.d.ts","sourceRoot":"","sources":["../src/libro-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"libro-service.d.ts","sourceRoot":"","sources":["../src/libro-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,YAAY,EAA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,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,IAAI;IAKpC,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAIpC,SAAS,CAAC,UAAU,UAAS;IAC7B,IAAI,QAAQ,YAEX;IACD,OAAO;CAIR"}
|
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;AAMtE,OAAO,EAKL,QAAQ,EAIR,WAAW,EAEX,QAAQ,EAER,oBAAoB,EACpB,OAAO,EAIP,oBAAoB,EAErB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,EAAE,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAI1E,OAAO,EACL,WAAW,EAIZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAS7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAyB,MAAM,qBAAqB,CAAC;AAC7E,OAAO,KAAK,EACV,WAAW,EACX,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,q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sB,IAClB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAChC;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,IAAI,CAAA;KAAE;IAsBhC,qBAAqB,SAAU,QAAQ,UAYrC;IAEF,sBAAsB,SAAU,QAAQ,UAatC;IAEF,yBAAyB,aAOvB;IAEF,wBAAwB,aAOtB;IAEF,QAAQ,UAAS;IAER,OAAO;IAQhB,gBAAgB,cAAe,OAAO,UAUpC;IAEF,aAAa,aAIX;IAEF,cAAc,SAAU,QAAQ,UAO9B;IAEF,YAAY,SAAU,QAAQ,UAO5B;IAEF,cAAc,SAAgB,QAAQ,mBA+BpC;IAEF,cAAc,SAAgB,QAAQ,mBA8BpC;IAEF,UAAU,SAAgB,QAAQ,mBAgChC;IACF,aAAa,aAEX;IAEF,SAAS,SAAgB,QAAQ,mBA0C/B;IACF,kBAAkB,aAKhB;IAEF,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();
|
|
@@ -570,18 +572,11 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
570
572
|
}
|
|
571
573
|
_this.runCells([cell]);
|
|
572
574
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
} else {
|
|
579
|
-
setTimeout(function () {
|
|
580
|
-
if (_this.activeCell) {
|
|
581
|
-
_this.model.scrollToView(_this.activeCell);
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
}
|
|
575
|
+
setTimeout(function () {
|
|
576
|
+
if (_this.activeCell) {
|
|
577
|
+
_this.model.scrollToView(_this.activeCell);
|
|
578
|
+
}
|
|
579
|
+
});
|
|
585
580
|
case 4:
|
|
586
581
|
case "end":
|
|
587
582
|
return _context10.stop();
|
|
@@ -937,11 +932,8 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
937
932
|
}
|
|
938
933
|
};
|
|
939
934
|
_this.clearAllOutputs = function () {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
cellIndex: 0
|
|
943
|
-
});
|
|
944
|
-
} // 清空所有 cell滚动到最上面
|
|
935
|
+
// 清空所有 cell滚动到最上面
|
|
936
|
+
_this.model.scrollToView(_this.model.cells[0]);
|
|
945
937
|
var _iterator7 = _createForOfIteratorHelper(_this.model.cells),
|
|
946
938
|
_step7;
|
|
947
939
|
try {
|
|
@@ -1149,13 +1141,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1149
1141
|
if (_this.findCellIndex(_this.activeCell) > 0) {
|
|
1150
1142
|
_this.extendContiguousSelectionTo(activeIndex - 1);
|
|
1151
1143
|
}
|
|
1152
|
-
|
|
1153
|
-
_this.model.scrollToCellView({
|
|
1154
|
-
cellIndex: _this.activeCellIndex
|
|
1155
|
-
});
|
|
1156
|
-
} else {
|
|
1157
|
-
_this.model.scrollToView(_this.activeCell);
|
|
1158
|
-
}
|
|
1144
|
+
_this.model.scrollToView(_this.activeCell);
|
|
1159
1145
|
}
|
|
1160
1146
|
};
|
|
1161
1147
|
_this.extendSelectionToTop = function () {
|
|
@@ -1163,13 +1149,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1163
1149
|
if (_this.findCellIndex(_this.activeCell) > 0) {
|
|
1164
1150
|
_this.extendContiguousSelectionTo(0);
|
|
1165
1151
|
}
|
|
1166
|
-
|
|
1167
|
-
_this.model.scrollToCellView({
|
|
1168
|
-
cellIndex: _this.activeCellIndex
|
|
1169
|
-
});
|
|
1170
|
-
} else {
|
|
1171
|
-
_this.model.scrollToView(_this.activeCell);
|
|
1172
|
-
}
|
|
1152
|
+
_this.model.scrollToView(_this.activeCell);
|
|
1173
1153
|
}
|
|
1174
1154
|
};
|
|
1175
1155
|
_this.extendSelectionBelow = function () {
|
|
@@ -1182,13 +1162,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1182
1162
|
if (_this.findCellIndex(_this.activeCell) >= 0) {
|
|
1183
1163
|
_this.extendContiguousSelectionTo(activeIndex + 1);
|
|
1184
1164
|
}
|
|
1185
|
-
|
|
1186
|
-
_this.model.scrollToCellView({
|
|
1187
|
-
cellIndex: _this.activeCellIndex
|
|
1188
|
-
});
|
|
1189
|
-
} else {
|
|
1190
|
-
_this.model.scrollToView(_this.activeCell);
|
|
1191
|
-
}
|
|
1165
|
+
_this.model.scrollToView(_this.activeCell);
|
|
1192
1166
|
}
|
|
1193
1167
|
};
|
|
1194
1168
|
_this.extendSelectionToBottom = function () {
|
|
@@ -1196,13 +1170,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1196
1170
|
if (_this.findCellIndex(_this.activeCell) > 0) {
|
|
1197
1171
|
_this.extendContiguousSelectionTo(_this.model.cells.length - 1);
|
|
1198
1172
|
}
|
|
1199
|
-
|
|
1200
|
-
_this.model.scrollToCellView({
|
|
1201
|
-
cellIndex: _this.activeCellIndex
|
|
1202
|
-
});
|
|
1203
|
-
} else {
|
|
1204
|
-
_this.model.scrollToView(_this.activeCell);
|
|
1205
|
-
}
|
|
1173
|
+
_this.model.scrollToView(_this.activeCell);
|
|
1206
1174
|
}
|
|
1207
1175
|
};
|
|
1208
1176
|
_this.enableOutputScrolling = function (cell) {
|
|
@@ -1307,13 +1275,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1307
1275
|
if (newSelectedCell) {
|
|
1308
1276
|
_this.model.selectCell(newSelectedCell);
|
|
1309
1277
|
_this.model.selections = [];
|
|
1310
|
-
|
|
1311
|
-
_this.model.scrollToCellView({
|
|
1312
|
-
cellIndex: _this.activeCellIndex
|
|
1313
|
-
});
|
|
1314
|
-
} else {
|
|
1315
|
-
_this.model.scrollToView(newSelectedCell);
|
|
1316
|
-
}
|
|
1278
|
+
_this.model.scrollToView(newSelectedCell);
|
|
1317
1279
|
}
|
|
1318
1280
|
};
|
|
1319
1281
|
_this.moveCursorUp = function (cell) {
|
|
@@ -1321,13 +1283,7 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1321
1283
|
if (newSelectedCell) {
|
|
1322
1284
|
_this.model.selectCell(newSelectedCell);
|
|
1323
1285
|
_this.model.selections = [];
|
|
1324
|
-
|
|
1325
|
-
_this.model.scrollToCellView({
|
|
1326
|
-
cellIndex: _this.activeCellIndex
|
|
1327
|
-
});
|
|
1328
|
-
} else {
|
|
1329
|
-
_this.model.scrollToView(newSelectedCell);
|
|
1330
|
-
}
|
|
1286
|
+
_this.model.scrollToView(newSelectedCell);
|
|
1331
1287
|
}
|
|
1332
1288
|
};
|
|
1333
1289
|
_this.mergeCellBelow = /*#__PURE__*/function () {
|
|
@@ -1728,6 +1684,11 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1728
1684
|
get: function get() {
|
|
1729
1685
|
return this.onCellCreateEmitter.event;
|
|
1730
1686
|
}
|
|
1687
|
+
}, {
|
|
1688
|
+
key: "onCellDelete",
|
|
1689
|
+
get: function get() {
|
|
1690
|
+
return this.onCellDeleteEmitter.event;
|
|
1691
|
+
}
|
|
1731
1692
|
}, {
|
|
1732
1693
|
key: "onBlur",
|
|
1733
1694
|
get: function get() {
|
|
@@ -1745,6 +1706,11 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1745
1706
|
get: function get() {
|
|
1746
1707
|
return this.onSaveEmitter.event;
|
|
1747
1708
|
}
|
|
1709
|
+
}, {
|
|
1710
|
+
key: "onCellContentChanged",
|
|
1711
|
+
get: function get() {
|
|
1712
|
+
return this.onCellContentChangedEmitter.event;
|
|
1713
|
+
}
|
|
1748
1714
|
}, {
|
|
1749
1715
|
key: "onRunCell",
|
|
1750
1716
|
get: function get() {
|
|
@@ -1824,9 +1790,8 @@ export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId),
|
|
|
1824
1790
|
//
|
|
1825
1791
|
});
|
|
1826
1792
|
_this2.toDispose.push(watch(_this2.model, 'cells', function () {
|
|
1827
|
-
var _this2$model$onChange, _this2$model
|
|
1793
|
+
var _this2$model$onChange, _this2$model;
|
|
1828
1794
|
(_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
1795
|
}));
|
|
1831
1796
|
_this2.initializedDefer.resolve();
|
|
1832
1797
|
}, 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,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { NotebookModel } from './libro-protocol.js';
|
|
2
|
+
import { VirtualizedManagerOption } from './libro-protocol.js';
|
|
1
3
|
export interface IVirtualizedManager {
|
|
2
4
|
openVirtualized: (length: number, size?: number, path?: string) => Promise<boolean>;
|
|
3
5
|
isVirtualized: boolean;
|
|
@@ -8,6 +10,8 @@ export declare class VirtualizedManager implements IVirtualizedManager {
|
|
|
8
10
|
* 所以它用于滚动到某个cell的判断依据是没有问题的。
|
|
9
11
|
*/
|
|
10
12
|
isVirtualized: boolean;
|
|
13
|
+
libroModel: NotebookModel;
|
|
14
|
+
constructor(virtualizedManagerOption: VirtualizedManagerOption);
|
|
11
15
|
/**
|
|
12
16
|
*
|
|
13
17
|
* @param length cell个数
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtualized-manager.d.ts","sourceRoot":"","sources":["../src/virtualized-manager.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACpF,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,qBACa,kBAAmB,YAAW,mBAAmB;IAC5D;;;OAGG;IAEH,aAAa,UAAS;
|
|
1
|
+
{"version":3,"file":"virtualized-manager.d.ts","sourceRoot":"","sources":["../src/virtualized-manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACpF,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,qBACa,kBAAmB,YAAW,mBAAmB;IAC5D;;;OAGG;IAEH,aAAa,UAAS;IAEtB,UAAU,EAAE,aAAa,CAAC;gBAIxB,wBAAwB,EAAE,wBAAwB;IAKpD;;;;;OAKG;IAEH,eAAe,WAAkB,MAAM,SAAS,MAAM,SAAS,MAAM,sBAUnE;CACH"}
|
|
@@ -11,8 +11,9 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
11
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
12
|
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; }
|
|
13
13
|
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.'); }
|
|
14
|
-
import { transient, prop } from '@difizen/mana-app';
|
|
15
|
-
|
|
14
|
+
import { transient, prop, inject } from '@difizen/mana-app';
|
|
15
|
+
import { VirtualizedManagerOption } from "./libro-protocol.js";
|
|
16
|
+
export var VirtualizedManager = (_dec = transient(), _dec2 = prop(), _dec(_class = (_class2 = /*#__PURE__*/_createClass(function VirtualizedManager(virtualizedManagerOption) {
|
|
16
17
|
var _this = this;
|
|
17
18
|
_classCallCheck(this, VirtualizedManager);
|
|
18
19
|
/**
|
|
@@ -20,6 +21,7 @@ export var VirtualizedManager = (_dec = transient(), _dec2 = prop(), _dec(_class
|
|
|
20
21
|
* 所以它用于滚动到某个cell的判断依据是没有问题的。
|
|
21
22
|
*/
|
|
22
23
|
_initializerDefineProperty(this, "isVirtualized", _descriptor, this);
|
|
24
|
+
this.libroModel = void 0;
|
|
23
25
|
/**
|
|
24
26
|
*
|
|
25
27
|
* @param length cell个数
|
|
@@ -51,6 +53,7 @@ export var VirtualizedManager = (_dec = transient(), _dec2 = prop(), _dec(_class
|
|
|
51
53
|
return _ref.apply(this, arguments);
|
|
52
54
|
};
|
|
53
55
|
}();
|
|
56
|
+
this.libroModel = virtualizedManagerOption.libroModel;
|
|
54
57
|
}), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "isVirtualized", [_dec2], {
|
|
55
58
|
configurable: true,
|
|
56
59
|
enumerable: true,
|
|
@@ -58,4 +61,5 @@ export var VirtualizedManager = (_dec = transient(), _dec2 = prop(), _dec(_class
|
|
|
58
61
|
initializer: function initializer() {
|
|
59
62
|
return false;
|
|
60
63
|
}
|
|
61
|
-
})), _class2)) || _class);
|
|
64
|
+
})), _class2)) || _class);
|
|
65
|
+
VirtualizedManager = inject(VirtualizedManagerOption)(VirtualizedManager, undefined, 0) || VirtualizedManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
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.20",
|
|
38
|
+
"@difizen/libro-common": "^0.1.20",
|
|
39
|
+
"@difizen/libro-shared-model": "^0.1.20",
|
|
40
|
+
"@difizen/libro-virtualized": "^0.1.20",
|
|
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'],
|