@difizen/libro-core 0.2.0 → 0.2.1

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.
Files changed (78) hide show
  1. package/es/add-cell/libro-add-cell-view.js +1 -1
  2. package/es/cell/libro-cell-model.d.ts +2 -0
  3. package/es/cell/libro-cell-model.d.ts.map +1 -1
  4. package/es/cell/libro-cell-model.js +8 -1
  5. package/es/cell/libro-cell-view.d.ts +6 -1
  6. package/es/cell/libro-cell-view.d.ts.map +1 -1
  7. package/es/cell/libro-cell-view.js +17 -1
  8. package/es/command/document-commands.d.ts.map +1 -1
  9. package/es/command/document-commands.js +5 -3
  10. package/es/command/libro-command-contribution.d.ts +2 -2
  11. package/es/command/libro-command-contribution.d.ts.map +1 -1
  12. package/es/command/libro-command-contribution.js +71 -59
  13. package/es/components/dnd-cell-item-render.js +1 -1
  14. package/es/components/dnd-component/default-dnd-content.js +1 -1
  15. package/es/index.d.ts +2 -0
  16. package/es/index.d.ts.map +1 -1
  17. package/es/index.js +3 -1
  18. package/es/index.less +5 -3
  19. package/es/libro-context-key.d.ts +5 -1
  20. package/es/libro-context-key.d.ts.map +1 -1
  21. package/es/libro-context-key.js +12 -8
  22. package/es/libro-model.d.ts +8 -2
  23. package/es/libro-model.d.ts.map +1 -1
  24. package/es/libro-model.js +81 -47
  25. package/es/libro-protocol.d.ts +15 -4
  26. package/es/libro-protocol.d.ts.map +1 -1
  27. package/es/libro-service.d.ts +1 -0
  28. package/es/libro-service.d.ts.map +1 -1
  29. package/es/libro-service.js +17 -9
  30. package/es/libro-setting.d.ts +1 -0
  31. package/es/libro-setting.d.ts.map +1 -1
  32. package/es/libro-setting.js +10 -0
  33. package/es/libro-view.d.ts +3 -3
  34. package/es/libro-view.d.ts.map +1 -1
  35. package/es/libro-view.js +4 -4
  36. package/es/libro-workspace-service.d.ts +17 -0
  37. package/es/libro-workspace-service.d.ts.map +1 -0
  38. package/es/libro-workspace-service.js +36 -0
  39. package/es/material-from-designer.d.ts +1 -0
  40. package/es/material-from-designer.d.ts.map +1 -1
  41. package/es/material-from-designer.js +38 -2
  42. package/es/module.d.ts.map +1 -1
  43. package/es/module.js +3 -2
  44. package/es/output/output-area.d.ts +1 -0
  45. package/es/output/output-area.d.ts.map +1 -1
  46. package/es/output/output-area.js +70 -24
  47. package/es/output/output-model.d.ts +1 -0
  48. package/es/output/output-model.d.ts.map +1 -1
  49. package/es/output/output-model.js +17 -7
  50. package/es/output/output-protocol.d.ts +4 -0
  51. package/es/output/output-protocol.d.ts.map +1 -1
  52. package/es/theme/libro-color-registry.js +1 -1
  53. package/es/toolbar/change-cell-to-selector.d.ts.map +1 -1
  54. package/es/toolbar/change-cell-to-selector.js +7 -4
  55. package/package.json +6 -6
  56. package/src/add-cell/libro-add-cell-view.tsx +1 -1
  57. package/src/cell/libro-cell-model.ts +10 -1
  58. package/src/cell/libro-cell-view.tsx +17 -1
  59. package/src/command/document-commands.ts +5 -2
  60. package/src/command/libro-command-contribution.ts +86 -59
  61. package/src/components/dnd-cell-item-render.tsx +1 -1
  62. package/src/components/dnd-component/default-dnd-content.tsx +1 -1
  63. package/src/index.less +5 -3
  64. package/src/index.tsx +2 -1
  65. package/src/libro-context-key.ts +5 -1
  66. package/src/libro-model.ts +24 -5
  67. package/src/libro-protocol.ts +18 -5
  68. package/src/libro-service.ts +5 -1
  69. package/src/libro-setting.ts +11 -0
  70. package/src/libro-view.tsx +15 -6
  71. package/src/libro-workspace-service.ts +28 -0
  72. package/src/material-from-designer.tsx +32 -2
  73. package/src/module.ts +4 -2
  74. package/src/output/output-area.tsx +34 -9
  75. package/src/output/output-model.tsx +5 -1
  76. package/src/output/output-protocol.ts +5 -0
  77. package/src/theme/libro-color-registry.ts +1 -1
  78. package/src/toolbar/change-cell-to-selector.tsx +12 -3
