问题
Is it possible to enter non-rich-text into the text editor? The apostrophe-rich-text editor seems to add <p>
tags around everything inside it. I'd like to format the widget.html like so:
<h2>{{ apos.singleton(data.widget, 'section-heading', 'apostrophe-rich-text') }}</h2>
but the output wraps the text in <p>
tags so they override the <h2>
. Is there any way to override this behavior?
回答1:
I figured it out. You have to use the "string" type in the index.js. For example in the /widget-name/index.js, you would put:
module.exports = {
extend: 'apostrophe-widgets',
label: 'Section Heading',
addFields: [
{
name: 'sectionHeading',
label: 'Section Heading',
type: 'string'
}
]
};
Then, in the /widget-name/views/widget.html, put:
<h2>{{ data.widget.sectionHeading }}</h2>
This will bring up a dialogue box with a text field labelled "Section Heading". When you save the dialogue box, the string will render on your site.
来源:https://stackoverflow.com/questions/43374782/how-to-enter-non-rich-text