Skip to content

Conversation

@threefjefff
Copy link
Collaborator

@threefjefff threefjefff commented Mar 19, 2025

Add Stacks Snippet support to the editor as an external plugin.

  • Button to open an external modal, passing existing Stack Snippet if selected
  • Added to Prosemirror and Markdown IT schemas, so that snippets are correctly parsed and serialized between the two types of Node/Token streams.
  • Added a paste handler to convert pasted snippet code directly into the rich text view
  • Added the ability to append new content (expect to be used by the external modal)
  • Added a snippet view, which is used to render the blocks of snippet content, and a "Run Code" button to render the content to IFrame
  • DEVX: added a route for snippet contents such that the render button uses the webpack proxy to POST to the Stacks Snippets service when using the test harness.

PR Checklist

  • All new/changed functionality includes unit and (optionally) e2e tests as appropriate
  • All new/changed functions have /** ... */ docs
  • I've added the bug/enhancement and other labels as appropriate

Environment(s) tested

  • Device: desktop
  • OS: Windows
  • Browser Chrome
  • Version 134.0.6998.37

Additional context

This is the baseline for Stack Snippets:

  • The buttons will not appear unless a renderer option is supplied (which it is not, currently)
  • The button use a placeholder icon, this is going through internal design at the moment
  • Continuing to do internal UX review and squashing any bugs found. Intention is to triage and roll forwards with bugs that aren't showstoppers.

@threefjefff threefjefff added the enhancement New feature or request label Mar 19, 2025
@threefjefff
Copy link
Collaborator Author

After discussion, we're going to amend the external plugin architecture to make this work as an external plugin. This also means moving the /plugins folder to the top level, and we can think about distrubtion strategies at a later date.

@threefjefff threefjefff requested a review from alexwarren March 25, 2025 14:22
@threefjefff threefjefff force-pushed the jsmb/stack-snippets branch from 150ce40 to 608b867 Compare March 27, 2025 12:25
Copy link
Contributor

@giamir giamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @threefjefff for implementing this integration. I think we are very close to be able to merge. The main ask I have is to make explicit the parts of the "core" editor which we rely on in the plugin. This should help us greatly if we will eventually extract the plugin and in general with evolving the core parts with confidence. Being able to see at a glance what is exposed. The comments scattered through the PR are all related to this point.

Apart from that I also have a couple of suggestions regarding the demo site:

  • I would recommend to create a brand new page dedicated to showcasing the stacks snippets plugin. It is big enough that deserves it. It will also make it easier to test/try by having some prebaked examples.
  • Given we will have a new page for the snippets plugin I would recommend to turn off the plugin from any other page. This emphasize that snippets are not part of the "core" editor and need to be injected as a plugin
  • Cosmetic: I would suggest to change the max width of the main element from wmx6 to wmx7 (see layout.html). This is because we have several menu items now and the horizontal scollbar creeps in, in some pages.

Let me know if my suggestions make sense. Happy to sync if necessary to discuss this further. Thanks for bringing snippets to the finish line. It is a big feat. ❤️

@threefjefff threefjefff requested a review from giamir March 28, 2025 11:14
Copy link
Contributor

@giamir giamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @threefjefff for addressing my comments. Let's merge it! 🙂

@threefjefff threefjefff merged commit 54df8c3 into StackExchange:main Mar 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants