@difizen/libro-sql-cell 0.2.34 → 0.2.35-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ export interface SqlDecodedFormatter extends DefaultDecodedFormatter {
6
6
  export declare class FormatterSqlMagicContribution implements FormatterContribution<SqlDecodedFormatter> {
7
7
  formatter: string;
8
8
  formatterOptions?: object;
9
- canHandle: (libroFormatter: string) => 100 | 1;
9
+ canHandle: (libroFormatter: string) => 1 | 100;
10
10
  encode: (source: SqlDecodedFormatter) => {
11
11
  source: string;
12
12
  metadata: {
@@ -1,25 +1,20 @@
1
- import type { CodeEditorView } from '@difizen/libro-code-editor';
2
1
  import { CodeEditorManager } from '@difizen/libro-code-editor';
3
2
  import type { IOutput } from '@difizen/libro-common';
4
3
  import type { CellViewOptions, LibroCell, KernelMessage } from '@difizen/libro-jupyter';
5
- import { CellService, EditorStatus, LibroContextKey, LibroExecutableCellView, LibroViewTracker, LibroOutputArea } from '@difizen/libro-jupyter';
4
+ import { CellService, EditorStatus, LibroEditableExecutableCellView, LibroViewTracker, LibroOutputArea } from '@difizen/libro-jupyter';
6
5
  import type { ViewSize } from '@difizen/mana-app';
7
- import { Deferred, DisposableCollection, ViewManager } from '@difizen/mana-app';
6
+ import { Deferred, ViewManager } from '@difizen/mana-app';
8
7
  import React from 'react';
9
8
  import './index.less';
10
9
  import { LibroSqlCellModel } from './libro-sql-cell-model.js';
11
10
  import type { DatabaseConfig } from './libro-sql-cell-protocol.js';
12
11
  import { SqlScript } from './libro-sql-cell-script.js';
13
12
  export declare const LibroSqlCell: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
14
- export declare class LibroSqlCellView extends LibroExecutableCellView {
13
+ export declare class LibroSqlCellView extends LibroEditableExecutableCellView {
15
14
  view: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
16
15
  model: LibroSqlCellModel;
17
16
  libroViewTracker: LibroViewTracker;
18
- codeEditorManager: CodeEditorManager;
19
- protected toDisposeOnEditor: DisposableCollection;
20
- protected readonly libroContextKey: LibroContextKey;
21
17
  outputs: IOutput[];
22
- editorView?: CodeEditorView;
23
18
  databaseConfig?: DatabaseConfig;
24
19
  editorStatus: EditorStatus;
25
20
  editorAreaHeight: number;
@@ -35,18 +30,13 @@ export declare class LibroSqlCellView extends LibroExecutableCellView {
35
30
  constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager, libroViewTracker: LibroViewTracker, codeEditorManager: CodeEditorManager);
36
31
  onViewMount: () => Promise<void>;
37
32
  setEditorHost(ref: any): void;
38
- createEditor(): Promise<void>;
39
- protected afterEditorReady(): Promise<void>;
40
- protected focusEditor(): void;
41
33
  onViewResize: (size: ViewSize) => void;
42
34
  toJSON(): LibroCell;
43
35
  focus: (toEdit: boolean) => void;
44
- blur: () => void;
45
36
  clearExecution: () => void;
46
37
  run(): Promise<boolean>;
47
38
  fetch: (content: KernelMessage.IExecuteRequestMsg['content'], ioCallback: (msg: KernelMessage.IIOPubMessage) => any) => Promise<KernelMessage.IExecuteReplyMsg>;
48
39
  handleQueryResponse: (response: KernelMessage.IIOPubMessage, cb: (result: string) => void) => void;
49
40
  getDatabaseConfig: () => Promise<KernelMessage.IExecuteReplyMsg>;
50
- shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>): boolean;
51
41
  }
52
42
  //# sourceMappingURL=libro-sql-cell-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"libro-sql-cell-view.d.ts","sourceRoot":"","sources":["../src/libro-sql-cell-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAyB,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,KAAK,EACV,eAAe,EAGf,SAAS,EACT,aAAa,EACd,MAAM,wBAAw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typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7;
2
+ var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5;
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -31,9 +31,9 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
31
31
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
32
32
  import { EditFilled, DatabaseOutlined } from '@ant-design/icons';
33
33
  import { CodeEditorManager } from '@difizen/libro-code-editor';
34
- import { CellUri, isOutput } from '@difizen/libro-common';
35
- import { CellService, EditorStatus, LibroContextKey, LibroExecutableCellView, LibroViewTracker, VirtualizedManagerHelper, KernelError, LibroJupyterModel, LibroOutputArea } from '@difizen/libro-jupyter';
36
- import { Deferred, Disposable, DisposableCollection, getOrigin, inject, prop, transient, useInject, view, ViewInstance, ViewManager, ViewOption, ViewRender, watch } from '@difizen/mana-app';
34
+ import { isOutput } from '@difizen/libro-common';
35
+ import { CellService, EditorStatus, LibroContextKey, LibroEditableExecutableCellView, LibroViewTracker, VirtualizedManagerHelper, KernelError, LibroJupyterModel, LibroOutputArea } from '@difizen/libro-jupyter';
36
+ import { Deferred, getOrigin, inject, prop, transient, useInject, view, ViewInstance, ViewManager, ViewOption, ViewRender } from '@difizen/mana-app';
37
37
  import { l10n } from '@difizen/mana-l10n';
38
38
  import { Input, Popover } from 'antd';
39
39
  import React from 'react';
@@ -205,8 +205,8 @@ export var LibroSqlCell = /*#__PURE__*/React.forwardRef(function SqlEditorViewCo
205
205
  }), /*#__PURE__*/_jsx(CellEditor, {})]
206
206
  });
