Liferay: customize CKEditor

假装没事ソ 提交于 2019-12-11 07:34:39

问题


I try to customize shortcuts keys in Liferay 6, in the CKEditor.

I made a hook, and added this to the file html/js/editor/ckeditor/ckconfig.jsp:

CKEDITOR.config.keystrokes = [
    [ CKEDITOR.ALT + 121 /*F10*/, 'toolbarFocus' ],
    [ CKEDITOR.ALT + 122 /*F11*/, 'elementsPathFocus' ],

    [ CKEDITOR.SHIFT + 121 /*F10*/, 'contextMenu' ],

    [ CKEDITOR.CTRL + 90 /*Z*/, 'undo' ],
    [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ],
    [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ],

    [ CKEDITOR.CTRL + 76 /*L*/, 'link' ],

    [ CKEDITOR.CTRL + 71 /*G*/, 'bold' ],
    [ CKEDITOR.CTRL + 73 /*I*/, 'italic' ],
    [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ],

    [ CKEDITOR.ALT + 109 /*-*/, 'toolbarCollapse' ]
];

The problem is, whatever the change I make in this file, it changes nothing in my CKEditor! Even if I remove everything, it is still the same.

When I parse the page with Firebug, I see that ckeditor.jsp is parsed, and even if I manually edit this file, the shortcuts are still the native ones.

Question is: is this JSP file even parsed by CKEditor? If yes, is there anything that blocks my modifications?


回答1:


I think we figured this out. As referenced in http://issues.liferay.com/browse/LPS-5075 the latest version of CKEditor takes it's customizations from ROOT\html\js\editor\ckeditor\config.js, not ckconfig.jsp . The documentation in Liferay User Interface Development may no longer be applicable to this version. After you update this file, make sure you clear the browser cache, close the browser, clear the Tomcat work directory, and restart Tomcat to ensure you see new updates (I'm having problems with that).

Example of overriding a toolbar:

CKEDITOR.editorConfig = function( config )
{
    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';

    config.toolbar_liferay = [
        ['Undo', 'Redo', '-', 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'SelectAll', 'RemoveFormat'],
        ['Link', 'Unlink', 'Anchor'],
        ['Image', 'Flash', 'Table', '-', 'Smiley', 'SpecialChar']
    ];
};



回答2:


It seems this has been fixed in Liferay 6.0 SP2. I just migrated and the first technic I exposed is now working...

Ed Holderman's answer must be valid for Liferay 6.0 SP1, though.

Thanks for your help.




回答3:


Also look here:

http://www.liferay.com/community/forums/-/message_boards/view_message/10991139#_19_message_10997220

The jsp that comes with liferay 6.0.5 / 6.0.6 CE has a ton of issues, and does not load the config!



来源:https://stackoverflow.com/questions/7104152/liferay-customize-ckeditor

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