|
129 | 129 | window.ContentEditor = prepareContentEditorObject(django.jQuery) |
130 | 130 |
|
131 | 131 | django.jQuery(($) => { |
132 | | - ContentEditor.addPluginButton = (prefix, iconHTML) => { |
| 132 | + ContentEditor.addPluginButton = ( |
| 133 | + prefix, |
| 134 | + iconHTML, |
| 135 | + initializing = false, |
| 136 | + ) => { |
133 | 137 | const plugin = ContentEditor.pluginsByPrefix[prefix] |
134 | 138 | if (!plugin) return |
135 | 139 |
|
|
160 | 164 | const unit = qs(".plugin-buttons") |
161 | 165 | unit.appendChild(button) |
162 | 166 |
|
163 | | - hideNotAllowedPluginButtons([button]) |
| 167 | + if (!initializing) { |
| 168 | + updatePluginButtonsVisibility() |
| 169 | + } |
164 | 170 | } |
165 | 171 |
|
166 | 172 | // Add basic structure. There is always at least one inline group if |
|
487 | 493 |
|
488 | 494 | // Hide not allowed plugin buttons |
489 | 495 | // If buttons only checks this buttons, else checks all |
490 | | - function hideNotAllowedPluginButtons(_buttons) { |
491 | | - const buttons = _buttons |
492 | | - ? _buttons |
493 | | - : qsa(".plugin-buttons .plugin-button") |
494 | | - |
| 496 | + function updatePluginButtonsVisibility() { |
| 497 | + const buttons = qsa(".plugin-buttons .plugin-button") |
495 | 498 | let visible = 0 |
496 | 499 |
|
497 | 500 | for (const button of buttons) { |
|
838 | 841 | .filter(`[data-region="${ContentEditor.currentRegion}"]`) |
839 | 842 | .addClass("active") |
840 | 843 |
|
841 | | - // Make sure only allowed plugins are in select |
842 | | - hideNotAllowedPluginButtons() |
843 | | - |
| 844 | + updatePluginButtonsVisibility() |
844 | 845 | updateSections() |
845 | 846 | }) |
846 | 847 | })() |
|
1003 | 1004 | setTimeout(restoreEditorState, 1) |
1004 | 1005 |
|
1005 | 1006 | for (const plugin of ContentEditor.plugins) { |
1006 | | - ContentEditor.addPluginButton(plugin.prefix, plugin.button) |
| 1007 | + ContentEditor.addPluginButton(plugin.prefix, plugin.button, true) |
1007 | 1008 | } |
1008 | 1009 |
|
1009 | 1010 | if (!ContentEditor.allowChange) { |
|
0 commit comments