207
207
  });
208
- export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-view'), _dec3 = inject(LibroContextKey), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = prop(), _dec8 = prop(), _dec9 = inject(SqlScript), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroExecutableCellV) {
209
- _inherits(LibroSqlCellView, _LibroExecutableCellV);
208
+ export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-view'), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec6 = prop(), _dec7 = inject(SqlScript), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroEditableExecuta) {
209
+ _inherits(LibroSqlCellView, _LibroEditableExecuta);
210
210
  var _super = _createSuper(LibroSqlCellView);
211
211
  function LibroSqlCellView(options, cellService, viewManager, libroViewTracker, codeEditorManager) {
212
212
  var _options$cell;
@@ -215,16 +215,12 @@ export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-
215
215
  _this = _super.call(this, options, cellService);
216
216
  _this.view = LibroSqlCell;
217
217
  _this.libroViewTracker = void 0;
218
- _this.codeEditorManager = void 0;
219
- _this.toDisposeOnEditor = new DisposableCollection();
220
- _initializerDefineProperty(_this, "libroContextKey", _descriptor, _assertThisInitialized(_this));
221
218
  _this.outputs = void 0;
222
- _initializerDefineProperty(_this, "editorView", _descriptor2, _assertThisInitialized(_this));
223
- _initializerDefineProperty(_this, "databaseConfig", _descriptor3, _assertThisInitialized(_this));
224
- _initializerDefineProperty(_this, "editorStatus", _descriptor4, _assertThisInitialized(_this));
225
- _initializerDefineProperty(_this, "editorAreaHeight", _descriptor5, _assertThisInitialized(_this));
226
- _initializerDefineProperty(_this, "noEditorAreaHeight", _descriptor6, _assertThisInitialized(_this));
227
- _initializerDefineProperty(_this, "sqlScript", _descriptor7, _assertThisInitialized(_this));
219
+ _initializerDefineProperty(_this, "databaseConfig", _descriptor, _assertThisInitialized(_this));
220
+ _initializerDefineProperty(_this, "editorStatus", _descriptor2, _assertThisInitialized(_this));
221
+ _initializerDefineProperty(_this, "editorAreaHeight", _descriptor3, _assertThisInitialized(_this));
222
+ _initializerDefineProperty(_this, "noEditorAreaHeight", _descriptor4, _assertThisInitialized(_this));
223
+ _initializerDefineProperty(_this, "sqlScript", _descriptor5, _assertThisInitialized(_this));
228
224
  _this.editorViewReadyDeferred = new Deferred();
229
225
  _this.renderEditor = function () {
230
226
  if (_this.editorView) {
@@ -266,11 +262,6 @@ export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-
266
262
  (_this$container2 = _this.container) === null || _this$container2 === void 0 || (_this$container2 = _this$container2.current) === null || _this$container2 === void 0 || (_this$container2 = _this$container2.parentElement) === null || _this$container2 === void 0 || _this$container2.focus();
267
263
  }
268
264
  };
269
- _this.blur = function () {
270
- var _this$editorView, _this$editorView2;
271
- (_this$editorView = _this.editorView) === null || _this$editorView === void 0 || (_this$editorView = _this$editorView.editor) === null || _this$editorView === void 0 || _this$editorView.setOption('styleActiveLine', false);
272
- (_this$editorView2 = _this.editorView) === null || _this$editorView2 === void 0 || (_this$editorView2 = _this$editorView2.editor) === null || _this$editorView2 === void 0 || _this$editorView2.setOption('highlightActiveLineGutter', false);
273
- };
274
265
  _this.clearExecution = function () {
275
266
  _this.model.clearExecution();
276
267
  _this.outputArea.clear();
@@ -448,110 +439,6 @@ export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-
448
439
  var editorHostId = this.parent.id + this.id;
449
440
  this.codeEditorManager.setEditorHostRef(editorHostId, ref);
450
441
  }
451
- }, {
452
- key: "createEditor",
453
- value: function () {
454
- var _createEditor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
455
- var _this2 = this;
456
- var editorHostId, option, editorView;
457
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
458
- while (1) switch (_context5.prev = _context5.next) {
459
- case 0:
460
- editorHostId = this.parent.id + this.id;
461
- option = {
462
- uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
463
- editorHostId: editorHostId,
464
- model: this.model,
465
- config: {
466
- readOnly: !this.parent.model.inputEditable,
467
- editable: this.parent.model.inputEditable
468
- }
469
- }; // 防止虚拟滚动中编辑器被频繁创建
470
- if (!this.editorView) {
471
- _context5.next = 5;
472
- break;
473
- }
474
- this.editorStatus = EditorStatus.LOADED;
475
- return _context5.abrupt("return");
476
- case 5:
477
- _context5.next = 7;
478
- return this.codeEditorManager.getOrCreateEditorView(option);
479
- case 7:
480
- editorView = _context5.sent;
481
- this.editorView = editorView;
482
- this.editorStatus = EditorStatus.LOADED;
483
- this.editorViewReadyDeferred.resolve();
484
- editorView.onEditorStatusChange(function (e) {
485
- if (e.status === 'ready') {
486
- _this2.editor = _this2.editorView.editor;
487
- _this2.afterEditorReady();
488
- } else if (e.status === 'disposed') {
489
- _this2.toDisposeOnEditor.dispose();
490
- }
491
- });
492
- case 12:
493
- case "end":
494
- return _context5.stop();
495
- }
496
- }, _callee5, this);
497
- }));
498
- function createEditor() {
499
- return _createEditor.apply(this, arguments);
500
- }
501
- return createEditor;
502
- }()
503
- }, {
504
- key: "afterEditorReady",
505
- value: function () {
506
- var _afterEditorReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
507
- var _this3 = this,
508
- _this$editorView$onMo,
509
- _this$editorView3,
510
- _this$editor$onModelC,
511
- _this$editor,
512
- _this$editor$onModelC2;
513
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
514
- while (1) switch (_context6.prev = _context6.next) {
515
- case 0:
516
- this.focusEditor();
517
- this.toDisposeOnEditor.push(watch(this.parent.model, 'inputEditable', function () {
518
- var _this3$editorView;
519
- (_this3$editorView = _this3.editorView) === null || _this3$editorView === void 0 || (_this3$editorView = _this3$editorView.editor) === null || _this3$editorView === void 0 || _this3$editorView.setOption('readOnly', getOrigin(!_this3.parent.model.inputEditable));
520
- }));
521
- this.toDisposeOnEditor.push((_this$editorView$onMo = (_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0 ? void 0 : _this$editorView3.onModalChange(function (val) {
522
- return _this3.hasModal = val;
523
- })) !== null && _this$editorView$onMo !== void 0 ? _this$editorView$onMo : Disposable.NONE);
524
- this.toDisposeOnEditor.push((_this$editor$onModelC = (_this$editor = this.editor) === null || _this$editor === void 0 || (_this$editor$onModelC2 = _this$editor.onModelContentChanged) === null || _this$editor$onModelC2 === void 0 ? void 0 : _this$editor$onModelC2.call(_this$editor, function (e) {
525
- _this3.parent.model.onCellContentChange({
526
- cell: _this3,
527
- changes: e
528
- });
529
- })) !== null && _this$editor$onModelC !== void 0 ? _this$editor$onModelC : Disposable.NONE);
530
- case 4:
531
- case "end":
532
- return _context6.stop();
533
- }
534
- }, _callee6, this);
535
- }));
536
- function afterEditorReady() {
537
- return _afterEditorReady.apply(this, arguments);
538
- }
539
- return afterEditorReady;
540
- }()
541
- }, {
542
- key: "focusEditor",
543
- value: function focusEditor() {
544
- var _this$editorView4, _this$parent$model$ac;
545
- //选中cell、编辑模式、非只读时才focus
546
- 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 &&
547
- // 排除弹窗等情况
548
- this.parent.model.inputEditable) {
549
- var _this$editorView5, _this$editorView6, _this$editorView7;
550
- (_this$editorView5 = this.editorView) === null || _this$editorView5 === void 0 || _this$editorView5.editor.setOption('styleActiveLine', true);
551
- (_this$editorView6 = this.editorView) === null || _this$editorView6 === void 0 || _this$editorView6.editor.setOption('highlightActiveLineGutter', true);
552
- (_this$editorView7 = this.editorView) === null || _this$editorView7 === void 0 || _this$editorView7.editor.focus();
553
- }
554
- }
555
442
  }, {
556
443
  key: "toJSON",
557
444
  value: function toJSON() {
@@ -565,22 +452,22 @@ export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-
565
452
  }, {
566
453
  key: "run",
567
454
  value: function () {
568
- var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
569
- var _this4 = this;
455
+ var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
456
+ var _this2 = this;
570
457
  var libroModel, kernelConnection, cellContent, future, startTimeStr, msgPromise, endTimeStr;
571
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
572
- while (1) switch (_context7.prev = _context7.next) {
458
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
459
+ while (1) switch (_context5.prev = _context5.next) {
573
460
  case 0:
574
461
  libroModel = this.parent.model;
575
462
  if (!(!libroModel || !(libroModel instanceof LibroJupyterModel) || !libroModel.kernelConnection || libroModel.kernelConnection.isDisposed)) {
576
- _context7.next = 3;
463
+ _context5.next = 3;
577
464
  break;
578
465
  }
579
- return _context7.abrupt("return", false);
466
+ return _context5.abrupt("return", false);
580
467
  case 3:
581
468
  kernelConnection = getOrigin(libroModel.kernelConnection);
582
469
  cellContent = this.model.source;
583
- _context7.prev = 5;
470
+ _context5.prev = 5;
584
471
  // Promise.resolve().then(() => {
585
472
  this.clearExecution();
586
473
  // });
@@ -596,26 +483,26 @@ export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-
596
483
  };
597
484
  // Handle iopub messages
598
485
  future.onIOPub = function (msg) {
599
- _this4.model.msgChangeEmitter.fire(msg);
486
+ _this2.model.msgChangeEmitter.fire(msg);
600
487
  if (msg.header.msg_type === 'execute_input') {
601
- _this4.model.kernelExecuting = true;
488
+ _this2.model.kernelExecuting = true;
602
489
  startTimeStr = msg.header.date;
603
- var meta = _this4.model.metadata['execution'];
490
+ var meta = _this2.model.metadata['execution'];
604
491
  if (meta) {
605
492
  meta['shell.execute_reply.started'] = startTimeStr;
606
493
  }
607
494
  }
608
495
  if (msg.header.msg_type === 'execute_result') {
609
- _this4.model.metadata['isVariableSaved'] = msg.content.data['application/vnd.libro.sql+json'].isVariableSaved;
496
+ _this2.model.metadata['isVariableSaved'] = msg.content.data['application/vnd.libro.sql+json'].isVariableSaved;
610
497
  }
611
498
  if (msg.header.msg_type === 'error') {
612
- _this4.model.hasExecutedError = true;
499
+ _this2.model.hasExecutedError = true;
613
500
  }
614
501
  };
615
- _context7.next = 14;
502
+ _context5.next = 14;
616
503
  return future.done;
617
504
  case 14:
618
- msgPromise = _context7.sent;
505
+ msgPromise = _context5.sent;
619
506
  this.model.executing = false;
620
507
  this.model.kernelExecuting = false;
621
508
  this.model.hasExecutedSuccess = !this.model.hasExecutedError;
@@ -624,87 +511,71 @@ export var LibroSqlCellView = (_dec = transient(), _dec2 = view('libro-sql-cell-
624
511
  this.model.metadata['execution']['shell.execute_reply.started'] = startTimeStr;
625
512
  this.model.metadata['execution']['shell.execute_reply.end'] = endTimeStr;
626
513
  if (msgPromise) {
627
- _context7.next = 24;
514
+ _context5.next = 24;
628
515
  break;
629
516
  }
630
- return _context7.abrupt("return", true);
517
+ return _context5.abrupt("return", true);
631
518
  case 24:
632
519
  if (!(msgPromise.content.status === 'ok')) {
633
- _context7.next = 28;
520
+ _context5.next = 28;
634
521
  break;
635
522
  }
636
- return _context7.abrupt("return", true);
523
+ return _context5.abrupt("return", true);
637
524
  case 28:
638
525
  throw new KernelError(msgPromise.content);
639
526
  case 29:
640
- _context7.next = 36;
527
+ _context5.next = 36;
641
528
  break;
642
529
  case 31:
643
- _context7.prev = 31;
644
- _context7.t0 = _context7["catch"](5);
645
- if (!_context7.t0.message.startsWith('Canceled')) {
646
- _context7.next = 35;
530
+ _context5.prev = 31;
531
+ _context5.t0 = _context5["catch"](5);
532
+ if (!_context5.t0.message.startsWith('Canceled')) {
533
+ _context5.next = 35;
647
534
  break;
648
535
  }
649
- return _context7.abrupt("return", false);
536
+ return _context5.abrupt("return", false);
650
537
  case 35:
651
- throw _context7.t0;
538
+ throw _context5.t0;
652
539
  case 36:
653
540
  case "end":
654
- return _context7.stop();
541
+ return _context5.stop();
655
542
  }
656
- }, _callee7, this, [[5, 31]]);
543
+ }, _callee5, this, [[5, 31]]);
657
544
  }));
