-
Notifications
You must be signed in to change notification settings - Fork 23
Customizable collapsed text? #7
Comments
There’s indeed a way to specify the way the title of a block is displayed, but that’s limited to class ButtonBlock(StructBlock):
color = CharBlock()
label = CharBlock()
url = URLBlock()
def get_definition(self):
definition = super().get_definition()
definition['titleTemplate'] = 'Button “${label}”'
return definition Note that the “title template” uses the new JavaScript string format, with a dollar sign and braces. I’ll probably add the possibility later to specify a JavaScript function instead of a simple template like this. I’m not sure though on what would be the best API for it. Anyways, note that another layout of block called |
Great! Looks quite useful for our purposes! |
@fpoulain Yes, the idea of these titles was to give a hint on what’s inside, but I’m not sure we want to give too much control over the HTML that’s inside it. The first simple reason for that is that I use I chose to display the numbers as title because it can make sense in lots of context, though I agree it’s not universal. The main idea was to at least give something, even meaningless, that helps users differentiate blocks when they often go on the same page or when reordering blocks. Anyway, note that now the default layout is The ideal solution of this is obviously to do AJAX calls to a Python method, but I want to see what’s the feedback before introducing that. I already introduced AJAX calls when rebuilding the whole preview system, and now I introduced a few AJAX callls when the page loads to fetch images chosen with the |
I confirm. Upgrading my local version of wagtail-react-streamfield suited my needs. |
Is the .get_definition() part still supposed to work? I cannot get it working. All I need is to display a custom value as title for a few structblocks; but it only works if the block has a .title property. |
@roodie It was renamed from |
Yes, I found it after my comment, but worths a note, yes. |
Is there a special way to use a block of type RichTextBlock or ImageChooserBlock on the titleTemplate? Having:
Is showing something like: And having:
Is showing a number, it would be good to show the image name instead of a number |
@jkevingutierrez Unfortunately no, there is no easy & generic way to work around this. Which is why I disabled that help title on these block types. |
As I mentioned over on the wagtail queue, it'd be nice if the text that's displayed when a block is collapsed were customizable. It's supposedly possible, but how does it work?
The text was updated successfully, but these errors were encountered: