I need to add a functionality to my CKEditor to give suggestions to user when he types '#' in document, the suggestions can change on the fly depending on some other fields on the page. please help
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
In order to make a suggestion box, you will have to make your custom plugin to use context menu as suggestion box, please check out the link for the basic knowledge of making ckeditor plugin from here a link
Add this to your config.js, where autocomplete is name of the plugin
Then create a following directory structure/file in the ckeditor folder
Put the following content in your plugin.js file
We will need to create a dummy span in the document to calculate the current position of the menu to be shown
After calculation the position, we remove the element and call the method to show the suggestions (placed in the context menu, which are configured in next function)
Here is the listener bind on editor to check whether the current key is a # or not, CKEDITOR.SHIFT + 51 is the key combination for #
reloadSuggetionBox command will be called from your external jquery to generate the menu just after the ckeditor is ready
Here "Suggestions" is the variable present somewhere on your page with holds a list of object having a 'id' and 'label' to be shown in suggestion.
Now in order to configure these suggestions, please perform the following jquery code, after this, whenever '#' is pressed, suggestions will be shown
This will load the ckeditor(contractData is name of my ckeditor instance) and configure the plugin to show suggestions currently present int the "Suggestions" variable, anytime you need to refresh/change the suggestions you just need to call this function after reloading "Suggestions" variable
Let me know if you get any problem on getting this working.
Find the downloadable plugin at my repo at
http://navalgandhi1989.github.io/ckeditor-autocomplete-suggestions-plugin/