CKEditor 4下拉按钮插入占位符 [英] CKEditor 4 Dropdown Button to Insert Placeholder
问题描述
我发现了两个独立的插件: StrInsert
和占位符
。第一个插件创建下拉菜单,插入字符串和第二个插件插入占位符。
I found two separated plugins: StrInsert
and Placeholder
. The first plugin create dropdown menu that insert string and the second plugin insert placeholder.
这里是 StrInsert
插件的屏幕截图:
here's the screenshot for StrInsert
plugin:
和占位符
插件:
and for Placeholder
plugin:
互联网上有这么多问题要求类似的功能(制作一个插入占位符的下拉列表),但是没有解决方案/提供此功能的插件。以下是插件的链接: StrInsert 和占位符
There has been so many questions on the Internet asking for similar function (To make a dropdown that insert a placeholder), yet there's no solution/ plugin that provides this functionality. Here's the link for the plugins: StrInsert and Placeholder
我在 ckeditor
论坛也是。但是,以防万一其他人以前这样做过,我需要你的帮助。
I have asked this question on ckeditor
forum too. But, just in case somebody else here has done this before, I need your help.
============== ==============编辑=================================== ======
这是什么 StrInsert
呢,
当单击其中一个下拉菜单时,它将插入文本
进入编辑器。但是,我希望它插入占位符
而不是插入文本
。
Here's what StrInsert
does,
when one of the dropdown menu is clicked, it will insert a text
into the editor. However, instead of inserting a text
, I want it to insert a placeholder
.
占位符
可以使用另一个名为 PlaceHolder
的插件插入,它与<$有什么区别? C $ C>文本?它有黄色背景颜色,最重要的是,用户无法删除字母
Placeholder
can be inserted using another plugin called PlaceHolder
, how is it differ from text
? It has yellow background color and most importantly, the user can't erase the letter
推荐答案
是的,这可以完成,可以用你已经拥有的东西来完成。
Yes this can be done, and can be done with what you already have.
总之 - Placeholder插件可以很好地将占位符表示为自包含的黄色元素,而StrInsert插件提供了一种方便的方法,可以从下拉列表中插入预定义的字符串,而不是让用户输入它们进入一个对话框。
In summary - the Placeholder plugin does a nice job of representing the placeholders as self contained yellow elements, and the StrInsert plugin offers a convenient method of inserting pre-defined strings from a drop-down list rather than having the user type them into a dialog.
因此,一个简单的解决方案是充分利用两者--StrInsert插入占位符字符串。它适用于您描述和使用每个插件的标准功能。
Therefore, a simple solution to get the best of both is to use both - StrInsert to insert placeholder strings. It works as you describe and uses the standard functionality of each plugin.
步骤如下:
-
从标准安装的两个插件开始。我不认为我需要在这里描述一下。
Start with both plugins installed as standard. I don't think I need to describe that bit here.
StrInsert插件允许您在其插件脚本文件中定义其字符串值。不要在那里放置常规字符串,而是以占位符格式添加字符串。
The StrInsert plugin allows you to define its string values within its plugin script file. Instead of putting regular strings in there, add your strings in placeholder format.
例如。更改下面的默认字符串...
e.g. Change the default strings below...
//要插入编辑器的字符串数组
var strings = [];
strings.push(['@@ FAQ :: displayList()@@','FAQs','FAQs']);
strings.push(['@@ Glossary :: displayList()@@','Glossary','Glossary']);
strings.push(['@@ CareerCourse :: displayList()@@','职业课程','职业课程']);
strings.push(['@@ CareerProfile :: displayList()@@','职业档案','职业档案']);
// array of strings to choose from that'll be inserted into the editor var strings = []; strings.push(['@@FAQ::displayList()@@', 'FAQs', 'FAQs']); strings.push(['@@Glossary::displayList()@@', 'Glossary', 'Glossary']); strings.push(['@@CareerCourse::displayList()@@', 'Career Courses', 'Career Courses']); strings.push(['@@CareerProfile::displayList()@@', 'Career Profiles', 'Career Profiles']);
to使它们成为你想要的占位符......
to make them your desired placeholders...
//可以选择的字符串数组,它们将被插入到编辑器中
var strings = [];
strings.push(['[[Something]]','Something','Something']);
...
// array of strings to choose from that'll be inserted into the editor var strings = []; strings.push(['[[Something]]', 'Something', 'Something']); ...
最后,如果你不需要占位符按钮,那么你可以通过使用它来删除它(只是按钮) ckeditor文件夹中正常config.js中的条目。可能已经有一个removeButtons行,你可以添加CreatePlaceholder,但无论如何它看起来像这样:
Finally, if you don't need the Placeholder button as well then you can remove it (just the button) by using the entry in the normal config.js in the ckeditor folder. There may already be a removeButtons line in there that you can add CreatePlaceholder to, but in any case it'll look something like this:
config.removeButtons ='CreatePlaceholder' ;
config.removeButtons = 'CreatePlaceholder';
这篇关于CKEditor 4下拉按钮插入占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!