TYPO3 CKeditor 未呈现 javascript link

TYPO3 CKeditor not rendering javascript link

我正在使用 TYPO3 8.7.8,必须提供 javascript link 才能停用 Google Analytics。

link 应该是这样的:

<a href="javascript:gaOptout()" onclick="alert('Google Analytics is now deactivated');">Deactivate Google Analytics</a>

不幸的是 link 没有出现在前端,这意味着它只是 <p> 标签内的普通文本。但是在后端一切都很好,它在那里显示为 link...

这是我的 CKeditor yaml 配置:

# Load default processing options
imports:
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml" }

# Configuration for the editor
# For complete documentation see http://docs.ckeditor.com/#!/api/CKEDITOR.config
editor:
  config:
    allowedContent: true
    linkJavaScriptLinksAllowed: true
    contentsCss: ["EXT:rte_ckeditor/Resources/Public/Css/contents.css", "EXT:my_extension/Resources/Public/Stylesheets/styles.css", "EXT:my_extension/Resources/Public/Stylesheets/fonts.css"]
    resize_enabled: true

    stylesSet:
    # block level styles
    - { name: "Button Default", element: "a", attributes: { 'class': 'btn btn-default', 'role': 'button', 'aria-pressed': 'true'}}

    format_tags: "p;h1;h2;h3;h4;h5;pre"

    toolbarGroups:
      - { name: styles, groups: [ styles, format ] }
      - { name: basicstyles, groups: [ basicstyles ] }
      - { name: paragraph, groups: [ list, indent, blocks, align ] }
      - { name: links, groups: [ links ] }
      - { name: clipboard, groups: [ clipboard, cleanup, undo ] }
      - { name: editing, groups: [ spellchecker ] }
      - { name: insert, groups: [ insert ] }
      - { name: tools, groups: [ table, specialchar ] }
      - { name: document, groups: [ mode ] }

    justifyClasses:
      - text-left
      - text-center
      - text-right
      - text-justify

    extraPlugins:
      - justify

    removePlugins:
      - image

    removeButtons:
      - Anchor
      - Underline
      - Strike

buttons.:
  link.:
    queryParametersSelector.:
      enabled: true

我在这里错过了什么?

这不是 ckeditor 的问题,而是 TYPO3 本身禁止的,以避免安全问题 - XSS。

我使用的解决方案是这样的 这样编辑器例如links 到 http://ga-output.tld,这将被 JS link.

取代

我们只是 运行 遇到了同样的问题 - 我们为 typo3 编写了一个小的 link 处理程序,只允许 javascript:gaOptOut(); link.

在此处获取: https://www.infoworxx.de/download/ifx_linkhandler_googleAnalytics.zip

塞巴斯蒂安

您可以使用源按钮 (<>) 在 ckeditor 中将 class 添加到 link。

<a class="gaOptout" href="#">your linked text</a>

现在您只需将函数重写为这样的 onclick 事件:

$('.gaOptout').on('click', function(){
your function
});

这在 T3 9.5 中似乎仍然是一个问题,尤其是对于这个 Google OptOut 脚本。 无需编码的简单解决方法:我们删除包含 javascript 的段落并将其放在单独的 html 元素中。只需从 CKEs Source-view 中将其剪下并粘贴到新元素中即可。为了保持文章的顺序,只需剪切文本的其余部分并将其粘贴到新的文本元素中。