Skip to content

Commit

Permalink
Re-merge (#48)
Browse files Browse the repository at this point in the history
* Provide another option to dive deeper into sample use-cases

* Gallery isn't appropriate as we're not showing photos.

* Implement improve line-by-line run logic for the Cmd/Cntrl + Enter shortcut. (#44)

Close #43

* Add talks & tweets.
  • Loading branch information
coatless authored Sep 24, 2023
1 parent de3a05d commit 39379f1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
37 changes: 35 additions & 2 deletions _extensions/webr/webr-context-interactive.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
}
};

// Helper function to check if selected text is empty
function isEmptyCodeText(selectedCodeText) {
return (selectedCodeText === null || selectedCodeText === undefined || selectedCodeText === "");
}

// Registry of keyboard shortcuts that should be re-added to each editor window
// when focus changes.
const addWebRKeyboardShortCutCommands = () => {
Expand All @@ -59,10 +64,38 @@

// Add a keydown event listener for CMD/Ctrl+Enter to run selected code
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => {

// Get the selected text from the editor
const selectedText = editor.getModel().getValueInRange(editor.getSelection());
// Code to run when Ctrl+Enter is pressed (run selected code)
executeCode(selectedText);
// Check if no code is selected
if (isEmptyCodeText(selectedText)) {
// Obtain the current cursor position
let currentPosition = editor.getPosition();
// Retrieve the current line content
let currentLine = editor.getModel().getLineContent(currentPosition.lineNumber);

// Propose a new position to move the cursor to
let newPosition = new monaco.Position(currentPosition.lineNumber + 1, 1);

// Check if the new position is beyond the last line of the editor
if (newPosition.lineNumber > editor.getModel().getLineCount()) {
// Add a new line at the end of the editor
editor.executeEdits("addNewLine", [{
range: new monaco.Range(newPosition.lineNumber, 1, newPosition.lineNumber, 1),
text: "\n",
forceMoveMarkers: true,
}]);
}

// Run the entire line of code.
executeCode(currentLine);

// Move cursor to new position
editor.setPosition(newPosition);
} else {
// Code to run when Ctrl+Enter is pressed with selected code
executeCode(selectedText);
}
});
}

Expand Down
6 changes: 3 additions & 3 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project:
- CNAME

website:
title: "quarto-webr: A Quarto Extension for webR"
title: "quarto-webr"
reader-mode: true
repo-url: https://github.com/coatless/quarto-webr
repo-actions: [edit, issue]
Expand Down Expand Up @@ -35,8 +35,8 @@ website:
text: README Example
- href: webr-code-cell-demos.qmd
text: Exploring Interactive Code Cells
- href: webr-community-example-gallery.qmd
text: Community Example Gallery
- href: webr-community-examples.qmd
text: Community Examples
- section: "Deployment"
contents:
- href: webr-communication-channels.qmd
Expand Down
2 changes: 1 addition & 1 deletion docs/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ summary(model)

