Repository navigation
Replies: 4 comments
|
Thanks for writing these up, and for asking before building. That makes this much easier. Going through them in order: Clicking outside the modal. I agree losing changes this way is frustrating, but I don't want an outside click to save. Everywhere else in Filament it means cancel, and in insert mode it would add a brick the author may have meant to discard. A warning dialog is a lot of machinery for the problem. I'd rather make Duplicate a brick. Yes, this is the one I'd most like to have. I'd put it as a button in the brick controls and an action in the outline. I'd skip Shift + click on Add: it's hard to discover, and it gives Add two meanings. One thing it needs: some config values shouldn't be copied as they are, like anchors or ids, slugs, or upload paths. So I'd like a small hook on Brick (something like Presets. I can see the use, but it's close to the templates side of #73, and inserting several bricks at once with configs that skip their forms brings its own problems. Not for now. If it comes back, I'd rather add a general "insert these bricks at this position" hook a package could build on than presets in core. Copy/paste, selecting several bricks, the Delete key. I'm going to pass on these for now. Selection is built around a single brick in both the editor and the preview, and selecting several would touch most of it. That's the part of Mason I'm most careful with. Pasting also means trusting content from another field, record or app, which would need checking on the server against the field's bricks. While looking at the keyboard side I also found and fixed a bug (#83): the undo/redo listener acted on every Mason field on the page, so one Cmd+Z undid both. Shortcuts now act only in the field that has focus, and any new ones should work the same way. Brick parts. This fits the direction much better than containers did, thanks for thinking it through. My concern is the partial form. Saving only one part's fields breaks as soon as a field is required elsewhere in the form, or a field depends on another part through visible() or Get. Making parts clickable in the preview also means reworking how the preview handles the pointer, and we've only just got that stable. And since toHtml() renders the site too, the part attributes would end up on the frontend. What I'd be open to is a lighter version: clicking a part opens the full brick form, scrolled to that part's Section or with its Tab already open. Authors still land on the piece they clicked, there's one form to validate, and nothing needs merging. If you want to sketch an API for that, I'm happy to look. So in short: duplicate and the outside-click default are yes, parts as scroll-to-section is maybe, and the rest is not for now. Thanks again! |
|
What I forgot: 1 | Show layout toggle Note PR submitted in #88 . My preview layout wraps the bricks in the site's header and footer, but authors usually want to see the bricks alone. I built a toggle for this in my app and think it would fit in core. "Layout" because the marked parts are exactly what the field's Mason::make('content')
->previewLayout('layouts.mason-preview')
->layoutToggle()
->layoutToggleLabel('Show header and footer') // optional, defaults to "Show layout"The parts are marked in the preview layout: <div data-mason-layout>@include('partials.header')</div>
<main>@include('mason::iframe-preview-content', ['blocks' => $blocks])</main>
<div data-mason-layout>@include('partials.footer')</div>Implementation, following the colour mode toggle:
The toggle is off by default, and the docs note that it only makes sense with a custom 2 | limit how often a brick can be used Note PR submitted in #89 . While building duplicate I wondered about bricks that should only appear once, such as a hero or a page meta brick. An opt-out for duplicate alone would not help, since the brick could still be added from the sidebar, the picker or the add line. So I'd rather suggest a general limit, similar to Gutenberg's public static function getMaxInstances(): ?int
{
return 1; // null (default) = no limit
}Once the limit is reached:
Values that only need to be unique (anchors, IDs) are already covered by Would this be something you'd consider? If so, I'd sketch it after the duplicate PR. |
|
For further feature ideas see the comment above. Regarding "parts as scroll-to-section": Sketch: brick parts that open the form at the right place Note PR submitted in #91 . Following your suggestion, here is a sketch for the lighter version: a part only tells the editor where to open the full form. In the brick view, a helper marks an element as a part. It outputs <header {{ mason_part('heading') }}>
<h2>{{ $heading }}</h2>
</header>The part name is the key of a component in the brick's form: a field name, or the Tabs::make()->tabs([
Tab::make('Heading')->key('heading')->schema([...]),
Tab::make('Media')->schema([
FileUpload::make('image'), // part "image" works too
]),
])In the preview, a click on a part of the selected brick opens its form with a In the form, Mason finds the component with that key. Once the modal is open, it dispatches Filament's own Because the whole form is submitted, required fields and One open point: the helper needs to know that it is rendering inside the editor preview. Today a brick can only guess from Does this direction work for you? Happy to adjust names before I start. |
|
Thanks for all of these. I've gone through each one, and I'm not merging any of them as they are yet. Notes are on each PR. A few things apply to most of them:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
a) Save on an outside click
b) Show a warning on an outside click, with a button to save
This could also be an opt-in feature, for all Mason fields or individual ones.
a) via the outline?
b) via an additional button in
.mason-block-controls?c) via Shift + click on the Add button? ACF/SCF handles it this way in repeater fields.
overflow-x), that shows presets: groups of bricks that are inserted at once.mason-actions-brick) in the sidebar to drag and drop the brick(s) from the clipboardmason-brick-picker-brick) in the "Add brick" popupWhat do you think?
Copy-paste of my comment from feat: container bricks that hold other bricks - #73:
One alternative came up while thinking about your answer, and I think it fits your direction: brick parts.
Instead of bricks inside bricks, a developer marks fixed areas in a brick's own view as parts, and groups the brick's fields by part:
In the preview, clicking a part opens an edit modal with only that part's fields, rather than the whole brick form. A part can optionally be hidden, but never removed or moved. The form for configuring the brick itself remains clean.
The stored content stays flat: everything is still in the brick's own config.
The layout stays with the developer. Authors can only edit (or hide) what the brick offers.
It helps with the one downside of the Repeater/Builder approach: bricks with a lot of structure end up with long forms, and parts let authors edit the piece they clicked on.
A typical case for us: an accordion(-section) whose heading has its own fields (Tagline, heading, subline, (to conditionally render a hgroup instead of a simple heading), level, visually hidden). Today that goes into one long form with the accordion items.
Would something like this be interesting for Mason? If so, I'm happy to sketch out the API first before writing any code.
It might look something like this (although it would probably be nicer to display the name of the element—in this example, “heading”)

All reactions