{"action":"created","issue":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/11338","repository_url":"https://api.github.com/repos/WordPress/gutenberg","labels_url":"https://api.github.com/repos/WordPress/gutenberg/issues/11338/labels{/name}","comments_url":"https://api.github.com/repos/WordPress/gutenberg/issues/11338/comments","events_url":"https://api.github.com/repos/WordPress/gutenberg/issues/11338/events","html_url":"https://github.com/WordPress/gutenberg/issues/11338","id":376186291,"node_id":"MDU6SXNzdWUzNzYxODYyOTE=","number":11338,"title":"Is it possible to disable default block styles?","user":{"login":"dashkevych","id":3655965,"node_id":"MDQ6VXNlcjM2NTU5NjU=","avatar_url":"https://avatars0.githubusercontent.com/u/3655965?v=4","gravatar_id":"","url":"https://api.github.com/users/dashkevych","html_url":"https://github.com/dashkevych","followers_url":"https://api.github.com/users/dashkevych/followers","following_url":"https://api.github.com/users/dashkevych/following{/other_user}","gists_url":"https://api.github.com/users/dashkevych/gists{/gist_id}","starred_url":"https://api.github.com/users/dashkevych/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dashkevych/subscriptions","organizations_url":"https://api.github.com/users/dashkevych/orgs","repos_url":"https://api.github.com/users/dashkevych/repos","events_url":"https://api.github.com/users/dashkevych/events{/privacy}","received_events_url":"https://api.github.com/users/dashkevych/received_events","type":"User","site_admin":false},"labels":[{"id":808238501,"node_id":"MDU6TGFiZWw4MDgyMzg1MDE=","url":"https://api.github.com/repos/WordPress/gutenberg/labels/[Type]%20Help%20Request","name":"[Type] Help Request","color":"cc317c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-31T22:35:29Z","updated_at":"2018-11-14T12:34:52Z","closed_at":null,"author_association":"NONE","body":"Some blocks come with multiple styles. For example, a default Quote block offers two styles: Regular and Large. I am wondering, if it's possible to disable a specific style. `add_theme_support()` maybe?"},"comment":{"url":"https://api.github.com/repos/WordPress/gutenberg/issues/comments/438646919","html_url":"https://github.com/WordPress/gutenberg/issues/11338#issuecomment-438646919","issue_url":"https://api.github.com/repos/WordPress/gutenberg/issues/11338","id":438646919,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODY0NjkxOQ==","user":{"login":"nickcernis","id":647669,"node_id":"MDQ6VXNlcjY0NzY2OQ==","avatar_url":"https://avatars3.githubusercontent.com/u/647669?v=4","gravatar_id":"","url":"https://api.github.com/users/nickcernis","html_url":"https://github.com/nickcernis","followers_url":"https://api.github.com/users/nickcernis/followers","following_url":"https://api.github.com/users/nickcernis/following{/other_user}","gists_url":"https://api.github.com/users/nickcernis/gists{/gist_id}","starred_url":"https://api.github.com/users/nickcernis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickcernis/subscriptions","organizations_url":"https://api.github.com/users/nickcernis/orgs","repos_url":"https://api.github.com/users/nickcernis/repos","events_url":"https://api.github.com/users/nickcernis/events{/privacy}","received_events_url":"https://api.github.com/users/nickcernis/received_events","type":"User","site_admin":false},"created_at":"2018-11-14T12:34:52Z","updated_at":"2018-11-14T12:34:52Z","author_association":"NONE","body":"`wp.blocks.unregisterBlockStyle` has no effect on core blocks for me (WP 5.0 Beta 4/Gutenberg 4.3), at least when enqueued in a theme via 'init' or 'enqueue_block_editor_assets' like this:\r\n\r\n```php\r\nadd_action( 'enqueue_block_editor_assets', 'theme_name_block_editor_styles' );\r\n/**\r\n * Enqueues Gutenberg admin editor scripts.\r\n *\r\n * @since 2.7.0\r\n */\r\nfunction theme_name_block_editor_styles() {\r\n\r\n\twp_enqueue_script(\r\n\t\t'theme-name-editor',\r\n\t\tget_stylesheet_directory_uri() . '/lib/gutenberg/js/editor.js',\r\n\t\tarray( 'wp-blocks' ),\r\n\t\tCHILD_THEME_VERSION\r\n\t);\r\n\r\n}\r\n```\r\n\r\nI had to use a filter in `/lib/gutenberg/js/editor.js` to filter editor styles like this instead:\r\n\r\n```js\r\nvar spThemes = (function () {\r\n\t'use strict';\r\n\r\n\tfunction adjustBlockStyles(settings, name) {\r\n\t\tswitch (name) {\r\n\t\t\tcase 'core/quote':\r\n\t\t\t\treturn removeStyles(settings, ['large']);\r\n\t\t\tcase 'core/button':\r\n\t\t\t\tsetDefaultLabel(settings, 'Squared');\r\n\t\t\t\treturn removeStyles(settings, ['outline', 'squared']);\r\n\t\t\tcase 'core/pullquote':\r\n\t\t\t\treturn removeStyles(settings, ['solid-color']);\r\n\t\t\tcase 'core/separator':\r\n\t\t\t\treturn removeStyles(settings, ['wide', 'dots']);\r\n\t\t\tcase 'core/table':\r\n\t\t\t\treturn removeStyles(settings, ['stripes']);\r\n\t\t\tdefault:\r\n\t\t\t\treturn settings;\r\n\t\t}\r\n\t}\r\n\r\n\tfunction setDefaultLabel(settings, newLabel) {\r\n\t\tsettings['styles'] = settings['styles'].map(function (style) {\r\n\t\t\tif (style.isDefault) style.label = newLabel;\r\n\t\t\treturn style;\r\n\t\t});\r\n\t}\r\n\r\n\tfunction removeStyles(settings, styles) {\r\n\t\tsettings['styles'] = settings['styles'].filter(function (style) {\r\n\t\t\treturn styles.indexOf(style.name) === -1;\r\n\t\t});\r\n\t\treturn settings;\r\n\t}\r\n\r\n\treturn {\r\n\t\tadjustBlockStyles: adjustBlockStyles\r\n\t};\r\n\r\n}());\r\n\r\nwp.hooks.addFilter(\r\n\t'blocks.registerBlockType',\r\n\t'sp/editor',\r\n\tspThemes.adjustBlockStyles\r\n);\r\n```\r\n\r\nYou can add `console.log(name, settings.styles);` at the top of `adjustBlockStyles` before the switch statement to see a list of all active blocks and their available style names prior to being filtered. "}}
{"actor":{"display_login":"nickcernis"}}