@difizen/libro-raw-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.
- package/es/raw-cell-view.d.ts +2 -2
- package/es/raw-cell-view.js +10 -10
- package/package.json +5 -5
- package/src/raw-cell-view.tsx +8 -8
package/es/raw-cell-view.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
|
|
2
2
|
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
3
3
|
import type { CellViewOptions } from '@difizen/libro-core';
|
|
4
|
-
import { CellService, LibroEditorCellView,
|
|
4
|
+
import { CellService, LibroEditorCellView, LibroContextKey } from '@difizen/libro-core';
|
|
5
5
|
import { ViewManager } from '@difizen/mana-app';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import type { LibroRawCellModel } from './raw-cell-model.js';
|
|
8
8
|
export declare class LibroRawCellView extends LibroEditorCellView {
|
|
9
|
-
protected readonly
|
|
9
|
+
protected readonly libroContextKey: LibroContextKey;
|
|
10
10
|
model: LibroRawCellModel;
|
|
11
11
|
view: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
|
|
12
12
|
viewManager: ViewManager;
|
package/es/raw-cell-view.js
CHANGED
|
@@ -22,7 +22,7 @@ function _initializerWarningHelper(descriptor, context) { throw new Error('Decor
|
|
|
22
22
|
/* eslint-disable @typescript-eslint/parameter-properties */
|
|
23
23
|
|
|
24
24
|
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
25
|
-
import { CellService, LibroEditorCellView,
|
|
25
|
+
import { CellService, LibroEditorCellView, LibroContextKey } from '@difizen/libro-core';
|
|
26
26
|
import { getOrigin, prop, useInject, watch } from '@difizen/mana-app';
|
|
27
27
|
import { view, ViewInstance, ViewManager, ViewOption, ViewRender } from '@difizen/mana-app';
|
|
28
28
|
import { inject, transient } from '@difizen/mana-app';
|
|
@@ -54,14 +54,14 @@ var CodeEditorViewComponent = /*#__PURE__*/React.forwardRef(function CodeEditorV
|
|
|
54
54
|
children: /*#__PURE__*/_jsx(CellEditorMemo, {})
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
|
-
export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view'), _dec3 = inject(
|
|
57
|
+
export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view'), _dec3 = inject(LibroContextKey), _dec4 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroEditorCellView) {
|
|
58
58
|
_inherits(LibroRawCellView, _LibroEditorCellView);
|
|
59
59
|
var _super = _createSuper(LibroRawCellView);
|
|
60
60
|
function LibroRawCellView(options, cellService, viewManager, codeEditorManager) {
|
|
61
61
|
var _this;
|
|
62
62
|
_classCallCheck(this, LibroRawCellView);
|
|
63
63
|
_this = _super.call(this, options, cellService);
|
|
64
|
-
_initializerDefineProperty(_this, "
|
|
64
|
+
_initializerDefineProperty(_this, "libroContextKey", _descriptor, _assertThisInitialized(_this));
|
|
65
65
|
_this.view = CodeEditorViewComponent;
|
|
66
66
|
_this.viewManager = void 0;
|
|
67
67
|
_this.codeEditorManager = void 0;
|
|
@@ -107,8 +107,8 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
|
|
|
107
107
|
editorHostId: this.parent.id + this.id,
|
|
108
108
|
model: this.model,
|
|
109
109
|
config: {
|
|
110
|
-
readOnly: this.parent.model.
|
|
111
|
-
editable:
|
|
110
|
+
readOnly: !this.parent.model.inputEditable,
|
|
111
|
+
editable: this.parent.model.inputEditable,
|
|
112
112
|
lineNumbers: false,
|
|
113
113
|
foldGutter: false,
|
|
114
114
|
lineWrap: 'on',
|
|
@@ -153,9 +153,9 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
|
|
|
153
153
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
154
154
|
while (1) switch (_context2.prev = _context2.next) {
|
|
155
155
|
case 0:
|
|
156
|
-
watch(this.parent.model, '
|
|
156
|
+
watch(this.parent.model, 'inputEditable', function () {
|
|
157
157
|
var _this2$editorView;
|
|
158
|
-
(_this2$editorView = _this2.editorView) === null || _this2$editorView === void 0 || _this2$editorView.editor.setOption('readOnly', _this2.parent.model.
|
|
158
|
+
(_this2$editorView = _this2.editorView) === null || _this2$editorView === void 0 || _this2$editorView.editor.setOption('readOnly', !_this2.parent.model.inputEditable);
|
|
159
159
|
});
|
|
160
160
|
case 1:
|
|
161
161
|
case "end":
|
|
@@ -179,9 +179,9 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
|
|
|
179
179
|
value: function focusEditor() {
|
|
180
180
|
var _this$editorView, _this$parent$model$ac2;
|
|
181
181
|
//选中cell、编辑模式、非只读时才focus
|
|
182
|
-
if ((_this$editorView = this.editorView) !== null && _this$editorView !== void 0 && _this$editorView.editor && this.editorView.editorStatus === 'ready' && ((_this$parent$model$ac2 = this.parent.model.active) === null || _this$parent$model$ac2 === void 0 ? void 0 : _this$parent$model$ac2.id) === this.id && !this.parent.model.commandMode && this.
|
|
182
|
+
if ((_this$editorView = this.editorView) !== null && _this$editorView !== void 0 && _this$editorView.editor && this.editorView.editorStatus === 'ready' && ((_this$parent$model$ac2 = this.parent.model.active) === null || _this$parent$model$ac2 === void 0 ? void 0 : _this$parent$model$ac2.id) === this.id && !this.parent.model.commandMode && this.libroContextKey.commandModeEnabled === true &&
|
|
183
183
|
// 排除弹窗等情况
|
|
184
|
-
this.parent.model.
|
|
184
|
+
this.parent.model.inputEditable) {
|
|
185
185
|
var _this$editorView2, _this$editorView3, _this$editorView4;
|
|
186
186
|
(_this$editorView2 = this.editorView) === null || _this$editorView2 === void 0 || _this$editorView2.editor.setOption('styleActiveLine', true);
|
|
187
187
|
(_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0 || _this$editorView3.editor.setOption('highlightActiveLineGutter', true);
|
|
@@ -190,7 +190,7 @@ export var LibroRawCellView = (_dec = transient(), _dec2 = view('raw-cell-view')
|
|
|
190
190
|
}
|
|
191
191
|
}]);
|
|
192
192
|
return LibroRawCellView;
|
|
193
|
-
}(LibroEditorCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "
|
|
193
|
+
}(LibroEditorCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroContextKey", [_dec3], {
|
|
194
194
|
configurable: true,
|
|
195
195
|
enumerable: true,
|
|
196
196
|
writable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-raw-cell",
|
|
3
|
-
"version": "0.2.
|
|
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.
|
|
36
|
-
"@difizen/libro-common": "^0.2.
|
|
37
|
-
"@difizen/libro-core": "^0.2.
|
|
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": "
|
|
41
|
+
"react": ">=16"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/react": "^18.2.25"
|
package/src/raw-cell-view.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type { CodeEditorViewOptions, CodeEditorView } from '@difizen/libro-code-editor';
|
|
4
4
|
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
5
5
|
import type { CellViewOptions } from '@difizen/libro-core';
|
|
6
|
-
import { CellService, LibroEditorCellView,
|
|
6
|
+
import { CellService, LibroEditorCellView, LibroContextKey } from '@difizen/libro-core';
|
|
7
7
|
import { getOrigin, prop, useInject, watch } from '@difizen/mana-app';
|
|
8
8
|
import {
|
|
9
9
|
view,
|
|
@@ -43,7 +43,7 @@ const CodeEditorViewComponent = React.forwardRef<HTMLDivElement>(
|
|
|
43
43
|
@transient()
|
|
44
44
|
@view('raw-cell-view')
|
|
45
45
|
export class LibroRawCellView extends LibroEditorCellView {
|
|
46
|
-
@inject(
|
|
46
|
+
@inject(LibroContextKey) protected readonly libroContextKey: LibroContextKey;
|
|
47
47
|
declare model: LibroRawCellModel;
|
|
48
48
|
override view = CodeEditorViewComponent;
|
|
49
49
|
|
|
@@ -80,8 +80,8 @@ export class LibroRawCellView extends LibroEditorCellView {
|
|
|
80
80
|
editorHostId: this.parent.id + this.id,
|
|
81
81
|
model: this.model,
|
|
82
82
|
config: {
|
|
83
|
-
readOnly: this.parent.model.
|
|
84
|
-
editable:
|
|
83
|
+
readOnly: !this.parent.model.inputEditable,
|
|
84
|
+
editable: this.parent.model.inputEditable,
|
|
85
85
|
lineNumbers: false,
|
|
86
86
|
foldGutter: false,
|
|
87
87
|
lineWrap: 'on',
|
|
@@ -102,8 +102,8 @@ export class LibroRawCellView extends LibroEditorCellView {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
protected async afterEditorReady() {
|
|
105
|
-
watch(this.parent.model, '
|
|
106
|
-
this.editorView?.editor.setOption('readOnly', this.parent.model.
|
|
105
|
+
watch(this.parent.model, 'inputEditable', () => {
|
|
106
|
+
this.editorView?.editor.setOption('readOnly', !this.parent.model.inputEditable);
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -126,8 +126,8 @@ export class LibroRawCellView extends LibroEditorCellView {
|
|
|
126
126
|
this.editorView.editorStatus === 'ready' &&
|
|
127
127
|
this.parent.model.active?.id === this.id &&
|
|
128
128
|
!this.parent.model.commandMode &&
|
|
129
|
-
this.
|
|
130
|
-
this.parent.model.
|
|
129
|
+
this.libroContextKey.commandModeEnabled === true && // 排除弹窗等情况
|
|
130
|
+
this.parent.model.inputEditable
|
|
131
131
|
) {
|
|
132
132
|
this.editorView?.editor.setOption('styleActiveLine', true);
|
|
133
133
|
this.editorView?.editor.setOption('highlightActiveLineGutter', true);
|