kopia lustrzana https://github.com/wagtail/wagtail
display-character-count-to-RichTextBlock
rodzic
361c89ba9b
commit
96b5f45fad
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
Ładowanie…
Reference in New Issue