Skip to content

Conversation

@threefjefff
Copy link
Collaborator

@threefjefff threefjefff commented Apr 25, 2025

Describe your changes

In the Stacks Snippets plugin, we were relying on callers to append their changes to the document. This PR creates a callback parameter on the openSnippetModal function definition such that a function that will update the document can be called instead.

This allows us to amend existing snippets by their ID (which is available on the snippetMetadata passed to openSnippetsModal) by replacing thier contents. If it is not present, we append to the document.

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: 135.0.7049.114

Additional context

I ran into an issue here where the plugin is trying to interact with the markdown-it parser while during a Prosemirror flow. We bundle these together at a top level (e.g. RichTextEditor) which encapsulates Prosemirror's EditorView and a MarkdownSerializer (which is ultimately served by markdown-it).
Long story short, we need a way of being able to access that encapsulation from inside the EditorView, and as such I've registered the BaseViewState (and it's Key) so that we can grab a handle on the editor, and use a familiar pathway for serialization tasks and the like.

@changeset-bot
Copy link

changeset-bot bot commented Apr 25, 2025

🦋 Changeset detected

Latest commit: 5f4c5e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stackoverflow/stacks-editor Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@threefjefff threefjefff added the enhancement New feature or request label Apr 25, 2025
@netlify
Copy link

netlify bot commented Apr 25, 2025

Deploy Preview for stacks-editor ready!

Name Link
🔨 Latest commit 5f4c5e3
🔍 Latest deploy log https://app.netlify.com/sites/stacks-editor/deploys/680bb0e5309f0d0008b3945c
😎 Deploy Preview https://deploy-preview-431--stacks-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@threefjefff threefjefff merged commit 353995e into main Apr 28, 2025
5 checks passed
@threefjefff threefjefff deleted the jsmb/amend-existing-snippet branch April 28, 2025 13:31
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