diff --git a/modules/ppcp-button/resources/js/modules/Renderer/PreviewButtonManager.js b/modules/ppcp-button/resources/js/modules/Renderer/PreviewButtonManager.js index 5277d9d8a..dd201cffe 100644 --- a/modules/ppcp-button/resources/js/modules/Renderer/PreviewButtonManager.js +++ b/modules/ppcp-button/resources/js/modules/Renderer/PreviewButtonManager.js @@ -184,6 +184,10 @@ class PreviewButtonManager { return; } + if (!this.shouldInsertPreviewButton(id)) { + return; + } + if (!this.buttons[id]) { this._addButton(id, ppcpConfig); } else { @@ -192,6 +196,22 @@ class PreviewButtonManager { } } + /** + * Determines if the preview box supports the current button. + * + * When this function returns false, this manager instance does not create a new preview button. + * + * @param {string} previewId - ID of the inner preview box container. + * @return {boolean} True if the box is eligible for the preview button, false otherwise. + */ + shouldInsertPreviewButton(previewId) { + const container = document.querySelector(previewId); + const box = container.closest('.ppcp-preview'); + const limit = box.dataset.ppcpPreviewBlock ?? 'all'; + + return ('all' === limit) || (this.methodName === limit); + } + /** * Applies a new configuration to an existing preview button. */