2017-10-19 286 views
1

我需要一些指针如何将TYPO3 7.6中的htmlarea_rte中的userElements迁移到TYPO3 8.7中的CKEditor。如何在TYPO3 8.7中将htmlarea userElements迁移到CKEditor?

或者更改我的问题:如何在CKEditor中自定义html预先链接?

这是我userElements什么样子:

RTE.default { 
    contentCSS = EXT:mytheme/Resources/Public/Css/Rte.css 

    proc.allowTagsOutside := addToList(i,em) 
    proc.entryHTMLparser_db.tags.i > 
    proc.entryHTMLparser_db.tags.em > 

    showButtons := addToList(user) 

    proc.allowedClasses := addToList(envelope, phone, fax) 
    classesCharacter = envelope, phone, fax 

    userElements { 
    10 = Icons 
    10 { 
     1 = E-Mail 
     1.content (
<i class="envelope"></i> 
    ) 

     2 = Telefon 
     2.content (
<i class="phone"></i> 
    ) 

     3 = Fax 
     3.content (
<i class="fax"></i> 
    ) 
    } 
    } 
} 

回答

0

我创建了一个小型CKEditor插件以适合我的需求:

'use strict'; 
 

 
(function() { 
 

 
\t CKEDITOR.dtd.$removeEmpty.em = 0; 
 
\t CKEDITOR.dtd.$removeEmpty.i = 0; 
 

 
\t CKEDITOR.plugins.add('icon-envelope', { 
 
\t \t icons: 'iconenvelope', 
 
\t \t init: function (editor) { 
 
\t \t \t editor.ui.addButton('IconEnvelope', { 
 
\t \t \t \t label: 'Icon E-Mail', 
 
\t \t \t \t toolbar: 'insert', 
 
\t \t \t \t command: 'insertIconEnvelope' 
 
\t \t \t }); 
 

 
\t \t \t editor.addCommand('insertIconEnvelope', { 
 
\t \t \t \t exec: function (editor) { 
 
\t \t \t \t \t var icon = editor.document.createElement('i'); 
 
\t \t \t \t \t icon.setAttribute('class', 'fa fa-envelope'); 
 
\t \t \t \t \t editor.insertElement(icon); 
 
\t \t \t \t } 
 
\t \t \t }); 
 
\t \t } 
 
\t }); 
 

 
})();

插件需要这个文件结构的工作:

icon-envelope plugin.js icons iconenvelope.png

整合TYPO3通过这个YAML做: editor: externalPlugins: icon-envelope: { resource: "EXT:mytheme/Resources/Public/CkEditorPlugins/icon-envelope/plugin.js" }

完整的代码可以在这里找到: https://gist.github.com/peterkraume/95106c5b27615e06dcfcb01a62b2a30c

1

所以你的问题是关于如何将这些样式(<i class="envelope"></i>等)添加到CKEDITOR?

首先,添加你.yaml配置文件(见https://typo3worx.eu/2017/02/configure-ckeditor-in-typo3/

然后在# Inline styles部分,你可以添加类似:参考这里也

 - { name: 'Envelope', element: 'i', attributes: { 'class': 'envelope' } } 

参见:https://processwire.com/talk/topic/8342-adding-css-classes-to-ckeditor/

+0

有了'stylesSet',我可以将元素添加到元素中,但这并不是我想在此处存档。我想插入完整的摘录,例如'并不包裹任何现有的文字。 还是我需要创建一个自定义插件来归档? –

+0

在创建自定义插件之前,我会尝试使用https://ckeditor.com/cke4/addon/glyphicons;) 说我不喜欢使用空标签添加图标,我更喜欢使用':before '伪元素 –