At its core, the [quarto-webr extension](https://github.com/coatless/quarto-webr) is designed to empower you to run R code directly in your web browser using familiar reporting tools, all without the need for an external R server. Moreover, the extension abstracts away the need to know HTML or JavaScript to use webR. However, it's worth noting that you can also choose to unlock the full potential of webR and create more complex applications independently by directly using [webR's JavaScript API](https://docs.r-wasm.org/webr/latest/evaluating.html), granting you unparalleled freedom to harness the power of R in innovative ways.

With this in mind, let's dive in and kickstart your journey with interactive code cells by creating our very first [webR-powered Quarto document](webr-first-steps.qmd)!
With this in mind, let's dive in and kickstart your journey with interactive code cells by [creating our very first webR-powered Quarto document](webr-first-steps.qmd) or [exploring interactive code cells](webr-code-cell-demos.qmd)!
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Community Example Gallery"
title: "Community Examples"
subtitle: "Explore Real-world Use Cases and Projects Using the `quarto-webr` Extension"
date: "09-22-2023"
date-modified: last-modified
Expand All @@ -12,9 +12,9 @@ filters:

Welcome to the Community Examples page for the `quarto-webr` extension. This section celebrates the diverse and innovative ways that members of our community are harnessing the power of the `quarto-webr` extension. These examples showcase real-world use cases, highlighting the extension's adaptability and functionality across various fields. You may also find references to examples from the [main webR project](https://webr.r-wasm.org/) here as well.

Explore the projects, applications, educational materials, and more created by fellow users. Gain inspiration from the community's contributions and discover how you can leverage the full potential of quarto-webr in your own work. Whether your interests lie in data analysis, interactive reports, or educational resources, you'll find valuable insights and ideas within the community's projects.
Explore the projects, applications, educational materials, and more created by fellow users. Gain inspiration from the community's contributions and discover how you can leverage the full potential of `quarto-webr` in your own work. Whether your interests lie in data analysis, interactive reports, or educational resources, you'll find valuable insights and ideas within the community's projects.

Do you have your own project or example that incorporates `quarto-webr`? We [invite you to contribute](https://github.com/coatless/quarto-webr/edit/main/docs/webr-community-example-gallery.qmd) to this growing collection of community-driven projects by submitting a [pull request](https://github.com/coatless/quarto-webr/edit/main/docs/webr-community-example-gallery.qmd) or [creating an issue](https://github.com/coatless/quarto-webr/issues/new?assignees=&labels=community-example&projects=&template=community-example.yml&title=%5BExample%5D%3A+). Your experiences and creativity can inspire others and promote collaboration within our community. Together, we can continue to expand the possibilities of `quarto-webr`.
Do you have your own project or example that incorporates `quarto-webr`? We invite you to contribute to this growing collection of community-driven projects by submitting a [pull request](https://github.com/coatless/quarto-webr/edit/main/docs/webr-community-examples.qmd) or [creating an issue](https://github.com/coatless/quarto-webr/issues/new?assignees=&labels=community-example&projects=&template=community-example.yml&title=%5BExample%5D%3A+). Your experiences and creativity can inspire others and promote collaboration within our community. Together, we can continue to expand the possibilities of `quarto-webr`.

# Videos

Expand All @@ -34,10 +34,13 @@ Do you have your own project or example that incorporates `quarto-webr`? We [inv
- [George Stagg](https://gws.phd)'s talk on the [Magic with WebAssembly and webR](https://gws.quarto.pub/magic-with-wasm-and-webr/#/title-slide) mentioning `quarto-webr` as an easy onboarding option. Sep 20, 2023 @ posit::conf(2023)
- [James Balamuta](http://thecoatlessprofessor.com/)'s talk on [Dynamic Interactions:Empowering Educators and Researchers with Interactive Quarto Documents Using webR](https://assets.thecoatlessprofessor.com/talks/quarto-webr-posit-conf-23-talk.pdf). Sep 19, 2023 @ posit::conf(2023)
- [George Stagg](https://gws.phd)'s talk on the [Introduction to webR](https://gws.quarto.pub/introduction-to-webr-2023/#/title-slide) mentioning `quarto-webr` as an easy onboarding option. Sep 18, 2023 @ posit::conf(2023)
- [bob Rudis](https://rud.is/)' talk on [🕸️ Into the WebR-Verse](https://github.com/hrbrmstr/2023-nyr-webr) incorporating a demo of the `quarto-webr` extension. Jul 13 @ New York R Conference 2023
- [Nicola Rennie](https://nrennie.rbind.io/)'s talk on [Teaching statistics interactively with webR](https://nrennie.rbind.io/talks/rss-conference-teaching-webr/). @ RSS International Conference 2023
- [Slides](https://teaching-with-webr.netlify.app/#/title-slide) and [Source code](https://github.com/nrennie/teaching-with-webR)
- [bob Rudis](https://rud.is/)' talk on [🕸️ Into the WebR-Verse](https://github.com/hrbrmstr/2023-nyr-webr) incorporating a demo of the `quarto-webr` extension. Jul 13th, 2023 @ New York R Conference 2023
- [Video](https://www.youtube.com/watch?v=inpwcTUmBDY&list=PLlzRFZmxVl9RYNkA-lRUxloDYrd1Bhln9&index=8) and [Source code](https://github.com/hrbrmstr/2023-nyr-webr)
- boB used a [cool trick to embed the demo](https://github.com/coatless/quarto-webr/issues/14#issuecomment-1634944155) in his revealjs slides.
- [Maria Tackett](https://maria-tackett.netlify.app/)'s talk on [Using Quarto for Making and Organizing Teaching Materials](https://mine-cetinkaya-rundel.github.io/teach-with-quarto/talks/5-teaching-materials/) during the [Teaching (with) Quarto](https://mine-cetinkaya-rundel.github.io/teach-with-quarto/) Session. Aug 7, 2023 @ JSM 2023
- [Slides](https://mine-cetinkaya-rundel.github.io/teach-with-quarto/talks/5-teaching-materials/) and [Source code](https://github.com/mine-cetinkaya-rundel/teach-with-quarto/tree/main/talks/5-teaching-materials)
- [WebR Demo](https://maria.quarto.pub/webr-demo/) on [Quarto Pub](https://quarto.pub)

# Textbooks
Expand All @@ -52,12 +55,14 @@ Do you have your own project or example that incorporates `quarto-webr`? We [inv

# Social media posts

- [Linh Nguyen](https://www.linkedin.com/in/nguyenllpsych)'s post on [LinkedIn](https://www.linkedin.com/posts/nguyenllpsych_positconf2023-activity-7111101659509899265-CTay?utm_source=share&utm_medium=member_desktop) describing how she used knowledge at posit::conf(2023) to convert existing R notes to use the `quarto-webr` extension. Sept 22, 2023
- [Linh Nguyen](https://nguyenllpsych.github.io/)'s post on [LinkedIn](https://www.linkedin.com/posts/nguyenllpsych_positconf2023-activity-7111101659509899265-CTay?utm_source=share&utm_medium=member_desktop) and [Twitter](https://twitter.com/nguyenllpsych/status/1705357201400066141) describing how she used knowledge at posit::conf(2023) to convert existing R notes to use the `quarto-webr` extension. Sept 22, 2023
- [Joe Chelladurai](https://joechelladurai.com/) mentioning a [similiar integration on mastodon](https://mastodon.social/@[email protected]/110699434655070719) for his newly developed [The School of Data](https://www.theschoolofdata.org/). Jul 11th, 2023
- [Nicola Rennie](https://nrennie.rbind.io/)'s tweet showing [live coding with webR](https://twitter.com/nrennie35/status/1654509541499850752). May 5th, 2023
- [bob Rudis](https://rud.is/)' kind [praise](https://mastodon.social/@hrbrmstr/110130242863636605) of the extension. Apr 2nd, 2023

# Blog posts

- [Javier Orraca-Deatcu](https://www.javierorracadeatcu.com/)'s post titled [webR via Quarto Extensions](https://www.javierorracadeatcu.com/posts/2023-08-23-webr-via-quarto-extensions/). Aug 23rd, 2023.
- [George Stagg](https://gws.phd/)'s mention of the extension in his [webR 0.2.0 announcement](https://www.tidyverse.org/blog/2023/08/webr-0-2-0/). Aug 8th, 2023.
- [Ethan White](https://www.weecology.org/author/ethan-white/)'s use to create a [portal for Tidy Tuesday](https://tidytuesday.weecology.org/). May 2nd, 2023
- [Matt Dray](https://www.matt-dray.com/)'s post on [Playgrounds with WebR and Quarto](https://www.rostrum.blog/posts/2023-03-16-webr-quarto/). Mar 16th, 2023
Expand Down

0 comments on commit 39379f1

Please sign in to comment.