Skip to content

Sandcastle helper snippets #12679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 22, 2025
Merged

Sandcastle helper snippets #12679

merged 5 commits into from
Jul 22, 2025

Conversation

jjspace
Copy link
Contributor

@jjspace jjspace commented Jun 18, 2025

Description

I have long wanted to include some sort of "code helpers" for adding common chunks of code to sandcastle. Currently these exist as dedicated buttons in the new Sandcastle but I'm not sure they will stay that way in the final UI. These are mostly for more "power users" so I've taken a pass at implementing these as snippets directly in monaco. These can always be expanded later.

  • scbutton will generate the button code
  • sctoggle will generate the checkmark toggle button code
  • scmenu and scmenuitem will generate code for the dropdown menus.

All of these snippets have tab stops to make it quick an easy to input the labels, variables and your code.

Based on the monaco code completion example

Issue number and link

Part of #12566

Testing plan

  • Run new sandcastle (npm run dev in the package or npm run build-sandcastle && npm star at top level)
  • anywhere in the editor type any of the snippet labels above and hit tab/enter
  • Try out a mix and make sure they work as expected

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

@jjspace jjspace requested review from ggetz and javagl June 18, 2025 15:52
Copy link

Thank you for the pull request, @jjspace!

✅ We can confirm we have a CLA on file for you.

Copy link
Contributor

@javagl javagl left a comment

Choose a reason for hiding this comment

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

I had a look at this. I cannot say much about the "code level", except that specifying the return type could make sense: void for setSnippets and
function createDependencyProposals(range: Range) : languages.CompletionItem[]
Just for additional documentation/type safety.

I also tried it out with different configurations, and it seems that it works as expected.

And... yeah ... it's me again...
documentation: "Create a Sancastle button", should be
documentation: "Create a Sandcastle button", 😁
(in all documentation fields)

@jjspace
Copy link
Contributor Author

jjspace commented Jun 18, 2025

Thanks for taking a look @javagl! I added some types to help.

"Sancastle" should be "Sandcastle"

I have a few typing quirks I can't seem to shake, like often typing teh instead of the. This seems to be a new one that I have to keep an eye on 😆 I've updated my auto correct for it

Base automatically changed from sandcastle-react-structure to sandcastle-v2 June 27, 2025 19:45
@@ -112,6 +114,79 @@ function SandcastleEditor({
);
}

function createDependencyProposals(range: Range): languages.CompletionItem[] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move the snippets to their own file?

label: "scbutton",
kind: languages.CompletionItemKind.Function,
documentation: "Create a Sandcastle button",
insertText: `Sandcastle.addToolbarButton(\${1:"New Button"}, function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does the ${1:"New Button"} syntax come from? I've never seen it before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This syntax is for the various "tab stops" to make filling data easier. I can look for monaco specific documentation but I mostly referred to the VSCode snippets docs which I've used for snippets a bunch in the past https://code.visualstudio.com/docs/editing/userdefinedsnippets

@jjspace
Copy link
Contributor Author

jjspace commented Jul 16, 2025

@ggetz I moved the snippet setup to it's own file quickly while cleaning up some branches. This should be good to go now I think but no rush

@ggetz
Copy link
Contributor

ggetz commented Jul 22, 2025

Thanks @jjspace! We may wan to take a pass on which snippets to include and so forth as we do a final polish, but looking good overall.

@ggetz ggetz merged commit 1e05d97 into sandcastle-v2 Jul 22, 2025
3 of 5 checks passed
@ggetz ggetz deleted the sandcastle-snippets branch July 22, 2025 15:29
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.

3 participants