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:
parent
361c89ba9b
commit
96b5f45fad
@ -155,6 +155,10 @@ export class FieldBlock {
|
||||
attributes.required = '';
|
||||
}
|
||||
|
||||
if (this.blockDef.meta.maxLength) {
|
||||
attributes.maxLength = this.blockDef.meta.maxLength;
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user