1

我需要一些指示如何将 TYPO3 7.6 中的 htmlarea_rte 中的 userElements 迁移到 TYPO3 8.7 中的 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>
      )
    }
  }
}
4

2 回答 2

2

所以您的问题是关于如何将这些样式(<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/

于 2017-10-19T08:29:30.213 回答
0

我创建了一个小的 CKEditor 插件来满足我的需要:

'use strict';

(function () {

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

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

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

})();

该插件需要此​​文件结构才能工作:

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

于 2017-10-27T08:06:11.123 回答