0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 01:22:07 +01:00

display-character-count-to-RichTextBlock

This commit is contained in:
elhussein almasri 2023-12-22 22:17:15 +00:00 committed by Matt Westcott
parent 361c89ba9b
commit 96b5f45fad
3 changed files with 13 additions and 0 deletions

View File

@ -155,6 +155,10 @@ export class FieldBlock {
attributes.required = '';
}
if (this.blockDef.meta.maxLength) {
attributes.maxLength = this.blockDef.meta.maxLength;
}
return attributes;
}

View File

@ -378,6 +378,11 @@ class DraftailRichTextArea {
input.id = id;
input.name = name;
if (typeof options?.attributes === 'object') {
Object.entries(options.attributes).forEach(([key, value]) => {
input.setAttribute(key, value);
});
}
// If the initialState is an EditorState, rather than serialized rawContentState, it's
// easier for us to initialize the widget blank and then setState to the correct state
const initialiseBlank = !!initialState.getCurrentContent;

View File

@ -120,6 +120,9 @@ class FieldBlockAdapter(Adapter):
if block.field.help_text:
meta["helpText"] = block.field.help_text
if hasattr(block, "max_length") and block.max_length is not None:
meta["maxLength"] = block.max_length
return [
block.name,
block.field.widget,
@ -678,6 +681,7 @@ class RichTextBlock(FieldBlock):
"help_text": help_text,
"validators": validators,
}
self.max_length = max_length
self.editor = editor
self.features = features
self.search_index = search_index