gpt4 book ai didi

telerik - Sitecore 的富文本编辑器的内部链接管理器能否记住您的上次位置?

转载 作者:行者123 更新时间:2023-12-01 03:57:49 27 4
gpt4 key购买 nike



是否可以记住最后链接的项目并在下次使用“插入链接”对话框时选择该项目?

背景

我们的 Sitecore 内容编辑器使用富文本编辑器 (Telerik RadEditor) 来编辑我们网站上的 HTML 内容。有时他们需要在同一页面上创建多个位于相似区域的链接(例如,几篇不同的相关文章)。目前,当他们单击“插入链接”按钮时,他们会进入“插入链接”对话框,其中在内容树中选择了当前项目。他们浏览到要链接的项目并单击链接。然后他们去创建另一个链接,它会再次打开当前项目的“插入链接”对话框,而不是他们刚刚链接的项目。

最佳答案

我发现的解决方案需要更改 Website\sitecore\shell\Controls\Rich Text Editor\RichText Commands.js只要您不重新加载页面,文件就可以工作。通过将信息存储在 中,您可以在编辑其他页面时轻松扩展它的工作。 cookies 而不是使用变量 上一个 .

首先,您需要在文件的开头定义变量:

var prevId = null;

每次插入 Sitecore 链接时,我们都会将最后选择的项目 ID 分配给该变量。

第二步是扩展 scInsertSitecoreLink分配 prevId 的函数选择链接后的变量:
function scInsertSitecoreLink(sender, returnValue) {

if (!returnValue) {
return;
}

prevId = returnValue.url.match(/id\=[a-fA-F0-9]{32}/g);
if (prevId) {
prevId = prevId[0].substr(3);
}

... rest of the scInsertSitecoreLink goes here

最后一步是修改 RadEditorCommandList["InsertSitecoreLink"]它使用 prevId 的函数如果在尝试分配之前设置了变量值 scItemID保存当前项目 id:
RadEditorCommandList["InsertSitecoreLink"] = function(commandName, editor, args) {\

... here goes the original code of the function up to
if (!id) {
... and the code in the bracket
}

... and now we try to assign the prevId which was set after the last link was chosen
if(!id && prevId) {
id = prevId;
}

... and here goes the rest of the function
if (!id) {
id = scItemID;
}

关于telerik - Sitecore 的富文本编辑器的内部链接管理器能否记住您的上次位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15773787/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com