如何扩展撇号富文本小部件样式

How to extend Apostrophe Rich Text Widget Styles

我正在尝试在撇号中扩展富文本窗口小部件样式,但它不起作用。

在home.html

{ apos.area(data.page, 'body', {

        widgets: {
            'apostrophe-rich-text': {
                toolbar: [ 'Styles', 'Bold', 'Italic', 'Link', 
                                   'Unlink'],
                styles: [
                    { name: 'Heading', element: 'h2'},
                    { name: 'Subheading', element: 'h3'},
                    { name: 'Paragraph', element: 'p'}
                ]
            }
            }
    }) }}

在lib/modules/apostrophe-rich-text-widgets/index.js

module.exports = {
  // The standard list copied from the module, plus sup and sub

  sanitizeHtml: {

    allowedTags: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 
                   'ul', 'ol', 'li', 'b', 'i', 'strong', 'em', 'strike', 
                   'code', 'hr', 'br', 'div', 'table', 'thead', 'caption', 
                   'tbody', 'tr', 'th', 'td', 'pre', 'sup', 'sub'
    ],

    allowedAttributes: {
      a: [ 'href', 'name', 'target' ],
      // We don't currently allow img itself by default, but this
      // would make sense if we did
      img: [ 'src' ]
    },

    // Lots of these won't come up by default because we don't allow them
    selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont',
      'input', 'link', 'meta' ],
    // URL schemes we permit
    allowedSchemes: [ 'http', 'https', 'ftp', 'mailto' ],
    allowedSchemesByTag: {}
  }
};

HTML 标签 h3 和 p 可以正常工作,但 h2 和 p 一样。是不是我写的不对?

谢谢!

我修复了它,为 h2 标签添加了样式。我注意到 h3 在 site.less

中有自己的风格
h3 {
    font-size: 24px;
    margin-bottom: 12px;
  }

  h4 {
    font-size: 20px;
    margin-bottom: 10px;
  }

  strong { font-weight: bold; }
  em { font-style: italic; }

所以我将我想要的样式添加到我的 h2 标签中,它起作用了。