How to enter non-rich-text?

只愿长相守 提交于 2019-12-24 04:33:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!