@difizen/libro-code-cell 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.
@@ -3,7 +3,7 @@ import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-
3
3
  import { CodeEditorManager } from '@difizen/libro-code-editor';
4
4
  import type { IOutput } from '@difizen/libro-common';
5
5
  import type { LibroCell, CellViewOptions } from '@difizen/libro-core';
6
- import { CellService, EditorStatus, LibroExecutableCellView, LibroOutputArea, LirboContextKey } from '@difizen/libro-core';
6
+ import { CellService, EditorStatus, LibroExecutableCellView, LibroOutputArea, LibroContextKey } from '@difizen/libro-core';
7
7
  import type { ViewSize } from '@difizen/mana-app';
8
8
  import { DisposableCollection } from '@difizen/mana-app';
9
9
  import { ViewManager, Deferred } from '@difizen/mana-app';
@@ -11,7 +11,7 @@ import type { LibroCodeCellModel } from './code-cell-model.js';
11
11
  export declare const CellEditorMemo: import("react").NamedExoticComponent<{}>;
12
12
  export declare class LibroCodeCellView extends LibroExecutableCellView {
13
13
  protected toDisposeOnEditor: DisposableCollection;
14
- protected readonly lirboContextKey: LirboContextKey;
14
+ protected readonly libroContextKey: LibroContextKey;
15
15
  view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
16
16
  viewManager: ViewManager;
17
17
  codeEditorManager: CodeEditorManager;
@@ -29,7 +29,7 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decor
29
29
 
30
30
  import { CodeEditorManager } from '@difizen/libro-code-editor';
31
31
  import { isOutput } from '@difizen/libro-common';
32
- import { CellService, EditorStatus, LibroExecutableCellView, LibroOutputArea, VirtualizedManagerHelper, LirboContextKey } from '@difizen/libro-core';
32
+ import { CellService, EditorStatus, LibroExecutableCellView, LibroOutputArea, VirtualizedManagerHelper, LibroContextKey } from '@difizen/libro-core';
33
33
  import { Disposable } from '@difizen/mana-app';
34
34
  import { DisposableCollection } from '@difizen/mana-app';
35
35
  import { getOrigin, inject, prop, transient, useInject, view, ViewInstance, ViewManager, ViewOption, ViewRender, watch, Deferred } from '@difizen/mana-app';
@@ -85,7 +85,7 @@ var CodeEditorViewComponent = /*#__PURE__*/forwardRef(function CodeEditorViewCom
85
85
  children: /*#__PURE__*/_jsx(CellEditorMemo, {})
86
86
  });
87
87
  });
88
- export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-cell-view'), _dec3 = inject(LirboContextKey), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroExecutableCellV) {
88
+ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-cell-view'), _dec3 = inject(LibroContextKey), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroExecutableCellV) {
89
89
  _inherits(LibroCodeCellView, _LibroExecutableCellV);
90
90
  var _super = _createSuper(LibroCodeCellView);
91
91
  function LibroCodeCellView(options, cellService, viewManager, codeEditorManager) {
@@ -94,7 +94,7 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
94
94
  _classCallCheck(this, LibroCodeCellView);
95
95
  _this = _super.call(this, options, cellService);
96
96
  _this.toDisposeOnEditor = new DisposableCollection();
97
- _initializerDefineProperty(_this, "lirboContextKey", _descriptor, _assertThisInitialized(_this));
97
+ _initializerDefineProperty(_this, "libroContextKey", _descriptor, _assertThisInitialized(_this));
98
98
  _this.view = CodeEditorViewComponent;
99
99
  _this.viewManager = void 0;
100
100
  _this.codeEditorManager = void 0;
@@ -244,8 +244,8 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
244
244
  editorHostId: this.parent.id + this.id,
245
245
  model: this.model,
246
246
  config: {
247
- readOnly: this.parent.model.readOnly,
248
- editable: !this.parent.model.readOnly,
247
+ readOnly: !this.parent.model.inputEditable,
248
+ editable: this.parent.model.inputEditable,
249
249
  placeholder: '请输入代码'
250
250
  }
251
251
  };
