Skip to content

Update thebe plugin#107

Open
kno10 wants to merge 1 commit into
decker-edu:developfrom
kno10:thebe
Open

Update thebe plugin#107
kno10 wants to merge 1 commit into
decker-edu:developfrom
kno10:thebe

Conversation

@kno10
Copy link
Copy Markdown
Contributor

@kno10 kno10 commented Feb 15, 2024

Binder, local jupyter, or jupyter-lite.

Closes #76

@monofon
Copy link
Copy Markdown
Contributor

monofon commented Feb 28, 2024

Thanks for updating this. Before I merge this, can you please add a test deck under test/decks? Makes it easier to quickly check if everything is working.

I will also be using Thebe again for a programming course starting in October. For that I need multiple code cells per deck using different kernels each. Plus, I cannot tolerate the scaling issue :-).

So I started experimenting with Thebe instances in iframes. You can have a look at the usage pattern on branch thebe-code-block in test/decks/thebe-iframe-deck.md.

The Thebe iframe document can be found here resource/decker/support/thebe/thebe.html.

Notable properties of this approach currently include:

  • scaling Codemirror widgets is not an issue at all
  • each Thebe cell uses it's own Jupyter kernel, so
    • different code languages can be mixed in one deck
    • each cell requires it's own Jupyter server instance

Maybe this is interesting for you.

@kno10
Copy link
Copy Markdown
Contributor Author

kno10 commented Feb 28, 2024

Not sure if it is possible/easy to add this to the test decks:

  • the plugin needs to be enabled
  • it requires settings in decker.yaml to configure thebe

I don't know where to make these changes; I would rather put a test deck into the plugin folder.

@kno10
Copy link
Copy Markdown
Contributor Author

kno10 commented Feb 28, 2024

CodeMirror 6 seems to have support for scale, and for CodeMirror 5 it appears something along this line will help:

deck.on('resize', (event) => {
let scale="scale("+(1/event.scale)+")";
document.getElementsByClassName('CodeMirror').forEach((x)=>{
  x.CodeMirror.display.cursorDiv.style.transform=scale;
  x.CodeMirror.display.cursorDiv.style.transformOrigin="0 0 0";
  x.CodeMirror.display.selectionDiv.style.transform=scale;
  x.CodeMirror.display.selectionDiv.style.transformOrigin="0 0 0";
})});

Needs a bit more testing, and multi-line selection still seems to be glitchy (as if assuming a wrong line height), but this may have become much more usable for simple code modifications in class.

@kno10
Copy link
Copy Markdown
Contributor Author

kno10 commented Feb 29, 2024

@monofon please try the new push

@kno10 kno10 force-pushed the thebe branch 2 times, most recently from c829b16 to b3f58e4 Compare March 1, 2024 13:28
@monofon monofon self-requested a review July 5, 2024 14:02
@monofon monofon self-assigned this Jul 5, 2024
@monofon monofon added this to the Decker Release Version 0.14.0 milestone Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants