i got issues in Saving Data in Rich Texts .. I already make the setAttributes for each attribute and have no changes too ! it is my code
attributes
attributes :{
titleONEHOMEPorT: {
type: "string",
source: "html",
selector: "h2",
},
titleTwoHOMEPorT: {
type: "string",
source: "html",
selector: "h2",
},
},
'Attributes and setAttributes'
const {titleONEHOMEPorT , titleTwoHOMEPorT} = attributes;
function onChangeTitleOnePort(newporttitone) { setAttributes({ titleONEHOMEPorT: newporttitone }); }
and this is the rich text in return
<RichText key="editable" tagName="h2" placeholder="اخر" value={titleONEHOMEPorT} onChange={onChangeTitleOnePort} />
And there's no thing shows in Console .. and not stored in DB Too
The RichText component requires saving the content in save() with <RichText.Content ... />. By implementing the save() function to return null, the content is not saved into HTML. The way the RichText component works is by using the selector set in attributes to parse content from the saved source (HTML). If there is no content saved into the post content as HTML, nothing can load.
Using the PHP render_callback for dynamic blocks is intended for dynamic content. As you mention this is your current approach, if you are using PHP to do some dynamic string replacement or something similiar, perhaps what you could try instead is using the_content hook to alter the content after its retrieved from the database but before its displayed on the frontend. By using this approach, you can implement the required save() function for RichText to work and have the content saved and edited via the Editor while making full use of RichText features.