display-character-count-to-RichTextBlock

pull/11414/head
elhussein almasri 2023-12-22 22:17:15 +00:00 zatwierdzone przez Matt Westcott
rodzic 361c89ba9b
commit 96b5f45fad
3 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

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

Wyświetl plik

@ -378,6 +378,11 @@ class DraftailRichTextArea {
input.id = id; input.id = id;
input.name = name; 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 // 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 // easier for us to initialize the widget blank and then setState to the correct state
const initialiseBlank = !!initialState.getCurrentContent; const initialiseBlank = !!initialState.getCurrentContent;

Wyświetl plik

@ -120,6 +120,9 @@ class FieldBlockAdapter(Adapter):
if block.field.help_text: if block.field.help_text:
meta["helpText"] = 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 [ return [
block.name, block.name,
block.field.widget, block.field.widget,
@ -678,6 +681,7 @@ class RichTextBlock(FieldBlock):
"help_text": help_text, "help_text": help_text,
"validators": validators, "validators": validators,
} }
self.max_length = max_length
self.editor = editor self.editor = editor
self.features = features self.features = features
self.search_index = search_index self.search_index = search_index