@difizen/libro-prompt-cell 0.2.0 → 0.2.2
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/index.d.ts +2 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +2 -0
- package/es/input-handler/chat-record-input.js +2 -2
- package/es/input-handler/variable-name-input.js +2 -2
- package/es/prompt-cell-command-contribution.js +1 -1
- package/es/prompt-cell-script.d.ts +2 -2
- package/es/prompt-cell-script.d.ts.map +1 -1
- package/es/prompt-cell-script.js +2 -2
- package/es/prompt-cell-view.d.ts +2 -2
- package/es/prompt-cell-view.js +10 -10
- package/package.json +8 -8
- package/src/index.ts +2 -0
- package/src/input-handler/chat-record-input.tsx +2 -2
- package/src/input-handler/variable-name-input.tsx +2 -2
- package/src/prompt-cell-command-contribution.ts +1 -1
- package/src/prompt-cell-script.ts +2 -2
- package/src/prompt-cell-view.tsx +8 -8
package/es/index.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ export * from './prompt-cell-contribution.js';
|
|
|
2
2
|
export * from './prompt-cell-model.js';
|
|
3
3
|
export * from './prompt-cell-protocol.js';
|
|
4
4
|
export * from './prompt-cell-view.js';
|
|
5
|
+
export * from './prompt-cell-script.js';
|
|
6
|
+
export * from './input-handler/index.js';
|
|
5
7
|
export * from './module.js';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC"}
|
package/es/index.js
CHANGED
|
@@ -2,4 +2,6 @@ export * from "./prompt-cell-contribution.js";
|
|
|
2
2
|
export * from "./prompt-cell-model.js";
|
|
3
3
|
export * from "./prompt-cell-protocol.js";
|
|
4
4
|
export * from "./prompt-cell-view.js";
|
|
5
|
+
export * from "./prompt-cell-script.js";
|
|
6
|
+
export * from "./input-handler/index.js";
|
|
5
7
|
export * from "./module.js";
|
|
@@ -5,7 +5,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { EditFilled } from '@ant-design/icons';
|
|
8
|
-
import {
|
|
8
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
9
9
|
import { useInject } from '@difizen/mana-app';
|
|
10
10
|
import { Select, Tag } from 'antd';
|
|
11
11
|
import classNames from 'classnames';
|
|
@@ -28,7 +28,7 @@ export var ChatRecordInput = function ChatRecordInput(props) {
|
|
|
28
28
|
selecting = _useState2[0],
|
|
29
29
|
setSelecting = _useState2[1];
|
|
30
30
|
var ref = useRef(null);
|
|
31
|
-
var contextKey = useInject(
|
|
31
|
+
var contextKey = useInject(LibroContextKey);
|
|
32
32
|
useEffect(function () {
|
|
33
33
|
if (selecting) {
|
|
34
34
|
var _selectRef$current;
|
|
@@ -11,7 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import { EditFilled } from '@ant-design/icons';
|
|
14
|
-
import {
|
|
14
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
15
15
|
import { useInject } from '@difizen/mana-app';
|
|
16
16
|
import { l10n } from '@difizen/mana-l10n';
|
|
17
17
|
import { Input, Popover } from 'antd';
|
|
@@ -79,7 +79,7 @@ export var VariableNameInput = function VariableNameInput(props) {
|
|
|
79
79
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
80
80
|
popoverVisible = _useState6[0],
|
|
81
81
|
setPopoverVisible = _useState6[1];
|
|
82
|
-
var contextKey = useInject(
|
|
82
|
+
var contextKey = useInject(LibroContextKey);
|
|
83
83
|
var ref = useRef(null);
|
|
84
84
|
return /*#__PURE__*/_jsxs("div", {
|
|
85
85
|
className: classNames(variableNameInputCls, props.classname),
|
|
@@ -40,7 +40,7 @@ export var LibroPromptCellCommandContribution = (_dec = singleton({
|
|
|
40
40
|
libro.invertCell(cell, 'prompt');
|
|
41
41
|
},
|
|
42
42
|
isEnabled: function isEnabled(cell, libro) {
|
|
43
|
-
if (!libro || !(libro instanceof LibroView) || libro.model.
|
|
43
|
+
if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
46
|
return true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare class PromptScript {
|
|
2
|
-
readonly getChatObjects
|
|
3
|
-
readonly getChatRecoreds
|
|
2
|
+
readonly getChatObjects: string;
|
|
3
|
+
readonly getChatRecoreds: string;
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=prompt-cell-script.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-cell-script.d.ts","sourceRoot":"","sources":["../src/prompt-cell-script.ts"],"names":[],"mappings":"AAEA,qBACa,YAAY;IACvB,SAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"prompt-cell-script.d.ts","sourceRoot":"","sources":["../src/prompt-cell-script.ts"],"names":[],"mappings":"AAEA,qBACa,YAAY;IACvB,SAAgB,cAAc,EAAE,MAAM,CACF;IACpC,SAAgB,eAAe,EAAE,MAAM,CACL;CACnC"}
|
package/es/prompt-cell-script.js
CHANGED
|
@@ -8,6 +8,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
8
8
|
import { singleton } from '@difizen/mana-app';
|
|
9
9
|
export var PromptScript = (_dec = singleton(), _dec(_class = /*#__PURE__*/_createClass(function PromptScript() {
|
|
10
10
|
_classCallCheck(this, PromptScript);
|
|
11
|
-
this.getChatObjects = "from
|
|
12
|
-
this.getChatRecoreds = "from
|
|
11
|
+
this.getChatObjects = "from libro_ai import chat_object_manager\nchat_object_manager.dump_list_json()";
|
|
12
|
+
this.getChatRecoreds = "from libro_ai import chat_record_provider\nchat_record_provider.get_records()";
|
|
13
13
|
})) || _class);
|
package/es/prompt-cell-view.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { CodeEditorViewOptions, IRange, CodeEditorView } from '@difizen/lib
|
|
|
3
3
|
import type { IOutput } from '@difizen/libro-common';
|
|
4
4
|
import type { LibroCell, CellViewOptions } from '@difizen/libro-core';
|
|
5
5
|
import { LibroOutputArea } from '@difizen/libro-core';
|
|
6
|
-
import { CellService, LibroExecutableCellView, LibroViewTracker,
|
|
6
|
+
import { CellService, LibroExecutableCellView, LibroViewTracker, LibroContextKey } from '@difizen/libro-core';
|
|
7
7
|
import type { KernelMessage } from '@difizen/libro-jupyter';
|
|
8
8
|
import { ViewManager } from '@difizen/mana-app';
|
|
9
9
|
import { Deferred } from '@difizen/mana-app';
|
|
@@ -24,7 +24,7 @@ export interface ChatObjectOptions {
|
|
|
24
24
|
}
|
|
25
25
|
export declare const CellEditor: React.NamedExoticComponent<{}>;
|
|
26
26
|
export declare class LibroPromptCellView extends LibroExecutableCellView {
|
|
27
|
-
protected
|
|
27
|
+
protected libroContextKey: LibroContextKey;
|
|
28
28
|
view: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
|
|
29
29
|
model: LibroPromptCellModel;
|
|
30
30
|
chatObjects: ChatObject[];
|
package/es/prompt-cell-view.js
CHANGED
|
@@ -36,7 +36,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
36
36
|
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
37
37
|
import { isOutput } from '@difizen/libro-common';
|
|
38
38
|
import { LibroOutputArea } from '@difizen/libro-core';
|
|
39
|
-
import { CellService, LibroExecutableCellView, LibroViewTracker, EditorStatus,
|
|
39
|
+
import { CellService, LibroExecutableCellView, LibroViewTracker, EditorStatus, LibroContextKey } from '@difizen/libro-core';
|
|
40
40
|
import { KernelError, LibroJupyterModel } from '@difizen/libro-jupyter';
|
|
41
41
|
import { getOrigin, inject, prop, transient, useInject, view, ViewInstance, ViewManager, ViewOption, ViewRender, watch } from '@difizen/mana-app';
|
|
42
42
|
import { Deferred } from '@difizen/mana-app';
|
|
@@ -207,7 +207,7 @@ var PropmtEditorViewComponent = /*#__PURE__*/React.forwardRef(function MaxPropmt
|
|
|
207
207
|
}), /*#__PURE__*/_jsx(CellEditor, {})]
|
|
208
208
|
});
|
|
209
209
|
});
|
|
210
|
-
export var LibroPromptCellView = (_dec = transient(), _dec2 = view('prompt-editor-cell-view'), _dec3 = inject(
|
|
210
|
+
export var LibroPromptCellView = (_dec = transient(), _dec2 = view('prompt-editor-cell-view'), _dec3 = inject(LibroContextKey), _dec4 = prop(), _dec5 = prop(), _dec6 = inject(CodeEditorManager), _dec7 = inject(PromptScript), _dec8 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_LibroExecutableCellV) {
|
|
211
211
|
_inherits(LibroPromptCellView, _LibroExecutableCellV);
|
|
212
212
|
var _super = _createSuper(LibroPromptCellView);
|
|
213
213
|
function LibroPromptCellView(options, cellService, viewManager, libroViewTracker) {
|
|
@@ -215,7 +215,7 @@ export var LibroPromptCellView = (_dec = transient(), _dec2 = view('prompt-edito
|
|
|
215
215
|
var _this;
|
|
216
216
|
_classCallCheck(this, LibroPromptCellView);
|
|
217
217
|
_this = _super.call(this, options, cellService);
|
|
218
|
-
_initializerDefineProperty(_this, "
|
|
218
|
+
_initializerDefineProperty(_this, "libroContextKey", _descriptor, _assertThisInitialized(_this));
|
|
219
219
|
_this.view = PropmtEditorViewComponent;
|
|
220
220
|
// TODO: Chat objects and chat message records should belong to libro rather than cell
|
|
221
221
|
_initializerDefineProperty(_this, "chatObjects", _descriptor2, _assertThisInitialized(_this));
|
|
@@ -526,8 +526,8 @@ export var LibroPromptCellView = (_dec = transient(), _dec2 = view('prompt-edito
|
|
|
526
526
|
editorHostId: this.parent.id + this.id,
|
|
527
527
|
model: this.model,
|
|
528
528
|
config: {
|
|
529
|
-
readOnly: this.parent.model.
|
|
530
|
-
editable:
|
|
529
|
+
readOnly: !this.parent.model.inputEditable,
|
|
530
|
+
editable: this.parent.model.inputEditable
|
|
531
531
|
}
|
|
532
532
|
};
|
|
533
533
|
return option;
|
|
@@ -579,9 +579,9 @@ export var LibroPromptCellView = (_dec = transient(), _dec2 = view('prompt-edito
|
|
|
579
579
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
580
580
|
while (1) switch (_context7.prev = _context7.next) {
|
|
581
581
|
case 0:
|
|
582
|
-
watch(this.parent.model, '
|
|
582
|
+
watch(this.parent.model, 'inputEditable', function () {
|
|
583
583
|
var _this3$editorView;
|
|
584
|
-
(_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.
|
|
584
|
+
(_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));
|
|
585
585
|
});
|
|
586
586
|
(_this$editorView3 = this.editorView) === null || _this$editorView3 === void 0 || _this$editorView3.onModalChange(function (val) {
|
|
587
587
|
return _this3.hasModal = val;
|
|
@@ -608,9 +608,9 @@ export var LibroPromptCellView = (_dec = transient(), _dec2 = view('prompt-edito
|
|
|
608
608
|
value: function focusEditor() {
|
|
609
609
|
var _this$editorView4, _this$parent$model$ac2;
|
|
610
610
|
//选中cell、编辑模式、非只读时才focus
|
|
611
|
-
if ((_this$editorView4 = this.editorView) !== null && _this$editorView4 !== void 0 && _this$editorView4.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.
|
|
611
|
+
if ((_this$editorView4 = this.editorView) !== null && _this$editorView4 !== void 0 && _this$editorView4.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 &&
|
|
612
612
|
// 排除弹窗等情况
|
|
613
|
-
this.parent.model.
|
|
613
|
+
this.parent.model.inputEditable) {
|
|
614
614
|
var _this$editorView5, _this$editorView6, _this$editorView7;
|
|
615
615
|
(_this$editorView5 = this.editorView) === null || _this$editorView5 === void 0 || _this$editorView5.editor.setOption('styleActiveLine', true);
|
|
616
616
|
(_this$editorView6 = this.editorView) === null || _this$editorView6 === void 0 || _this$editorView6.editor.setOption('highlightActiveLineGutter', true);
|
|
@@ -715,7 +715,7 @@ export var LibroPromptCellView = (_dec = transient(), _dec2 = view('prompt-edito
|
|
|
715
715
|
}()
|
|
716
716
|
}]);
|
|
717
717
|
return LibroPromptCellView;
|
|
718
|
-
}(LibroExecutableCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "
|
|
718
|
+
}(LibroExecutableCellView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "libroContextKey", [_dec3], {
|
|
719
719
|
configurable: true,
|
|
720
720
|
enumerable: true,
|
|
721
721
|
writable: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-prompt-cell",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@difizen/libro-code-editor": "^0.2.
|
|
36
|
-
"@difizen/libro-jupyter": "^0.2.
|
|
37
|
-
"@difizen/libro-rendermime": "^0.2.
|
|
38
|
-
"@difizen/libro-codemirror": "^0.2.
|
|
39
|
-
"@difizen/libro-common": "^0.2.
|
|
40
|
-
"@difizen/libro-core": "^0.2.
|
|
35
|
+
"@difizen/libro-code-editor": "^0.2.2",
|
|
36
|
+
"@difizen/libro-jupyter": "^0.2.2",
|
|
37
|
+
"@difizen/libro-rendermime": "^0.2.2",
|
|
38
|
+
"@difizen/libro-codemirror": "^0.2.2",
|
|
39
|
+
"@difizen/libro-common": "^0.2.2",
|
|
40
|
+
"@difizen/libro-core": "^0.2.2",
|
|
41
41
|
"@ant-design/icons": "^5.1.0",
|
|
42
42
|
"@difizen/mana-l10n": "latest",
|
|
43
43
|
"@difizen/mana-app": "latest",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react-dom": "^18.2.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"react": "
|
|
54
|
+
"react": ">=16",
|
|
55
55
|
"antd": "^5.8.6"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -2,4 +2,6 @@ export * from './prompt-cell-contribution.js';
|
|
|
2
2
|
export * from './prompt-cell-model.js';
|
|
3
3
|
export * from './prompt-cell-protocol.js';
|
|
4
4
|
export * from './prompt-cell-view.js';
|
|
5
|
+
export * from './prompt-cell-script.js';
|
|
6
|
+
export * from './input-handler/index.js';
|
|
5
7
|
export * from './module.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditFilled } from '@ant-design/icons';
|
|
2
|
-
import {
|
|
2
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
3
3
|
import { useInject } from '@difizen/mana-app';
|
|
4
4
|
import { Select, Tag } from 'antd';
|
|
5
5
|
import classNames from 'classnames';
|
|
@@ -25,7 +25,7 @@ export const ChatRecordInput: FC<ChatRecordInputProps> = (
|
|
|
25
25
|
const selectRef = useRef<BaseSelectRef>(null);
|
|
26
26
|
const [selecting, setSelecting] = useState(false);
|
|
27
27
|
const ref = useRef<HTMLDivElement>(null);
|
|
28
|
-
const contextKey = useInject(
|
|
28
|
+
const contextKey = useInject(LibroContextKey);
|
|
29
29
|
|
|
30
30
|
useEffect(() => {
|
|
31
31
|
if (selecting) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditFilled } from '@ant-design/icons';
|
|
2
|
-
import {
|
|
2
|
+
import { LibroContextKey } from '@difizen/libro-core';
|
|
3
3
|
import { useInject } from '@difizen/mana-app';
|
|
4
4
|
import { l10n } from '@difizen/mana-l10n';
|
|
5
5
|
import { Input, Popover } from 'antd';
|
|
@@ -80,7 +80,7 @@ export const VariableNameInput: FC<VariableNameInputProps> = (
|
|
|
80
80
|
) => {
|
|
81
81
|
const { value } = props;
|
|
82
82
|
const [popoverVisible, setPopoverVisible] = useState(false);
|
|
83
|
-
const contextKey = useInject(
|
|
83
|
+
const contextKey = useInject(LibroContextKey);
|
|
84
84
|
const ref = useRef<HTMLDivElement>(null);
|
|
85
85
|
return (
|
|
86
86
|
<div className={classNames(variableNameInputCls, props.classname)} ref={ref}>
|
|
@@ -47,7 +47,7 @@ export class LibroPromptCellCommandContribution
|
|
|
47
47
|
libro.invertCell(cell, 'prompt');
|
|
48
48
|
},
|
|
49
49
|
isEnabled: (cell, libro) => {
|
|
50
|
-
if (!libro || !(libro instanceof LibroView) || libro.model.
|
|
50
|
+
if (!libro || !(libro instanceof LibroView) || !libro.model.cellsEditable) {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
53
|
return true;
|
|
@@ -2,8 +2,8 @@ import { singleton } from '@difizen/mana-app';
|
|
|
2
2
|
|
|
3
3
|
@singleton()
|
|
4
4
|
export class PromptScript {
|
|
5
|
-
public readonly getChatObjects = `from
|
|
5
|
+
public readonly getChatObjects: string = `from libro_ai import chat_object_manager
|
|
6
6
|
chat_object_manager.dump_list_json()`;
|
|
7
|
-
public readonly getChatRecoreds = `from
|
|
7
|
+
public readonly getChatRecoreds: string = `from libro_ai import chat_record_provider
|
|
8
8
|
chat_record_provider.get_records()`;
|
|
9
9
|
}
|
package/src/prompt-cell-view.tsx
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
LibroExecutableCellView,
|
|
18
18
|
LibroViewTracker,
|
|
19
19
|
EditorStatus,
|
|
20
|
-
|
|
20
|
+
LibroContextKey,
|
|
21
21
|
} from '@difizen/libro-core';
|
|
22
22
|
import type { ExecutionMeta, KernelMessage } from '@difizen/libro-jupyter';
|
|
23
23
|
import { KernelError, LibroJupyterModel } from '@difizen/libro-jupyter';
|
|
@@ -214,7 +214,7 @@ const PropmtEditorViewComponent = React.forwardRef<HTMLDivElement>(
|
|
|
214
214
|
@transient()
|
|
215
215
|
@view('prompt-editor-cell-view')
|
|
216
216
|
export class LibroPromptCellView extends LibroExecutableCellView {
|
|
217
|
-
@inject(
|
|
217
|
+
@inject(LibroContextKey) protected libroContextKey: LibroContextKey;
|
|
218
218
|
override view = PropmtEditorViewComponent;
|
|
219
219
|
|
|
220
220
|
declare model: LibroPromptCellModel;
|
|
@@ -355,8 +355,8 @@ export class LibroPromptCellView extends LibroExecutableCellView {
|
|
|
355
355
|
editorHostId: this.parent.id + this.id,
|
|
356
356
|
model: this.model,
|
|
357
357
|
config: {
|
|
358
|
-
readOnly: this.parent.model.
|
|
359
|
-
editable:
|
|
358
|
+
readOnly: !this.parent.model.inputEditable,
|
|
359
|
+
editable: this.parent.model.inputEditable,
|
|
360
360
|
},
|
|
361
361
|
};
|
|
362
362
|
return option;
|
|
@@ -381,10 +381,10 @@ export class LibroPromptCellView extends LibroExecutableCellView {
|
|
|
381
381
|
}
|
|
382
382
|
|
|
383
383
|
protected async afterEditorReady() {
|
|
384
|
-
watch(this.parent.model, '
|
|
384
|
+
watch(this.parent.model, 'inputEditable', () => {
|
|
385
385
|
this.editorView?.editor?.setOption(
|
|
386
386
|
'readOnly',
|
|
387
|
-
getOrigin(this.parent.model.
|
|
387
|
+
getOrigin(!this.parent.model.inputEditable),
|
|
388
388
|
);
|
|
389
389
|
});
|
|
390
390
|
this.editorView?.onModalChange((val) => (this.hasModal = val));
|
|
@@ -410,8 +410,8 @@ export class LibroPromptCellView extends LibroExecutableCellView {
|
|
|
410
410
|
this.editorView.editorStatus === 'ready' &&
|
|
411
411
|
this.parent.model.active?.id === this.id &&
|
|
412
412
|
!this.parent.model.commandMode &&
|
|
413
|
-
this.
|
|
414
|
-
this.parent.model.
|
|
413
|
+
this.libroContextKey.commandModeEnabled === true && // 排除弹窗等情况
|
|
414
|
+
this.parent.model.inputEditable
|
|
415
415
|
) {
|
|
416
416
|
this.editorView?.editor.setOption('styleActiveLine', true);
|
|
417
417
|
this.editorView?.editor.setOption('highlightActiveLineGutter', true);
|