-
Notifications
You must be signed in to change notification settings - Fork 577
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
Remove text
and image
default blocks
#2410
base: 3.x
Are you sure you want to change the base?
Conversation
Thanks for the amazing report in this PR @driftingly. I'm totally with you on this. This is definitely a mix of lacking documentation on these default blocks and legacy code for how all blocks used to be defined in earlier versions of Twill. Creating new blocks back then required generating Vue SFCs from the blocks' Blade form files followed by a build. Compiled blocks are still valuable for custom needs, but as you probably figured, none of that complexity is necessary anymore. These default blocks aren't even meant to be used, since Twill is really about giving developers control of creating their own blocks, instead of being opinionated about it. Based on that, I was initially in favor of merging your PR. But thinking about it more, something doesn't feel right if we do, because instead of an error due to a missing frontend rendering file (which is definitely where Twill doesn't want to be opinionated at all), we'd get a weirdly empty block editor field when adding the field to a form before creating any blocks. So I'm split between accepting this or refactoring and documenting it properly instead. What was your expectation going in? Did you appreciate that there were 2 generic blocks provided by default until you had trouble using them? Or did you/do you feel like they shouldn't be there in the first place? I like your idea of generating the preview files. They could be super basic html but are likely to be helpful for new comers. It just feels a bit invasive to publish those files from the get go, especially in the current default Let me know what you think. For now I'm still inclined to merge this and revisit in the future if we feel like having some default blocks is preferred. |
@ifox, I agree with your hesitation. Seems like without publishing some starting point to the front end, neither option is ideal. The documentation I've seen on the Twill site around blocks usually starts by removing the default ones, so I'm not sure there is value in keeping them. If we wanted to move forward with this PR I tried to improve the messaging around the initial empty block state. Let me know how I could improve this, or if you could point me to somewhere in the app where something like this is already done. Possibly link out to the documentation? |
Maybe we should also update the content of the Currently @twillBlockCompiled('true')
@twillBlockComponent('a17-block-wysiwyg')
@twillBlockTitle('Body text')
@twillBlockIcon('text')
@twillBlockGroup('twill')
<x-twill::input
name="title"
label="Title"
:translated="true"
/>
<x-twill::wysiwyg
name="text"
label="Text"
placeholder="Text"
:toolbar-options="[
'bold',
'italic',
['list' => 'bullet'],
['list' => 'ordered'],
[ 'script' => 'super' ],
[ 'script' => 'sub' ],
'link',
'clean'
]"
:translated="true"
/> But it should be more like @twillBlockCompiled('true')
@twillBlockComponent('a17-block-wysiwyg')
@twillBlockTitle('Body text')
@twillBlockIcon('text')
@twillBlockGroup('twill')
<x-twill::wysiwyg
name="html"
label="Text"
placeholder="Text"
:toolbar-options="[
'bold',
'italic',
['list' => 'bullet'],
['list' => 'ordered'],
[ 'script' => 'super' ],
[ 'script' => 'sub' ],
'link',
'clean'
]"
:translated="false"
/> Or remove the content all together to not mislead in believing the content is coming from them |
@Tofandel it is normal considering the code, but not really desired indeed as it bloats the page even though they are not needed (not only default twill blocks, but all blocks that haven't been allowed on a specific form). |
As someone new to Twill, I was tripped up by the default blocks.
This could be simply user error or education is needed.
The other option would be to update the
twill:install
command to create the preview/site files for the default blocks.Steps to reproduce:
laravel new twill-test
composer require area17/twill:"^3.0"
php artisan twill:install
npm install && npm run dev
php artisan twill:make:module -B pages
AppServiceProvider
to add a navigation linkphp artisan migrate
PageController.php
to add a block editor to thegetForm
methodBody text
component onto the editor[site.blocks.text]
not found. in[...]/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php
We must create
text.blade.php
inresources/views/site/blocks
to fix the error.It took a lot of work to figure out what to put in the blade file to access the content.
I searched Twill for
Body text
and got a hit onsrc/Commands/stubs/blocks/text.blade.php
. The file includes two translatable blade components for thetitle
andtext
, which were red herrings. I finally figured out the stub uses the@twillBlockCompiled('true')
directive, resulting in the Vue componentfrontend/js/components/blocks/BlockWysiwyg.vue
being used instead. The Vue component defines a single WYSIWYG editor with a name ofhtml
.Contents of
text.blade.php
Or