Skip to content

Commit

Permalink
ref cannot be undefined here, and cm was just set. (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
kno10 committed Mar 15, 2024
1 parent a080c19 commit e86cedd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/thebe/src/codemirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,17 @@ export function setupCodemirror(
// TODO enable loading of mode js files via configuration
// see https://github.com/jupyterlab/jupyterlab/blob/3.6.x/packages/codemirror/src/mode.ts for
// an example of how to do this
ref.cm?.setOption('mode', codeMirrorConfig.mode);
ref.cm.setOption('mode', codeMirrorConfig.mode);

// All cells in the notebook automatically update their sources on change
ref?.cm?.on('change', () => {
const code = ref?.cm?.getValue();
ref.cm.on('change', () => {
const code = ref.cm.getValue();
cell.source = code;
ref?.cm?.refresh();
ref.cm.refresh();
});

if (codeMirrorConfig.readOnly) {
ref.cm?.display.lineDiv.setAttribute('data-readonly', 'true');
ref.cm.display.lineDiv.setAttribute('data-readonly', 'true');
editorEl.setAttribute('data-readonly', 'true');
cellEl.setAttribute('data-readonly', 'true');
}
Expand Down

0 comments on commit e86cedd

Please sign in to comment.