CKEditor: Hide some toolbar buttons on a per page basis
source link: https://blog.jakubholy.net/2011/04/04/ckeditor-hide-some-toolbar-buttons-on-a-per-page-basis/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
CKEditor: Hide some toolbar buttons on a per page basis
The page:
...
<script type="text/javascript">
// This must be defined before including ckeditor.js:
var removeButtons = "Link,Preview";
</script>
<script type="text/javascript" src="/mywebapproot/myckeditor/editor/ckeditor.js"></script>
...
My custom CKEditor configuration .js:
function removeUnwantedTools( toolbar )
{
if (typeof(removeButtons) == "undefined") { return toolbar; }
var filteredTools = new Array();
for(var i = 0, len = toolbar.length; i < len; i++)
{
var element = toolbar[i];
if (element instanceof Array)
{
filteredTools.push(
removeUnwantedTools(element)); //perhaps don't add if empty
}
else if (removeButtons.indexOf(element) == -1)
{
filteredTools.push(element);
}
// else just ignore the element present on the removeButtons list
}
return filteredTools;
}
CKEDITOR.editorConfig = function( config ) {
...
config.toolbar_Default = removeUnwantedTools([
['Preview', 'Source','Link'],['MyPlugin', 'AnotherCustomPlugin']
]);
...
}
The result will be that this plugin will only have the buttons [['Source'],['MyPlugin', 'AnotherCustomPlugin']].
It is not completely fool-proof but worked well for me.
Are you benefitting from my writing? Consider buying me a coffee or supporting my work via GitHub Sponsors. Thank you! You can also book me for a mentoring / pair-programming session via Codementor or (cheaper) email.
Allow me to write to you!
Let's get in touch! I will occasionally send you a short email with a few links to interesting stuff I found and with summaries of my new blog posts. Max 1-2 emails per month. I read and answer to all replies.
Recommend
-
11
Closed Bug 1674539 Opened 2 months ago Closed 1 month ago...
-
6
Some thoughts on the Yahoo! Toolbar offer on the Macromedia website Thursday, March 10, 2005 First of all, I am sorry that I have not been posting much for the past couple of months. As I
-
11
Hide div when the page loads and displays the same after a few seconds advertisements i have a div which i want to hide when the page loads an...
-
9
In this tutorial, we’ll learn how to hide specific chat messages for users using the TalkJS Chat API message filters. We will also learn how to combine TalkJS custom message attributes with message filters to...
-
6
Why are some buttons dimmed in the Markdown plugin for IntelliJ? advertisements I'm using
-
4
CKEditor: Collapsing only 2nd+ toolbar rows - howto April 1, 2011 Normally CKEditor (v3.5.2) hides/shows all the toolbar button...
-
5
CKEditor: Scroll dialogs with the page, i.e. not fixed to the middle March 31, 2011 Dialogs in the popular rich-text wysiwyg...
-
2
How to Hide a Page Title in WordPress Page titles not working with the design of your WordPress pages? Not sure how to hide the titles on your WordPress pages? WordPress makes it easy fo...
-
7
How to Hide or Remove Title on a Page in WordPress (3 Techniques) Titles are an important part of many webpages on a website. They help the readers and search engines know the main topic or content of the your page or post. H...
-
8
By default, a toolbar in UINavigationController will always be visible at the bottom of the screen.
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK