Skip to content

Commit

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

feat: add inputEditable、cellsEditable、executable、savable and so on
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 e2e8ad7

Please sign in to comment.