658
545
  function run() {
659
546
  return _run.apply(this, arguments);
660
547
  }
661
548
  return run;
662
549
  }()
663
- }, {
664
- key: "shouldEnterEditorMode",
665
- value: function shouldEnterEditorMode(e) {
666
- var _getOrigin;
667
- return (_getOrigin = getOrigin(this.editorView)) !== null && _getOrigin !== void 0 && (_getOrigin = _getOrigin.editor) !== null && _getOrigin !== void 0 && (_getOrigin = _getOrigin.host) !== null && _getOrigin !== void 0 && _getOrigin.contains(e.target) ? true : false;
668
- }
669
550
  }]);
670
551
  return LibroSqlCellView;
671
- }(LibroExecutableCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroContextKey", [_dec3], {
672
- configurable: true,
673
- enumerable: true,
674
- writable: true,
675
- initializer: null
676
- }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "editorView", [_dec4], {
677
- configurable: true,
678
- enumerable: true,
679
- writable: true,
680
- initializer: null
681
- }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "databaseConfig", [_dec5], {
552
+ }(LibroEditableExecutableCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "databaseConfig", [_dec3], {
682
553
  configurable: true,
683
554
  enumerable: true,
684
555
  writable: true,
685
556
  initializer: null
686
- }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "editorStatus", [_dec6], {
557
+ }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "editorStatus", [_dec4], {
687
558
  configurable: true,
688
559
  enumerable: true,
689
560
  writable: true,
690
561
  initializer: function initializer() {
691
562
  return EditorStatus.NOTLOADED;
692
563
  }
693
- }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "editorAreaHeight", [_dec7], {
564
+ }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "editorAreaHeight", [_dec5], {
694
565
  configurable: true,
695
566
  enumerable: true,
696
567
  writable: true,
697
568
  initializer: function initializer() {
698
569
  return 0;
699
570
  }
700
- }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "noEditorAreaHeight", [_dec8], {
571
+ }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "noEditorAreaHeight", [_dec6], {
701
572
  configurable: true,
702
573
  enumerable: true,
703
574
  writable: true,
704
575
  initializer: function initializer() {
705
576
  return 0;
706
577
  }
707
- }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "sqlScript", [_dec9], {
578
+ }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "sqlScript", [_dec7], {
708
579
  configurable: true,
709
580
  enumerable: true,
710
581
  writable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-sql-cell",
3
- "version": "0.2.34",
3
+ "version": "0.2.35-next.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -32,10 +32,10 @@
32
32
  "src"
33
33
  ],
34
34
  "dependencies": {
35
- "@difizen/libro-code-editor": "^0.2.34",
36
- "@difizen/libro-jupyter": "^0.2.34",
37
- "@difizen/libro-rendermime": "^0.2.34",
38
- "@difizen/libro-common": "^0.2.34",
35
+ "@difizen/libro-code-editor": "^0.2.35-next.0",
36
+ "@difizen/libro-jupyter": "^0.2.35-next.0",
37
+ "@difizen/libro-rendermime": "^0.2.35-next.0",
38
+ "@difizen/libro-common": "^0.2.35-next.0",
39
39
  "@ant-design/icons": "^5.1.0",
40
40
  "@difizen/mana-app": "latest",
41
41
  "@difizen/mana-l10n": "latest"
@@ -1,8 +1,7 @@
1
1
  import { EditFilled, DatabaseOutlined } from '@ant-design/icons';
2
- import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
3
2
  import { CodeEditorManager } from '@difizen/libro-code-editor';
4
3
  import type { ICodeCell, IOutput } from '@difizen/libro-common';
5
- import { CellUri, isOutput } from '@difizen/libro-common';
4
+ import { isOutput } from '@difizen/libro-common';
6
5
  import type {
7
6
  CellViewOptions,
8
7
  ExecutionMeta,
@@ -14,7 +13,7 @@ import {
14
13
  CellService,
15
14
  EditorStatus,
16
15
  LibroContextKey,
17
- LibroExecutableCellView,
16
+ LibroEditableExecutableCellView,
18
17
  LibroViewTracker,
19
18
  VirtualizedManagerHelper,
20
19
  KernelError,
@@ -24,8 +23,6 @@ import {
24
23
  import type { ViewSize } from '@difizen/mana-app';
25
24
  import {
26
25
  Deferred,
27
- Disposable,
28
- DisposableCollection,
29
26
  getOrigin,
30
27
  inject,
31
28
  prop,
@@ -36,7 +33,6 @@ import {
36
33
  ViewManager,
37
34
  ViewOption,
38
35
  ViewRender,
39
- watch,
40
36
  } from '@difizen/mana-app';
41
37
  import { l10n } from '@difizen/mana-l10n';
42
38
  import { Input, Popover } from 'antd';
@@ -226,20 +222,13 @@ export const LibroSqlCell = React.forwardRef<HTMLDivElement>(
226
222
 
227
223
  @transient()
228
224
  @view('libro-sql-cell-view')
229
- export class LibroSqlCellView extends LibroExecutableCellView {
225
+ export class LibroSqlCellView extends LibroEditableExecutableCellView {
230
226
  override view = LibroSqlCell;
231
227
  declare model: LibroSqlCellModel;
232
228
  libroViewTracker: LibroViewTracker;
233
- codeEditorManager: CodeEditorManager;
234
- protected toDisposeOnEditor = new DisposableCollection();
235
-
236
- @inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
237
229
 
238
230
  outputs: IOutput[];
239
231
 
240
- @prop()
241
- editorView?: CodeEditorView;
242
-
243
232
  @prop()
244
233
  databaseConfig?: DatabaseConfig;
245
234
 
@@ -353,74 +342,6 @@ export class LibroSqlCellView extends LibroExecutableCellView {
353
342
  this.codeEditorManager.setEditorHostRef(editorHostId, ref);
354
343
  }
355
344
 
356
- async createEditor() {
357
- const editorHostId = this.parent.id + this.id;
358
- const option: CodeEditorViewOptions = {
359
- uuid: CellUri.from(this.parent.model.id, this.model.id).toString(),
360
- editorHostId: editorHostId,
361
- model: this.model,
362
- config: {
363
- readOnly: !this.parent.model.inputEditable,
364
- editable: this.parent.model.inputEditable,
365
- },
366
- };
367
- // 防止虚拟滚动中编辑器被频繁创建
368
- if (this.editorView) {
369
- this.editorStatus = EditorStatus.LOADED;
370
- return;
371
- }
372
-
373
- const editorView = await this.codeEditorManager.getOrCreateEditorView(option);
374
-
375
- this.editorView = editorView;
376
- this.editorStatus = EditorStatus.LOADED;
377
- this.editorViewReadyDeferred.resolve();
378
- editorView.onEditorStatusChange((e) => {
379
- if (e.status === 'ready') {
380
- this.editor = this.editorView!.editor;
381
- this.afterEditorReady();
382
- } else if (e.status === 'disposed') {
383
- this.toDisposeOnEditor.dispose();
384
- }
385
- });
386
- }
387
-
388
- protected async afterEditorReady() {
389
- this.focusEditor();
390
- this.toDisposeOnEditor.push(
391
- watch(this.parent.model, 'inputEditable', () => {
392
- this.editorView?.editor?.setOption(
393
- 'readOnly',
394
- getOrigin(!this.parent.model.inputEditable),
395
- );
396
- }),
397
- );
398
- this.toDisposeOnEditor.push(
399
- this.editorView?.onModalChange((val) => (this.hasModal = val)) ?? Disposable.NONE,
400
- );
401
- this.toDisposeOnEditor.push(
402
- this.editor?.onModelContentChanged?.((e) => {
403
- this.parent.model.onCellContentChange({ cell: this, changes: e });
404
- }) ?? Disposable.NONE,
405
- );
406
- }
407
-
408
- protected focusEditor() {
409
- //选中cell、编辑模式、非只读时才focus
410
- if (
411
- this.editorView?.editor &&
412
- this.editorView.editorStatus === 'ready' &&
413
- this.parent.model.active?.id === this.id &&
414
- !this.parent.model.commandMode &&
415
- this.libroContextKey.commandModeEnabled === true && // 排除弹窗等情况
416
- this.parent.model.inputEditable
417
- ) {
418
- this.editorView?.editor.setOption('styleActiveLine', true);
419
- this.editorView?.editor.setOption('highlightActiveLineGutter', true);
420
- this.editorView?.editor.focus();
421
- }
422
- }
423
-
424
345
  override onViewResize = (size: ViewSize): void => {
425
346
  // 把 header 部分高度也放在这部分,用来撑开高度
426
347
  if (size.height) {
@@ -449,11 +370,6 @@ export class LibroSqlCellView extends LibroExecutableCellView {
449
370
  }
450
371
  };
451
372
 
452
- override blur = () => {
453
- this.editorView?.editor?.setOption('styleActiveLine', false);
454
- this.editorView?.editor?.setOption('highlightActiveLineGutter', false);
455
- };
456
-
457
373
  override clearExecution = () => {
458
374
  this.model.clearExecution();
459
375
  this.outputArea.clear();
@@ -591,10 +507,4 @@ export class LibroSqlCellView extends LibroExecutableCellView {
591
507
  }),
592
508
  );
593
509
  };
594
-
595
- override shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>) {
596
- return getOrigin(this.editorView)?.editor?.host?.contains(e.target as HTMLElement)
597
- ? true
598
- : false;
599
- }
600
510
  }