Skip to content

Conversation

@WhyPenguins
Copy link
Contributor

@WhyPenguins WhyPenguins commented Oct 12, 2025

Preview Deployment 😃

Quick links:

Overview

This is a PR for embedding SplashKit Online in the Field Guide as in-page activities. It adds a new component, CodeActivity, that can be used similar to normal code blocks, but instead creates an accordion that loads a SplashKit Online iFrame when opened.

  • "Block Edit" mode can be used to restrict the user to only editing specific regions, by marking them as one would when highlighting (e.g {10-20}). These can also be given names ({"inputBlock":5-27}), though this is unused currently.
  • Extra resources/code files can be attached via a zip file (for instance for utilities.h/cpp)
  • The full IDE can be launched as an internal Field Guide page from any activity

I believe the code quality can likely be improved - some parts of this are likely more hacky than needed due to my inexperience with Astro. Interested to know any changes needed to get this merged in, thanks!

image

Questionable points:

  • Currently the component creates a hidden div with the markdown output of the code, and extracts the code and block information by scanning through the elements. This feels hacky - maybe someone with more Starlight experience might have some ideas for improvements?
  • The method of getting data to the inline script is very weird (uses data attributes...)
  • The accordion is currently a required part of the component (since it's used to delay loading until interacted with). Lots of other options there though.
  • CodeActivity might not be the best name for the component?

Linked to https://github.com/WhyPenguins/SplashkitOnline/tree/field-guide-embedding-work branch.

Done-ish/To Do (for this repo + SplashKit Online repo):

  • Embedded view
  • Fixed C++ terminal handling
  • Inline terminal input
  • Block editing mode (rest of code locked)
  • CodeActivity component
  • Loading resources/utilities
  • Improve load times (now basically instant after first load)
  • Avoid full reloads somehow
  • Investigate Firefox input not working Works in newer versions, not worth investigating...
  • Make startup look smoother (no flashing between normal and embedded layout)
  • Ensure code/resources load (definitely a race condition...fun)
  • Handle projects properly (and allow re-opening the full IDE in another tab)
  • Allow re-opening the full IDE in another tab
  • Clean-up the code properly (kinda done...)
  • Match Field Guide's themes

Example Usage and Output

image
<CodeActivity 
    header="Try it out!"
    title="Sequence and Data/Simple Calculator/Read name"
    resources="/resources/code-activities/utilities.zip"
>
    ```c++ {"userCode":7-8}
    #include "splashkit.h"
    // access to read_integer, read_string, etc...
    #include "utilities.h"
    
    using std::to_string;
    
    // code the start of perform guess here
    
    
    int main()
    {
      while ( ! perform_guess(1, 37) )
      {
        write_line("Try again...");
      }
    
      return 0;
    }
    ```
</CodeActivity>

 - embeds an SKO iFrame and sends the code between the <></> in
 - added to a couple of pages as test/demo
 - not sure about the name
 - extracts editable blocks from the markdown
 - easy to use, but perhaps brittle to changes in the generated page?
 - 4s fade to mask load time - looks okay locally but may need adjusting
 - code has to be in 'code' directory in zip
@WhyPenguins WhyPenguins marked this pull request as draft October 12, 2025 18:12
@WhyPenguins WhyPenguins marked this pull request as ready for review October 20, 2025 14:53
@WhyPenguins WhyPenguins changed the title [DRAFT] Embedded SplashKit Online Embedded SplashKit Online Oct 20, 2025
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.

1 participant