【问题标题】:How to change default font size in rich:editor如何更改丰富的默认字体大小:编辑器
【发布时间】:2012-11-15 12:31:48
【问题描述】:

我的 xhtml 视图中有一个 rich:editor 字段,它的默认字体大小为 11。它是这样的:

<rich:editor id="editor_value"
    configuration="#{editorBean.currentSimpleConfiguration}"
    width="560" height="130" viewMode="#{editorBean.viewMode}"
    value="#{bean.value}">

我想更改默认字体大小并使其更大。

我知道我可以使用 "f:param" 来做到这一点,例如:

<rich:editor id="editor_value"
    configuration="#{editorBean.currentSimpleConfiguration}"
    width="560" height="130" viewMode="#{editorBean.viewMode}"
    value="#{bean.value}"/>
    <f:param name="font_size" value="13px"/>
</rich:editor>    

或将分配“font_size=13px”放入我的“simple.properties”文件(在“configuration="#{editorBean.currentSimpleConfiguration}"”中引用)

但这些解决方案无效,字体大小继续为 11px...

有人知道我哪里错了吗?

非常感谢

【问题讨论】:

    标签: richfaces


    【解决方案1】:

    您需要使用配置方面并遵循 CKEditor 说明:http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html

    例子:

    <rich:editor value="Test de contenu">
        <f:facet name="config">
        contentsCss: '#{facesContext.externalContext.requestContextPath}/resources/rich.css',
        toolbar: 'custom',
        language: 'fr',
        startupFocus: true,
        toolbar_custom:
            [
                { name: 'document', items : [ 'NewPage','Preview' ] },
                { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
                { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','Scayt' ] },
                { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'
                         ,'Iframe' ] },
                        '/',
                { name: 'styles', items : [ 'Styles','Format' ] },
                { name: 'basicstyles', items : [ 'Bold','Italic','Strike','-','RemoveFormat' ] },
                { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote' ] },
                { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
                { name: 'tools', items : [ 'Maximize' ] }
            ]
        </f:facet>
    </rich:editor>
    

    并创建您的自定义内容 css:

    body,
    p
    {
        font-family: Arial;
        font-size: 16px;
        font-weight: bold;
    }
    

    希望这会有所帮助!

    【讨论】:

    • 它至少对我有帮助。缺乏好的richface示例令人不安;(
    【解决方案2】:

    只需将content_css 参数添加到您的&lt;rich:editor&gt; 并将其指向您的样式表并在其中定义您的样式。

    <rich:editor>
       <f:param name="content_css" value="resources/myStyles.css"/>
    </rich:editor>
    

    现在在 myStyles.css 中定义您的样式,如下所示。

    body {
      color:red;
      font-size:20px;
    }
    

    欲了解更多信息:http://www.tinymce.com/tryit/full.php

    【讨论】:

      猜你喜欢
      • 2014-10-05
      • 2010-12-28
      • 2012-06-12
      • 1970-01-01
      • 2012-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多