本文介绍了PrimeFaces扩展CKEditor:无法访问自定义配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要我的pe:ckEditor来加载自定义配置,但是一段时间以来我一直没有成功,我将欢迎提出任何建议以使其工作.

I need my pe:ckEditor to load custom config, but I have been unsuccessful in this matter for some time, I will welcome any suggestions how to make it work.

(我需要它起作用,因为我有这个问题:,此 https://ckeditor.com/old/forums/CKEditor-3.x/utf-8-ckeditor 或类似 https://ckeditor.com/old/forums/Support/Change-charset-UTF-8 )

(I need it functional because I have this problem: PrimeFaces Extensions CKEditor: attempts to set encoding to UTF-8 unsuccessful, which might be solved by this https://ckeditor.com/old/forums/CKEditor-3.x/utf-8-ckeditor or something like this https://ckeditor.com/old/forums/Support/Change-charset-UTF-8)

自定义配置文件与pe:ckEditor所在的XHTML文件位于同一文件夹中.

The custom config file is in the same folder as my XHTML file in which the pe:ckEditor is.

自定义配置内容:

CKEDITOR.editorConfig = function( config ) {
    config.uiColor = '#AADC6E';
    config.toolbar = [
        { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
        { name: 'paragraph', items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] },
        '/',
        { name: 'links', items: [ 'Link', 'Unlink' ] },
        { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
        '/',
        { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
        { name: 'insert', items: [ 'Table', 'HorizontalRule',  'SpecialChar'] },
        { name: 'tools', items: [ 'ShowBlocks' ] },
        { name: 'document', items: [ 'Source' ] },
    ];
};

我尝试过:

<h:outputScript name="ckEditor.js" library="js"></h:outputScript>
<pe:ckEditor id="editor" customConfig="ckEditor.js"></pe:ckEditor>
<script type="text/javascript">
    CKEDITOR.config.customConfig = 'ckEditor.js';
    CKEDITOR.replace('editor');
 </script>

并且:

<h:outputScript name="ckEditor.js" library="js"></h:outputScript>
<pe:ckEditor id="editor" customConfig="ckEditor.js"></pe:ckEditor>

并且:

<pe:ckEditor id="editor"></pe:ckEditor>
    <script type="text/javascript">
        CKEDITOR.config.customConfig = 'ckEditor.js';
        CKEDITOR.replace('editor');
     </script>

并且:

<pe:ckEditor id="editor" customConfig="ckEditor.js"></pe:ckEditor>

并且:

<pe:ckEditor id="editor" customConfig="./ckEditor.js"></pe:ckEditor>

并且(文件的完整路径为 project/WebContent/pages/inc/ckEditor.js project/WebContent/pages/inc/emailEditor.xhtml ):

And (full path of the files is project/WebContent/pages/inc/ckEditor.js and project/WebContent/pages/inc/emailEditor.xhtml):

<pe:ckEditor id="editor" customConfig="project/WebContent/pages/inc/ckEditor.js"></pe:ckEditor>

并且:

<pe:ckEditor id="editor" customConfig="/project/WebContent/pages/inc/ckEditor.js"></pe:ckEditor>

并且(由于 https://forum.primefaces.org/viewtopic.php ?t = 31334 ):

<pe:ckEditor id="editor" customConfig="#{request.contextPath}/ckEditor.js"></pe:ckEditor>


当我将自定义配置文件中的详细信息输入到<pe:ckEditor>下的<script>时,它可以工作,但是不幸的是,这并不是我的情况的解决方案,因为我在许多页面上使用了编辑器,并且需要对其进行设置只能存储在一个地方.


When I entered the details from the custom config file into the <script> below the <pe:ckEditor>, it worked, but that is unfortunately not a solution for my case as I use the editor on many pages and need its settings to be stored at one place only.

此外,当我进行谷歌搜索时,我发现一些建议,我应该将自定义配置的说明放到默认配置文件中,但是我在项目中没有找到任何默认配置文件,因此不幸的是,这不是一个选择对我来说.

Also, when I was googling, I found some suggestion that I should place the directions for the custom config into the default config file, but I have not found any default config file in my project, so that is unfortunately not an option for me.

我做过google,在PrimeFaces Extensions页面和CKEditor页面上阅读了文档,在PrimeFaces论坛,CKEditor论坛以及此处阅读了类似的问题,但仍然没有任何效果.

I did google, read documentation at PrimeFaces Extensions page and CKEditor page, read similar questions at PrimeFaces forum, CKEditor forum and here, but nothing has worked yet.

PrimeFaces扩展-版本7.0.2
PrimeFaces-版本7.0.7

PrimeFaces Extensions - version 7.0.2
PrimeFaces - version 7.0.7

推荐答案

pe:ckEditor上的customConfig属性是URL.
因此,只需将JS放在可以通过浏览器访问的位置.
如果它可以访问(例如)为localhost:8080/myfolder/ckeditor.js,则在将customConfig设置为'#{request.contextPath} myFolder/ckeditor.js'

The customConfig attribute on pe:ckEditor is a URL.
So just put your JS somewhere, where it's a accessible via the browser.
If its accessible (for example) as localhost:8080/myfolder/ckeditor.js, it should work correctly when you set customConfig to '#{request.contextPath}myFolder/ckeditor.js'

这篇关于PrimeFaces扩展CKEditor:无法访问自定义配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:29