question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snippet Widgets Interface

See original GitHub issue

Terminology:

Term Definition
gutter a CodeMirror concept – examples would be the line numbers gutter or code folding gutter
line widget a CodeMirror concept that is a widget either above or below a line of code in the CodeMirror instance
snippet HB’s integrated snippets, such as images, class tables, monsters, etc…
widget a small utility that performs a function

Description

While discussing things with the DOMT team, one of the biggest topics that came up was snippet options. The overall concept stemmed from there being a solid number of users who are very unfamiliar with HTML/CSS, and having a UI to edit snippets would be really beneficial to them.

The DOMT team was initially thinking something akin to GMB’s snippet modal, but this would allow for after-insertion editing as well as initial editing (the editor could be set up to open itself when a snippet is inserted).

Thoughts

Some ideas for what this could look like:

  • A gutter or line widget that when clicked will create a line widget that will allow for UI-based editing of the snippet
  • Examples snippet options that could be made editable
    • LInk URLs/text
    • Inserting/removing frame/decoration/wide/other classes for known div types (monster, classTable, artist, note, etc…)
    • Values for vertical and horizontal spacing
    • Image height, width, position, URL, and alt text
    • Watercolor image selector and color picker
  • In chatting with @calculuschild, we realized it could be implemented in such a way that different document themes (tba) have different widgets available to them, and users could create their own widgets. A configurable approach would be ideal here, despite that being a bit more complicated from a programming perspective.

Working proof of concept: https://github.com/jeddai/homebrewery/pull/1 Videos: monster/table frame, artist credit position

Important Notes

CodeMirror handles line widgets normally by passing in dom elements. We do not want to do this, as the redraw process behind the scenes results in a new instance of the DOM elements and focus will be lost. This can be handled by the ReactDOM render method by rendering initially to a parent element and subsequently back into the widget’s DOM node. This will allow for consistent editing of text/number inputs, sliders, or any other input types we want to include.

Any react components or fragments can be rendered into the element with the method described above, which should allow for external-to-HB components such as color pickers and more detailed components like image pickers.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
G-Ambattecommented, May 19, 2022

Random thought: if we scan the text for {{monster to replace with the output of a monster Snippet function, then this is essentially the same functionality as the proposed Brew Variable system. So Advanced Snippets could leverage the find/replace functionality of Brew Vars.

0reactions
ericscheidcommented, Jul 6, 2022

Mentioned in variables discussion: https://github.com/naturalcrit/homebrewery/discussions/1400#discussioncomment-3090819 … TL;DR: declaring locally scoped variables could simplify the scanning/parsing involved.

So, instead of scanning for “Armor Class” in a monster block (and failing because someone translated that to french), scan for a variable name (e.g. scan for[_.AC]:=) and updating the variable value (i.e. the text that comes after :=). Then the insertion of the new AC value gets handled by the variables functionality.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Snippet Widget - Algolia
A widget that displays attributes as snippets of your search results.
Read more >
Widget snippet - Mage2Gen
Mage2Gen is an easy to use open source module generator for Magento 2. With the extensive interface the user can easily generate base...
Read more >
Snippet | Mendix Documentation
Snippets define reusable interface parts. They can be used on both pages and layouts. By using snippets you can make changes in fewer...
Read more >
Snippet Wrapper Widget - Akumina Community
Displays a fully functional portion of other widgets · Supports DMS Folder Tree · Supports DMS Grid · Supports DMS Refiner · Supports...
Read more >
Embedding Jupyter Widgets in Other Contexts than the ...
Jupyter interactive widgets can be serialized and embedded into ... The classic notebook interface provides a Widgets menu for generating an HTML snippet...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found