Skip to content
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

Snippet editor tab #3870

Open
wants to merge 32 commits into
base: master
Choose a base branch
from

Conversation

dbolack-ab
Copy link
Collaborator

@dbolack-ab dbolack-ab commented Nov 3, 2024

This adds brew-based user snippets.

This follows the document pattern using snippet Snippet Name instead of page to indicate the start of a snippet.

A new Brew Snippets menu is added at the end of the existing menu list with Snippets organized under their owning document names (themeBundles return their snippets as well)

To Do:

  • Highlighting
  • Disable the brew snippets button (not hide) in the snippetbar if there are no snippets to hide. ( Partially implemented. Needs a style )
  • Move the properties tab to the end

To test:

  • Add a Snippet to a theme brew
    • Ensure the snippet shows up on a brew using the theme.
    • Ensure the snippet inserts
  • Add a snippet to the brew using the theme above
    • Ensure that both menu items appear
    • Ensure the snippet insterts

Example Snippet

\snippet Example Snippet
Hello!
I'll be your snippet for the day!

SnippetMenuExample

@Gazook89
Copy link
Collaborator

Gazook89 commented Nov 3, 2024

What marks the end of a snippet

Edit: oh, I see there is a whole new editor tab in addition to Brew, Styles, Properties. So nothing needs to indicate the end of a snippet because presumably each snippet would start with \snippet and continue until the next \snippet. I was thinking this was something built in to the existing Brew editor.

@ericscheid
Copy link
Collaborator

ericscheid commented Nov 4, 2024

How is this different from using variables to insert blocks of text?

(aside from the editor UI — which could be done for variables too/instead)

@dbolack-ab
Copy link
Collaborator Author

How is this different from using variables to insert blocks of text?

(aside from the editor UI — which could be done for variables too/instead)

Abstractly? Only that a menu exists. Practically? It is a better organizational scheme with semi-self-documentation via the menu.

When I suggested creating user snippets via variables it got an unfavorable reaction.

@calculuschild
Copy link
Member

calculuschild commented Nov 4, 2024

How is this different from using variables to insert blocks of text?

A variable could insert a block of text, but that block would not be editable.

Example: say my theme introduces a new custom statblock for NPCs. It has a name, a table of stats, and some custom {{ability xyz}} blocks.

Making that into a snippet means a user of this theme can insert a nice example of this statblock, then manually edit the NPC's name, stats, etc. to match their use.

If the only option is to put a variable $[customStatBlock], there isn't a straightforward way to now change the internal statblock text.

This reveals the key difference: a variable enables easy duplication of a fixed text. A snippet enables easy insertion of a template text, intended to be filled out and edited.

@dbolack-ab dbolack-ab added feature 🔍 R0 - Needs first review 👀 PR ready but has not been reviewed labels Nov 12, 2024
@5e-Cleric
Copy link
Member

Can we get a deployment for this? @calculuschild

@5e-Cleric 5e-Cleric changed the title Local snippet editor Snippet editor tab Nov 12, 2024
@5e-Cleric 5e-Cleric added the Epic label Nov 12, 2024
@5e-Cleric
Copy link
Member

I'm sure you are aware, but the deployment is not working atm

@dbolack-ab
Copy link
Collaborator Author

I'm sure you are aware, but the deployment is not working atm

Checking what I can

@G-Ambatte G-Ambatte temporarily deployed to homebrewery-pr-3870 November 14, 2024 03:41 Inactive
@5e-Cleric
Copy link
Member

It doesn't look like the emoji syntax works. I think that will work once you have highlighting in (or at least, I think it's handled in the same markdown.js file for the regular editor).

unrelated error, fixed in #3911.

@dbolack-ab
Copy link
Collaborator Author

It doesn't look like the emoji syntax works. I think that will work once you have highlighting in (or at least, I think it's handled in the same markdown.js file for the regular editor).

unrelated error, fixed in #3911.

Thanks! I was wondering about that!

@dbolack-ab
Copy link
Collaborator Author

A few requests:

  • disable the brew snippets button (not hide) in the snippetbar if there are no snippets to show.
  • move the properties tab to the end again, i think that should be last

There's currently no styling for adding disabled to the class. What should it look like?

@5e-Cleric
Copy link
Member

A few requests:

  • disable the brew snippets button (not hide) in the snippetbar if there are no snippets to show.
  • move the properties tab to the end again, i think that should be last

There's currently no styling for adding disabled to the class. What should it look like?

I see two good options:

image

With color:grey and cursor:not-allowed

OR:

image

@dbolack-ab
Copy link
Collaborator Author

A few requests:

  • disable the brew snippets button (not hide) in the snippetbar if there are no snippets to show.
  • move the properties tab to the end again, i think that should be last

There's currently no styling for adding disabled to the class. What should it look like?

I see two good options:

image

With color:grey and cursor:not-allowed

OR:

image

I lean towards the first one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic feature 🔍 R3 - Reviewed - Awaiting Fixes 🔧 PR is okayed but needs fixes before merging
Projects
Status: Under Review
Development

Successfully merging this pull request may close these issues.

7 participants