Skip to content

Commit

Permalink
feat: add executionOnly state
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinesmilelk committed May 22, 2024
1 parent c3a2217 commit bb35d44
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 105 deletions.
33 changes: 33 additions & 0 deletions .changeset/thick-candles-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
"@difizen/libro-markdown-cell": patch
"@difizen/libro-prompt-cell": patch
"@difizen/libro-code-cell": patch
"@difizen/libro-raw-cell": patch
"@difizen/libro-jupyter": patch
"@difizen/libro-search": patch
"@difizen/libro-core": patch
"@difizen/libro-docs": patch
"@difizen/libro-code-editor": patch
"@difizen/libro-codemirror": patch
"@difizen/libro-cofine-editor": patch
"@difizen/libro-cofine-editor-contribution": patch
"@difizen/libro-cofine-editor-core": patch
"@difizen/libro-cofine-textmate": patch
"@difizen/libro-common": patch
"@difizen/libro-kernel": patch
"@difizen/libro-l10n": patch
"@difizen/libro-lab": patch
"@difizen/libro-language-client": patch
"@difizen/libro-lsp": patch
"@difizen/libro-markdown": patch
"@difizen/libro-output": patch
"@difizen/libro-rendermime": patch
"@difizen/libro-search-code-cell": patch
"@difizen/libro-shared-model": patch
"@difizen/libro-terminal": patch
"@difizen/libro-toc": patch
"@difizen/libro-virtualized": patch
"@difizen/libro-widget": patch
---

feat: add executionOnly state
10 changes: 5 additions & 5 deletions packages/libro-code-cell/src/code-cell-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ export class LibroCodeCellView extends LibroExecutableCellView {
editorHostId: this.parent.id + this.id,
model: this.model,
config: {
readOnly: this.parent.model.readOnly,
editable: !this.parent.model.readOnly,
readOnly: !this.parent.model.inputEditable,
editable: this.parent.model.inputEditable,
placeholder: '请输入代码',
},
};
Expand Down Expand Up @@ -268,10 +268,10 @@ export class LibroCodeCellView extends LibroExecutableCellView {
protected async afterEditorReady() {
this.focusEditor();
this.toDisposeOnEditor.push(
watch(this.parent.model, 'readOnly', () => {
watch(this.parent.model, 'inputEditable', () => {
this.editorView?.editor?.setOption(
'readOnly',
getOrigin(this.parent.model.readOnly),
getOrigin(!this.parent.model.inputEditable),
);
}),
);
Expand All @@ -293,7 +293,7 @@ export class LibroCodeCellView extends LibroExecutableCellView {
this.parent.model.active?.id === this.id &&
!this.parent.model.commandMode &&
this.libroContextKey.commandModeEnabled === true && // 排除弹窗等情况
this.parent.model.readOnly === false
this.parent.model.inputEditable
) {
this.editorView?.editor.setOption('styleActiveLine', true);
this.editorView?.editor.setOption('highlightActiveLineGutter', true);
Expand Down
2 changes: 1 addition & 1 deletion packages/libro-core/src/add-cell/libro-add-cell-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const LibroAddCell: React.FC = () => {
export const LibroWrappedAddCell = forwardRef(function LibroWrappedAddCell() {
const instance = useInject<LibroAddCellView>(ViewInstance);
return (
<DisplayWrapComponent mode={instance.parent?.model.readOnly}>
<DisplayWrapComponent mode={!instance.parent?.model.cellsEditable}>
<LibroAddCell />
</DisplayWrapComponent>
);
Expand Down
Loading

0 comments on commit bb35d44

Please sign in to comment.