如何在链接浏览器中为内容元素和新的 rte_ckeditor 定义自定义类、标题和目标? [英] How to define custom class, title, and target in Link Browser for content elements and the new rte_ckeditor?

查看:18
本文介绍了如何在链接浏览器中为内容元素和新的 rte_ckeditor 定义自定义类、标题和目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先决条件

[x] 你能在 TYPO3 8.7 LTS 上重现这个问题吗 - YES

[x] Can you reproduce the problem on TYPO3 8.7 LTS - YES

[x] 您是否[执行粗略搜索] 以查看是否已报告您的错误或增强功能?-是的

[x] Did you [perform a cursory search] to see if your bug or enhancement is already reported? -YES

说明

如何在 Typo3 8 LTS 的任何元素链接(通常是元素标题和图像)和 rte_ckeditor 中为链接浏览器配置默认链接目标、类和标题?我花了几个小时试图配置它,但没有成功,也没有文档.如下图所示,这些字段为空.

How do I configure default link target, class, and title for the Link Browser in any element link (usually element titles and images) AND in rte_ckeditor in Typo3 8 LTS? I've spent several hours trying to configure it, but no success and no documentation out there. The fields are empty as you can see on the images below.

重现问题的步骤

  1. 创建任何可以链接标题或图像的元素.
  2. 点击打开链接浏览器
  3. 对于任何类型的链接(页面、文件、文件夹、外部 URL、电子邮件),选项都为空.

预期行为:如果它们为空,我想为每种类型的链接定义默认类、链接目标和标题.例如外部 URL,如果之前没有配置链接,我想自动填充 target="_blank", class "external-link", title="Link to External Website".基本上对于任何新链接,我只想让它自动填充我的自定义值而不是空值.

Expected behavior: I want to define default classes, link targets and titles for each type of link if they are empty. For example External URL, I want to automatically populate with target="_blank", class "external-link", title="Link to External Website", if the link wasn't configure previously. Basically for any new link I just want to have it auto populated with my custom values and not empty values.

这曾经仅适用于以前的 Typo3 版本的 rtehtmlarea,但不是我无法在 Typo3 8 LTS 和 ckeditor 上设置此选项系统范围.

This used to work for rtehtmlarea only on previous Typo3 versions, but not I'm not able to set this option system wide on Typo3 8 LTS and ckeditor.

过去只适用于 rtehtmlarea 的 PageTS 是这样的:

The PageTS that used to work only for rtehtmlarea was something like this:

RTE {
    classesAnchor {
        externalLink {
            class = external-link
            type = url
            titleText = Opens external link in new window
            target = _blank
            image =
        }
        externalLinkInNewWindow {
            class = external-link-new-window
            type = url
            titleText = Opens external link in new window
            target = _blank
            image =
        }
        internalLink {
            class = internal-link
            type = page
            titleText =  Opens internal link in this window
            target = _top
            image =
        }
        internalLinkInNewWindow {
            class = internal-link-new-window
            type = page
            titleText = Opens internal link in new window
            target = _blank
            image =
        }
        folder {
            class = folder
            type = folder
            titleText =
            target =
            image =
        }
        download {
            class = download
            type = file
            titleText = Initiates file download
            target = _blank
            image =
        }
        mail {
            class = mail
            type = mail
            titleText = Email Address
            image =
        }
    }
}

我希望它适用于新的 rte_ckeditor 以及我可以使用链接浏览器链接的任何元素选项.

I would like this to work for the new rte_ckeditor as well for any element options that I can link using the Link Browser.

推荐答案

所以,日复一日,日复一日!!!在搜索、试验和错误中,我终于找到了一种方法,可以根据链接的类型在 rte_ckeditor 之外甚至在 rtehtmlarea 之外启用链接的自动填充参数.这不是我想要的,但几乎就在那里!

So after days and days and days!!! of search, trials, and errors, I finally found a way to enable the auto populated parameter of a link according to their type outside rte_ckeditor or even outside rtehtmlarea. It's not exactly what I wanted but is almost there!

将此添加到我的页面 TSConfig 解决了部分问题:

Adding this to my Page TSConfig solved part of the problem:

TCEMAIN.linkHandler {
    # I don't want to load the folder link handler so I reset it.
    folder >
    # Leaving page type empty on purpose.
    page {
    }
    file {
        addParams = onclick="jumpToUrl('?act=file&linkAttributes[target]=_blank&linkAttributes[title]=Opens or downloads file in new window&linkAttributes[class]=download&linkAttributes[params]=');return false;"
    }
    url {
        addParams = onclick="jumpToUrl('?act=url&linkAttributes[target]=_blank&linkAttributes[title]=Opens external link in new window&linkAttributes[class]=externalLink&linkAttributes[params]=');return false;"
    }
    mail {
        addParams = onclick="jumpToUrl('?act=mail&linkAttributes[title]=Opens email manager to send an email&linkAttributes[class]=mail&linkAttributes[params]=');return false;"
    }
}

我没有为 page 配置任何东西,因为如果它被填充并且我点击文件、外部 URL、电子邮件或任何其他自定义链接处理程序,属性将从页面链接处理程序传递,这违背了为每个链接处理程序类型预先填充参数的目的.

I didn't configure anything for page because if it's populated and I click on File, External Url, Email, or any other custom link handler, the attributes are passed along from the Page link handler, which defeats the purpose of the pre-populated parameters for each link handler type.

剩下的唯一问题是,例如,如果我点击 External URL,目标将是 "_blank",标题将是 "Opens external link innew window" 和 class 将是 "externalLink".到现在为止还挺好.然后如果你点击链接一个 File 甚至链接一个内部的 Page,那些为外部 URL 预加载的参数将被传递,我认为它不应该不会发生.由于我试图预填充每个链接类型,为什么我要保留以前链接类型的属性?这可能只是一个意见问题,但我希望为每种链接类型提供强制预填充参数的选项.也许我只是缺少一个小配置来实现这种行为.

The only remaining issue is if I click for example on External URL, the target will be "_blank", title will be "Opens external link in new window" and class will be "externalLink". So far so good. Then if you click to link a File or even to link an internal Page, those parameters that pre-loaded for External URL will be passed along, which I think it shouldn't happen. Since I'm trying to pre-populate each link type, why would I want to keep the attribute of a previous link type? This might be just a matter of opinion, but I would like to have the option for force pre-populated parameters for each link type. Maybe I'm just missing a small config to achieve this behavior.

这篇关于如何在链接浏览器中为内容元素和新的 rte_ckeditor 定义自定义类、标题和目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