@@ -4,14 +4,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
5
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
6
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
- import { useInject, ToolbarInstance, getOrigin, CommandRegistry } from '@difizen/mana-app';
8
- import { Select } from 'antd';
7
+ import { useInject, ToolbarInstance, getOrigin, CommandRegistry, ThemeService } from '@difizen/mana-app';
8
+ import { ConfigProvider, Select, theme } from 'antd';
9
9
  import { memo } from 'react';
10
10
  import { LibroCellService } from "../cell/index.js";
11
11
  import { NotebookCommands } from "../command/index.js";
12
12
  import "./index.less";
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { Fragment as _Fragment } from "react/jsx-runtime";
15
14
  var Option = Select.Option;
16
15
  var widthStyle = {
17
16
  width: 110
@@ -24,11 +23,15 @@ export var ToolItemSelectInner = function ToolItemSelectInner() {
24
23
  var data = toolbar.currentArgs;
25
24
  var command = useInject(CommandRegistry);
26
25
  var curCell = data === null || data === void 0 ? void 0 : data[0];
26
+ var themeService = useInject(ThemeService);
27
27
  var handleChange = function handleChange(value) {
28
28
  var args = getOrigin(data) || [];
29
29
  command.executeCommand.apply(command, [NotebookCommands['ChangeCellTo'].id].concat(_toConsumableArray(args), [value]));
30
30
  };
31
- return /*#__PURE__*/_jsx(_Fragment, {
31
+ return /*#__PURE__*/_jsx(ConfigProvider, {
32
+ theme: {
33
+ algorithm: themeService.getCurrentTheme().type === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm
34
+ },
32
35
  children: /*#__PURE__*/_jsx(Select, {
33
36
  value: curCell === null || curCell === void 0 || (_curCell$model = curCell.model) === null || _curCell$model === void 0 ? void 0 : _curCell$model.type,
34
37
  size: 'small',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
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.2.0",
38
- "@difizen/libro-common": "^0.2.0",
39
- "@difizen/libro-shared-model": "^0.2.0",
40
- "@difizen/libro-virtualized": "^0.2.0",
37
+ "@difizen/libro-code-editor": "^0.2.1",
38
+ "@difizen/libro-common": "^0.2.1",
39
+ "@difizen/libro-shared-model": "^0.2.1",
40
+ "@difizen/libro-virtualized": "^0.2.1",
41
41
  "@difizen/mana-app": "latest",
42
42
  "@difizen/mana-l10n": "latest",
43
43
  "@difizen/mana-react": "latest",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "antd": "^5.8.6",
58
- "react": "^18.2.0"
58
+ "react": ">=16"
59
59
  },
60
60
  "scripts": {
61
61
  "setup": "father build",
@@ -66,7 +66,7 @@ export const LibroAddCell: React.FC = () => {
66
66
  export const LibroWrappedAddCell = forwardRef(function LibroWrappedAddCell() {
67
67
  const instance = useInject<LibroAddCellView>(ViewInstance);
68
68
  return (
69
- <DisplayWrapComponent mode={instance.parent?.model.readOnly}>
69
+ <DisplayWrapComponent mode={!instance.parent?.model.cellsEditable}>
70
70
  <LibroAddCell />
71
71
  </DisplayWrapComponent>
72
72
  );
@@ -1,7 +1,7 @@
1
1
  import { Model } from '@difizen/libro-code-editor';
2
2
  import type { ICell } from '@difizen/libro-common';
3
3
  import { concatMultilineString } from '@difizen/libro-common';
4
- import { DisposableCollection } from '@difizen/mana-app';
4
+ import { DisposableCollection, watch } from '@difizen/mana-app';
5
5
  import { prop, inject, postConstruct, transient } from '@difizen/mana-app';
6
6
 
7
7
  import type { DefaultDecodedFormatter } from '../formatter/index.js';
@@ -34,6 +34,8 @@ export class LibroCellModel extends Model implements CellModel {
34
34
  @prop()
35
35
  trusted: boolean;
36
36
 
37
+ version = 0;
38
+
37
39
  constructor(@inject(CellOptions) options: CellOptions) {
38
40
  super({
39
41
  id: options.cell.id as string,
@@ -68,8 +70,15 @@ export class LibroCellModel extends Model implements CellModel {
68
70
  this.libroFormatType,
69
71
  formatValue,
70
72
  );
73
+ this.updateVersion();
71
74
  }
72
75
 
76
+ updateVersion = () => {
77
+ watch<Model>(this, 'value', () => {
78
+ this.version++;
79
+ });
80
+ };
81
+
73
82
  get source(): string {
74
83
  const encodedValue = this.libroFormatterManager.encode(
75
84
  this.libroFormatType,
@@ -1,4 +1,5 @@
1
1
  import type { ViewComponent } from '@difizen/mana-app';
2
+ import { Deferred } from '@difizen/mana-app';
2
3
  import { useInject, watch } from '@difizen/mana-app';
3
4
  import { BaseView, view, ViewInstance, ViewOption } from '@difizen/mana-app';
4
5
  import { inject } from '@difizen/mana-app';
@@ -36,7 +37,22 @@ export class LibroCellView extends BaseView implements CellView {
36
37
  model: CellModel;
37
38
  protected cellService: CellService;
38
39
  override view: ViewComponent = LibroCellComponent;
39
- parent: NotebookView;
40
+
41
+ protected _parent: NotebookView;
42
+
43
+ get parent() {
44
+ return this._parent;
45
+ }
46
+ set parent(value: NotebookView) {
47
+ this._parent = value;
48
+ this.parentDefer.resolve(this.parent);
49
+ }
50
+
51
+ protected parentDefer = new Deferred<NotebookView>();
52
+
53
+ get parentReady() {
54
+ return this.parentDefer.promise;
55
+ }
40
56
 
41
57
  @prop()
42
58
  override className?: string | undefined = 'libro-cell-view-container';
@@ -1,6 +1,8 @@
1
- import { ClearOutlined, SaveOutlined, SettingOutlined } from '@ant-design/icons';
1
+ import { SaveOutlined, SettingOutlined } from '@ant-design/icons';
2
2
  import type { Command } from '@difizen/mana-app';
3
3
 
4
+ import { FormatCellIcon } from '../material-from-designer.js';
5
+
4
6
  export const DocumentCommands: Record<string, Command & { keybind?: string }> = {
5
7
  Save: {
6
8
  id: 'document:save',
@@ -15,7 +17,8 @@ export const DocumentCommands: Record<string, Command & { keybind?: string }> =
15
17
  },
16
18
  FormatCell: {
17
19
  id: 'document.notebook.format_cell',
18
- icon: ClearOutlined,
20
+ icon: FormatCellIcon,
19
21
  label: 'format cell code',
22
+ keybind: 'shift+alt+f',
20
23
  },
21
24
  };
@@ -11,7 +11,8 @@ import { v4 } from 'uuid';
11
11
 
12
12
  import { LibroCellView, ExecutableCellModel, EditorCellView } from '../cell/index.js';
13
13
  import type { LibroEditorCellView } from '../cell/index.js';
14
- import { LirboContextKey } from '../libro-context-key.js';
14
+ import { LibroContextKey } from '../libro-context-key.js';
15
+ import type { LibroModel } from '../libro-model.js';
15
16
  import type { CellView, NotebookView } from '../libro-protocol.js';
16
17
  import { LibroToolbarArea } from '../libro-protocol.js';
17
18
  import { LibroService } from '../libro-service.js';
@@ -29,7 +30,7 @@ export class LibroCommandContribution implements CommandContribution {
29
30
  @inject(ModalService) protected readonly modalService: ModalService;
30
31
  @inject(LibroCommandRegister) protected readonly libroCommand: LibroCommandRegister;
31
32
  @inject(LibroService) protected readonly libroService: LibroService;
32
- @inject(LirboContextKey) protected readonly lirboContextKey: LirboContextKey;
33
+ @inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
33
34
 
34
35
  registerCommands(command: CommandRegistry): void {
35
36
  this.libroCommand.registerLibroCommand(command, NotebookCommands['EnterEditMode'], {
@@ -37,7 +38,7 @@ export class LibroCommandContribution implements CommandContribution {
37
38
  this.libroService.active?.enterEditMode();
38
39
  },
39
40
  isEnabled: (cell, libro) => {
40
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
41
+ if (!libro || !(libro instanceof LibroView) || !libro.model.inputEditable) {
41
42
  return false;
42
43
  }
43
44
  return true;
@@ -75,10 +76,12 @@ export class LibroCommandContribution implements CommandContribution {
75
76
  ) {
76
77
  return;
77
78
  }
78
- libro.runCell(cell);
79
+ if ((libro.model as LibroModel).executable) {
80
+ libro.runCell(cell);
81
+ }
79
82
  },
80
83
  isEnabled: (cell, libro) => {
81
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
84
+ if (!libro || !(libro instanceof LibroView)) {
82
85
  return false;
83
86
  }
84
87
  return true;
@@ -89,7 +92,9 @@ export class LibroCommandContribution implements CommandContribution {
89
92
  if (!libro || !(libro instanceof LibroView)) {
90
93
  return;
91
94
  }
92
- libro.runAllCell();
95
+ if ((libro.model as LibroModel).executable) {
96
+ libro.runAllCell();
97
+ }
93
98
  },
94
99
  });
95
100
  this.libroCommand.registerLibroCommand(command, NotebookCommands['RunAllAbove'], {
@@ -102,7 +107,9 @@ export class LibroCommandContribution implements CommandContribution {
102
107
  ) {
103
108
  return;
104
109
  }
105
- libro.runAllAbove(cell);
110
+ if ((libro.model as LibroModel).executable) {
111
+ libro.runAllAbove(cell);
112
+ }
106
113
  },
107
114
  });
108
115
  this.libroCommand.registerLibroCommand(command, NotebookCommands['RunAllBelow'], {
@@ -115,7 +122,9 @@ export class LibroCommandContribution implements CommandContribution {
115
122
  ) {
116
123
  return;
117
124
  }
118
- libro.runAllBelow(cell);
125
+ if ((libro.model as LibroModel).executable) {
126
+ libro.runAllBelow(cell);
127
+ }
119
128
  },
120
129
  });
121
130
  this.libroCommand.registerLibroCommand(
@@ -131,10 +140,12 @@ export class LibroCommandContribution implements CommandContribution {
131
140
  ) {
132
141
  return;
133
142
  }
134
- libro.runCellandSelectNext(cell);
143
+ if ((libro.model as LibroModel).executable) {
144
+ libro.runCellandSelectNext(cell);
145
+ }
135
146
  },
136
147
  isEnabled: (cell, libro) => {
137
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
148
+ if (!libro || !(libro instanceof LibroView)) {
138
149
  return false;
139
150
  }
140
151
  return true;
@@ -154,10 +165,12 @@ export class LibroCommandContribution implements CommandContribution {
154
165
  ) {
155
166
  return;
156
167
  }
157
- libro.runCellandInsertBelow(cell);
168
+ if ((libro.model as LibroModel).executable) {
169
+ libro.runCellandInsertBelow(cell);
170
+ }
158
171
  },
159
172
  isEnabled: (cell, libro) => {
160
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
173
+ if (!libro || !(libro instanceof LibroView)) {
161
174
  return false;
162
175
  }
163
176
  return true;
@@ -190,8 +203,7 @@ export class LibroCommandContribution implements CommandContribution {
190
203
  return false;
191
204
  }
192
205
  return (
193
- !libro?.model.quickEditMode &&
194
- !libro?.model.readOnly &&
206
+ (libro?.model as LibroModel).executable &&
195
207
  path === LibroToolbarArea.HeaderCenter
196
208
  );
197
209
  },
@@ -211,8 +223,7 @@ export class LibroCommandContribution implements CommandContribution {
211
223
  return false;
212
224
  }
213
225
  return (
214
- !libro?.model.quickEditMode &&
215
- !libro?.model.readOnly &&
226
+ (libro?.model as LibroModel).executable &&
216
227
  path === LibroToolbarArea.HeaderCenter
217
228
  );
218
229
  },
@@ -265,10 +276,10 @@ export class LibroCommandContribution implements CommandContribution {
265
276
  if (!libro || !(libro instanceof LibroView)) {
266
277
  return false;
267
278
  }
268
- return !libro?.model.readOnly && path === LibroToolbarArea.CellRight;
279
+ return libro?.model.cellsEditable && path === LibroToolbarArea.CellRight;
269
280
  },
270
281
  isEnabled: (cell, libro) => {
271
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
282
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
272
283
  return false;
273
284
  }
274
285
  return true;
@@ -300,7 +311,7 @@ export class LibroCommandContribution implements CommandContribution {
300
311
  }
301
312
  },
302
313
  isEnabled: (cell, libro) => {
303
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
314
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
304
315
  return false;
305
316
  }
306
317
  return true;
@@ -373,7 +384,12 @@ export class LibroCommandContribution implements CommandContribution {
373
384
  libro.mergeCellBelow(cell);
374
385
  },
375
386
  isEnabled: (cell, libro) => {
376
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
387
+ if (
388
+ !libro ||
389
+ !(libro instanceof LibroView) ||
390
+ !libro.model.inputEditable ||
391
+ !libro.model.cellsEditable
392
+ ) {
377
393
  return false;
378
394
  }
379
395
  return true;
@@ -396,7 +412,12 @@ export class LibroCommandContribution implements CommandContribution {
396
412
  libro.mergeCellAbove(cell);
397
413
  },
398
414
  isEnabled: (cell, libro) => {
399
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
415
+ if (
416
+ !libro ||
417
+ !(libro instanceof LibroView) ||
418
+ !libro.model.inputEditable ||
419
+ !libro.model.cellsEditable
420
+ ) {
400
421
  return false;
401
422
  }
402
423
  return true;
@@ -416,7 +437,12 @@ export class LibroCommandContribution implements CommandContribution {
416
437
  libro.mergeCells(cell);
417
438
  },
418
439
  isEnabled: (cell, libro) => {
419
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
440
+ if (
441
+ !libro ||
442
+ !(libro instanceof LibroView) ||
443
+ !libro.model.inputEditable ||
444
+ !libro.model.cellsEditable
445
+ ) {
420
446
  return false;
421
447
  }
422
448
  return true;
@@ -438,10 +464,10 @@ export class LibroCommandContribution implements CommandContribution {
438
464
  if (!libro || !(libro instanceof LibroView)) {
439
465
  return false;
440
466
  }
441
- return !libro?.model.readOnly && path === LibroToolbarArea.CellRight;
467
+ return libro?.model.cellsEditable && path === LibroToolbarArea.CellRight;
442
468
  },
443
469
  isEnabled: (cell, libro) => {
444
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
470
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
445
471
  return false;
446
472
  }
447
473
  return true;
@@ -463,7 +489,7 @@ export class LibroCommandContribution implements CommandContribution {
463
489
  libro.clearOutputs(cell);
464
490
  },
465
491
  isEnabled: (cell, libro) => {
466
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
492
+ if (!libro || !(libro instanceof LibroView) || !libro.model.outputEditable) {
467
493
  return false;
468
494
  }
469
495
  return true;
@@ -489,10 +515,10 @@ export class LibroCommandContribution implements CommandContribution {
489
515
  if (!libro || !(libro instanceof LibroView)) {
490
516
  return false;
491
517
  }
492
- return !libro?.model.readOnly && path === LibroToolbarArea.HeaderCenter;
518
+ return libro?.model.outputEditable && path === LibroToolbarArea.HeaderCenter;
493
519
  },
494
520
  isEnabled: (cell, libro) => {
495
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
521
+ if (!libro || !(libro instanceof LibroView) || !libro.model.outputEditable) {
496
522
  return false;
497
523
  }
498
524
  return true;
@@ -520,7 +546,7 @@ export class LibroCommandContribution implements CommandContribution {
520
546
  !libro ||
521
547
  !(cell instanceof LibroCellView) ||
522
548
  !(libro instanceof LibroView) ||
523
- libro.model.readOnly
549
+ !libro.model.cellsEditable
524
550
  ) {
525
551
  return false;
526
552
  }
@@ -548,7 +574,7 @@ export class LibroCommandContribution implements CommandContribution {
548
574
  !libro ||
549
575
  !(cell instanceof LibroCellView) ||
550
576
  !(libro instanceof LibroView) ||
551
- libro.model.readOnly
577
+ !libro.model.cellsEditable
552
578
  ) {
553
579
  return false;
554
580
  }
@@ -583,7 +609,7 @@ export class LibroCommandContribution implements CommandContribution {
583
609
  // return true;
584
610
  // },
585
611
  isEnabled: (cell, libro) => {
586
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
612
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
587
613
  return false;
588
614
  }
589
615
  return true;
@@ -611,7 +637,7 @@ export class LibroCommandContribution implements CommandContribution {
611
637
  // return true;
612
638
  // },
613
639
  isEnabled: (cell, libro) => {
614
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
640
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
615
641
  return false;
616
642
  }
617
643
  return true;
@@ -633,7 +659,7 @@ export class LibroCommandContribution implements CommandContribution {
633
659
  libro.pasteCellAbove(cell);
634
660
  },
635
661
  isEnabled: (cell, libro) => {
636
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
662
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
637
663
  return false;
638
664
  }
639
665
  return true;
@@ -665,7 +691,7 @@ export class LibroCommandContribution implements CommandContribution {
665
691
  // return true;
666
692
  // },
667
693
  isEnabled: (cell, libro) => {
668
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
694
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
669
695
  return false;
670
696
  }
671
697
  return true;
@@ -795,10 +821,10 @@ export class LibroCommandContribution implements CommandContribution {
795
821
  if (!libro || !(libro instanceof LibroView)) {
796
822
  return false;
797
823
  }
798
- return !libro?.model.readOnly && path === LibroToolbarArea.HeaderCenter;
824
+ return path === LibroToolbarArea.HeaderCenter;
799
825
  },
800
826
  isEnabled: (cell, libro) => {
801
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
827
+ if (!libro || !(libro instanceof LibroView)) {
802
828
  return false;
803
829
  }
804
830
  return true;
@@ -955,10 +981,10 @@ export class LibroCommandContribution implements CommandContribution {
955
981
  if (!libro || !(libro instanceof LibroView)) {
956
982
  return false;
957
983
  }
958
- return !libro?.model.readOnly && path === LibroToolbarArea.HeaderCenter;
984
+ return libro?.model.cellsEditable && path === LibroToolbarArea.HeaderCenter;
959
985
  },
960
986
  isEnabled: (cell, libro) => {
961
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
987
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
962
988
  return false;
963
989
  }
964
990
  return true;
@@ -980,7 +1006,7 @@ export class LibroCommandContribution implements CommandContribution {
980
1006
  libro.invertCell(cell, 'code');
981
1007
  },
982
1008
  isEnabled: (cell, libro) => {
983
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1009
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
984
1010
  return false;
985
1011
  }
986
1012
  return true;
@@ -1003,7 +1029,7 @@ export class LibroCommandContribution implements CommandContribution {
1003
1029
  libro.invertCell(cell, 'markdown');
1004
1030
  },
1005
1031
  isEnabled: (cell, libro) => {
1006
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1032
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1007
1033
  return false;
1008
1034
  }
1009
1035
  return true;
@@ -1067,25 +1093,25 @@ export class LibroCommandContribution implements CommandContribution {
1067
1093
  if (!libro || !(libro instanceof LibroView)) {
1068
1094
  return false;
1069
1095
  }
1070
- return !libro?.model.readOnly && path === LibroToolbarArea.HeaderCenter;
1096
+ return path === LibroToolbarArea.HeaderCenter;
1071
1097
  },
1072
1098
  },
1073
1099
  );
1074
1100
  this.libroCommand.registerLibroCommand(command, DocumentCommands['Save'], {
1075
1101
  execute: async (cell, libro) => {
1076
- if (!libro || !(libro instanceof LibroView)) {
1102
+ if (!libro || !(libro instanceof LibroView) || !libro.model.savable) {
1077
1103
  return;
1078
1104
  }
1079
1105
  libro.save();
1080
1106
  },
1081
1107
  isVisible: (cell, libro, path) => {
1082
- if (!libro || !(libro instanceof LibroView)) {
1108
+ if (!libro || !(libro instanceof LibroView) || !libro.model.savable) {
1083
1109
  return false;
1084
1110
  }
1085
- return !libro?.model.readOnly && path === LibroToolbarArea.HeaderCenter;
1111
+ return libro?.model.savable && path === LibroToolbarArea.HeaderCenter;
1086
1112
  },
1087
1113
  isEnabled: (cell, libro) => {
1088
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1114
+ if (!libro || !(libro instanceof LibroView)) {
1089
1115
  return false;
1090
1116
  }
1091
1117
  return true;
@@ -1099,7 +1125,7 @@ export class LibroCommandContribution implements CommandContribution {
1099
1125
  if (!libro || !(libro instanceof LibroView)) {
1100
1126
  return false;
1101
1127
  }
1102
- return !libro?.model.readOnly && path === LibroToolbarArea.HeaderRight;
1128
+ return path === LibroToolbarArea.HeaderRight;
1103
1129
  },
1104
1130
  });
1105
1131
  this.libroCommand.registerLibroCommand(command, DocumentCommands['FormatCell'], {
@@ -1113,7 +1139,8 @@ export class LibroCommandContribution implements CommandContribution {
1113
1139
  return false;
1114
1140
  }
1115
1141
  return (
1116
- !libro?.model.readOnly &&
1142
+ this.libroService.hasFormatter &&
1143
+ libro?.model.inputEditable &&
1117
1144
  EditorCellView.is(cell) &&
1118
1145
  cell.model.mimeType === MIME.python &&
1119
1146
  path === LibroToolbarArea.CellRight
@@ -1135,10 +1162,10 @@ export class LibroCommandContribution implements CommandContribution {
1135
1162
  if (!libro || !(libro instanceof LibroView)) {
1136
1163
  return false;
1137
1164
  }
1138
- return !libro?.model.readOnly && path === LibroToolbarArea.HeaderCenter;
1165
+ return libro?.model.cellsEditable && path === LibroToolbarArea.HeaderCenter;
1139
1166
  },
1140
1167
  isEnabled: (cell, libro) => {
1141
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1168
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1142
1169
  return false;
1143
1170
  }
1144
1171
 
@@ -1160,10 +1187,10 @@ export class LibroCommandContribution implements CommandContribution {
1160
1187
  if (!libro || !(libro instanceof LibroView)) {
1161
1188
  return false;
1162
1189
  }
1163
- return !libro?.model.readOnly && path === LibroToolbarArea.HeaderCenter;
1190
+ return libro?.model.cellsEditable && path === LibroToolbarArea.HeaderCenter;
1164
1191
  },
1165
1192
  isEnabled: (cell, libro) => {
1166
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1193
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1167
1194
  return false;
1168
1195
  }
1169
1196
  return libro.model.canRedo ?? false;
@@ -1186,7 +1213,7 @@ export class LibroCommandContribution implements CommandContribution {
1186
1213
  libro.splitCell(cell);
1187
1214
  },
1188
1215
  isEnabled: (cell, libro) => {
1189
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1216
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1190
1217
  return false;
1191
1218
  }
1192
1219
  return true;
@@ -1201,7 +1228,7 @@ export class LibroCommandContribution implements CommandContribution {
1201
1228
  (cell as LibroEditorCellView).redo();
1202
1229
  },
1203
1230
  isEnabled: (cell, libro) => {
1204
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1231
+ if (!libro || !(libro instanceof LibroView) || !libro.model.inputEditable) {
1205
1232
  return false;
1206
1233
  }
1207
1234
  return true;
@@ -1215,7 +1242,7 @@ export class LibroCommandContribution implements CommandContribution {
1215
1242
  (cell as LibroEditorCellView).undo();
1216
1243
  },
1217
1244
  isEnabled: (cell, libro) => {
1218
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1245
+ if (!libro || !(libro instanceof LibroView) || !libro.model.inputEditable) {
1219
1246
  return false;
1220
1247
  }
1221
1248
  return true;
@@ -1237,7 +1264,7 @@ export class LibroCommandContribution implements CommandContribution {
1237
1264
  libro.setMarkdownHeader(cell, 1);
1238
1265
  },
1239
1266
  isEnabled: (cell, libro) => {
1240
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1267
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1241
1268
  return false;
1242
1269
  }
1243
1270
  return true;
@@ -1260,7 +1287,7 @@ export class LibroCommandContribution implements CommandContribution {
1260
1287
  libro.setMarkdownHeader(cell, 2);
1261
1288
  },
1262
1289
  isEnabled: (cell, libro) => {
1263
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1290
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1264
1291
  return false;
1265
1292
  }
1266
1293
  return true;
@@ -1283,7 +1310,7 @@ export class LibroCommandContribution implements CommandContribution {
1283
1310
  libro.setMarkdownHeader(cell, 3);
1284
1311
  },
1285
1312
  isEnabled: (cell, libro) => {
1286
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1313
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1287
1314
  return false;
1288
1315
  }
1289
1316
  return true;
@@ -1306,7 +1333,7 @@ export class LibroCommandContribution implements CommandContribution {
1306
1333
  libro.setMarkdownHeader(cell, 4);
1307
1334
  },
1308
1335
  isEnabled: (cell, libro) => {
1309
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1336
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1310
1337
  return false;
1311
1338
  }
1312
1339
  return true;
@@ -1329,7 +1356,7 @@ export class LibroCommandContribution implements CommandContribution {
1329
1356
  libro.setMarkdownHeader(cell, 5);
1330
1357
  },
1331
1358
  isEnabled: (cell, libro) => {
1332
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1359
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1333
1360
  return false;
1334
1361
  }
1335
1362
  return true;
@@ -1352,7 +1379,7 @@ export class LibroCommandContribution implements CommandContribution {
1352
1379
  libro.setMarkdownHeader(cell, 6);
1353
1380
  },
1354
1381
  isEnabled: (cell, libro) => {
1355
- if (!libro || !(libro instanceof LibroView) || libro.model.readOnly) {
1382
+ if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
1356
1383
  return false;
1357
1384
  }
1358
1385
  return true;
@@ -407,7 +407,7 @@ export const DndCellItemContainer = memo(function DndCellItemContainer(
407
407
  e.stopPropagation();
408
408
  }}
409
409
  >
410
- {isActive && !isDrag && instance.model.readOnly !== true && (
410
+ {isActive && !isDrag && instance.model.cellsEditable && (
411
411
  <ToolbarRender
412
412
  data={rightToolbarArgs}
413
413
  tooltip={{ placement: LibroToolbarArea.CellRight }}
@@ -259,7 +259,7 @@ export const DndCellContainer: React.FC<DndContentProps> = ({ cell, index }) =>
259
259
  },
260
260
  });
261
261
  const opacity = isDrag ? 0.4 : 1;
262
- if (!instance.model.readOnly) {
262
+ if (instance.model.cellsEditable) {
263
263
  drop(ref);
264
264
  }
265
265
  if (isDrag) {