@@ -310,9 +310,9 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
310
310
  while (1) switch (_context3.prev = _context3.next) {
311
311
  case 0:
312
312
  this.focusEditor();
313
- this.toDisposeOnEditor.push(watch(this.parent.model, 'readOnly', function () {
313
+ this.toDisposeOnEditor.push(watch(this.parent.model, 'inputEditable', function () {
314
314
  var _this4$editorView;
315
- (_this4$editorView = _this4.editorView) === null || _this4$editorView === void 0 || (_this4$editorView = _this4$editorView.editor) === null || _this4$editorView === void 0 || _this4$editorView.setOption('readOnly', getOrigin(_this4.parent.model.readOnly));
315
+ (_this4$editorView = _this4.editorView) === null || _this4$editorView === void 0 || (_this4$editorView = _this4$editorView.editor) === null || _this4$editorView === void 0 || _this4$editorView.setOption('readOnly', getOrigin(!_this4.parent.model.inputEditable));
316
316
  }));
317
317
  this.toDisposeOnEditor.push((_this$editorView$onMo = (_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0 ? void 0 : _this$editorView3.onModalChange(function (val) {
318
318
  return _this4.hasModal = val;
@@ -339,9 +339,9 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
339
339
  value: function focusEditor() {
340
340
  var _this$editorView4, _this$parent$model$ac;
341
341
  //选中cell、编辑模式、非只读时才focus
342
- if ((_this$editorView4 = this.editorView) !== null && _this$editorView4 !== void 0 && _this$editorView4.editor && this.editorView.editorStatus === 'ready' && ((_this$parent$model$ac = this.parent.model.active) === null || _this$parent$model$ac === void 0 ? void 0 : _this$parent$model$ac.id) === this.id && !this.parent.model.commandMode && this.lirboContextKey.commandModeEnabled === true &&
342
+ if ((_this$editorView4 = this.editorView) !== null && _this$editorView4 !== void 0 && _this$editorView4.editor && this.editorView.editorStatus === 'ready' && ((_this$parent$model$ac = this.parent.model.active) === null || _this$parent$model$ac === void 0 ? void 0 : _this$parent$model$ac.id) === this.id && !this.parent.model.commandMode && this.libroContextKey.commandModeEnabled === true &&
343
343
  // 排除弹窗等情况
344
- this.parent.model.readOnly === false) {
344
+ this.parent.model.inputEditable) {
345
345
  var _this$editorView5, _this$editorView6, _this$editorView7;
346
346
  (_this$editorView5 = this.editorView) === null || _this$editorView5 === void 0 || _this$editorView5.editor.setOption('styleActiveLine', true);
347
347
  (_this$editorView6 = this.editorView) === null || _this$editorView6 === void 0 || _this$editorView6.editor.setOption('highlightActiveLineGutter', true);
@@ -356,7 +356,7 @@ export var LibroCodeCellView = (_dec = transient(), _dec2 = view('code-editor-ce
356
356
  }
357
357
  }]);
358
358
  return LibroCodeCellView;
359
- }(LibroExecutableCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "lirboContextKey", [_dec3], {
359
+ }(LibroExecutableCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroContextKey", [_dec3], {
360
360
  configurable: true,
361
361
  enumerable: true,
362
362
  writable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-code-cell",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -32,13 +32,13 @@
32
32
  "src"
33
33
  ],
34
34
  "dependencies": {
35
- "@difizen/libro-code-editor": "^0.2.0",
36
- "@difizen/libro-common": "^0.2.0",
37
- "@difizen/libro-core": "^0.2.0",
35
+ "@difizen/libro-code-editor": "^0.2.1",
36
+ "@difizen/libro-common": "^0.2.1",
37
+ "@difizen/libro-core": "^0.2.1",
38
38
  "@difizen/mana-app": "latest"
39
39
  },
40
40
  "peerDependencies": {
41
- "react": "^18.2.0"
41
+ "react": ">=16"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/react": "^18.2.25"
@@ -16,7 +16,7 @@ import {
16
16
  LibroExecutableCellView,
17
17
  LibroOutputArea,
18
18
  VirtualizedManagerHelper,
19
- LirboContextKey,
19
+ LibroContextKey,
20
20
  } from '@difizen/libro-core';
21
21
  import type { ViewSize } from '@difizen/mana-app';
22
22
  import { Disposable } from '@difizen/mana-app';
@@ -103,7 +103,7 @@ const CodeEditorViewComponent = forwardRef<HTMLDivElement>(
103
103
  @view('code-editor-cell-view')
104
104
  export class LibroCodeCellView extends LibroExecutableCellView {
105
105
  protected toDisposeOnEditor = new DisposableCollection();
106
- @inject(LirboContextKey) protected readonly lirboContextKey: LirboContextKey;
106
+ @inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
107
107
  override view = CodeEditorViewComponent;
108
108
 
109
109
  viewManager: ViewManager;
@@ -231,8 +231,8 @@ export class LibroCodeCellView extends LibroExecutableCellView {
231
231
  editorHostId: this.parent.id + this.id,
232
232
  model: this.model,
233
233
  config: {
234
- readOnly: this.parent.model.readOnly,
235
- editable: !this.parent.model.readOnly,
234
+ readOnly: !this.parent.model.inputEditable,
235
+ editable: this.parent.model.inputEditable,
236
236
  placeholder: '请输入代码',
237
237
  },
238
238
  };
@@ -268,10 +268,10 @@ export class LibroCodeCellView extends LibroExecutableCellView {
268
268
  protected async afterEditorReady() {
269
269
  this.focusEditor();
270
270
  this.toDisposeOnEditor.push(
271
- watch(this.parent.model, 'readOnly', () => {
271
+ watch(this.parent.model, 'inputEditable', () => {
272
272
  this.editorView?.editor?.setOption(
273
273
  'readOnly',
274
- getOrigin(this.parent.model.readOnly),
274
+ getOrigin(!this.parent.model.inputEditable),
275
275
  );
276
276
  }),
277
277
  );
@@ -292,8 +292,8 @@ export class LibroCodeCellView extends LibroExecutableCellView {
292
292
  this.editorView.editorStatus === 'ready' &&
293
293
  this.parent.model.active?.id === this.id &&
294
294
  !this.parent.model.commandMode &&
295
- this.lirboContextKey.commandModeEnabled === true && // 排除弹窗等情况
296
- this.parent.model.readOnly === false
295
+ this.libroContextKey.commandModeEnabled === true && // 排除弹窗等情况
296
+ this.parent.model.inputEditable
297
297
  ) {
298
298
  this.editorView?.editor.setOption('styleActiveLine', true);
299
299
  this.editorView?.editor.setOption('highlightActiveLineGutter', true);