简体   繁体   English

如何在CKEditor中设置自定义链接浏览器?

[英]How to set custom link browser in CKEditor?

CKEditor documentation describes "File Browser (Uploader)" which appears when user clicks insert image button. CKEditor文档描述了“文件浏览器(上传器)”,当用户单击“插入图像”按钮时出现。

But I see no documentation about dialog which appears when user clicks insert hyperlink button. 但是我没有看到有关对话框的文档,该对话框在用户单击“插入超链接”按钮时出现。 This dialog also has "browse on server" button which shows file browser. 此对话框还具有“浏览服务器”按钮,该按钮显示文件浏览器。 But I have my won list of server pages on my site. 但是我在自己的网站上有我的服务器页面列表。 Can I configure my custom list here, not browsing for file? 我可以在这里配置我的自定义列表,而不浏览文件吗?

You can make a custom plugin or modify the default link plugin. 您可以制作自定义插件或修改默认链接插件。

To make a custom plugin, create a directory in /plugins with the name you want to use for the new plugin, then copy the contents of the _source/plugins/link directory into your new directory. 要制作自定义插件,请在/plugins创建一个目录,并使用您要用于新插件的名称,然后将_source/plugins/link目录的内容复制到新目录中。 You'll need to change the plugin name throughout those copied files. 您需要在所有复制的文件中更改插件名称。 Then modify the dialog files to suit your needs. 然后修改对话框文件以适合您的需求。 Then load your new plugin with the config.extraPlugins setting and add the button to your config.toolbar_xxx setting. 然后使用config.extraPlugins设置加载新插件,并将按钮添加到config.toolbar_xxx设置。


To modify the existing link plugin, copy the uncompressed file for the link dialog window from: 要修改现有的链接插件,请从以下位置复制链接对话框窗口的未压缩文件:
_source/plugins/link/dialogs/link.js

and replace the: 并替换:
plugins/link/dialogs/link.js

Then modify that dialog window file, one approach would be to populate a select element with your list of server pages. 然后修改该对话框窗口文件,一种方法是用服务器页面列表填充select元素。

You could change the url text field: 您可以更改url文本字段:

type : 'text',
id : 'url',
label : commonLang.url,
required: true,

To this: 对此:

type : 'select',
id : 'url',
label : commonLang.url,
required: true,
'default' : 'xxx',
items :
[
  [ 'Link Name', 'Link Path' ],
  [ 'Link Name', 'Link Path' ],
  [ 'Link Name', 'Link Path' ],
  [ 'Link Name', 'Link Path' ]
],

Then go through the functions associated with the url element, removing the ones you don't need and modifying the remaining functions to do what you want. 然后遍历与url元素关联的功能,删除不需要的功能,然后修改其余功能以完成所需的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM