Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block API: Adding a Block API flag to disable the block's HTML mode #3037

Merged
merged 2 commits into from
Oct 18, 2017

Conversation

youknowriad
Copy link
Contributor

closes #2985

This PR adds a supportHTML block type property to remove support for the HTML mode. The idea is to fix this issue before the next release.

Notes

  • We could consider to infer this from blocks returning null in the save function but this is not consistent, Some dynamic blocks can decide to provide fallback HTML and some static blocks could return null depending on some attributes.

  • We need to start thinking about unifying all the support* flags under a unique property?

Testing instructions

  • Check that the HTML, latest posts, categories and more blocks do not support the HTML mode (no button to toggle modes)

@youknowriad youknowriad added [Feature] Block API API that allows to express the block paradigm. [Type] Bug An existing feature does not function as intended labels Oct 17, 2017
@youknowriad youknowriad self-assigned this Oct 17, 2017
@jasmussen
Copy link
Contributor

In my testing, using your instructions, this works for me 👍 👍

@@ -34,7 +35,7 @@ function BlockSettingsMenuContent( { mode, uids, isSidebarOpened, onDelete, onTo
>
{ __( 'Settings' ) }
</IconButton>
{ count === 1 &&
{ count === 1 && blockType && blockType.supportHTML !== false &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is count === 1 redundant here, since blockType assumes a single selected block anyways?

import { removeBlocks, toggleSidebar, setActivePanel, toggleBlockMode } from '../actions';

function BlockSettingsMenuContent( { mode, uids, isSidebarOpened, onDelete, onToggleSidebar, onShowInspector, onToggleMode, onClose } ) {
export function BlockSettingsMenuContent( { blockType, mode, uids, isSidebarOpened, onDelete, onToggleSidebar, onShowInspector, onToggleMode, onClose } ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider splitting props onto their own lines, since this one is now quite long? Alternatively, would it be sensible to create a separate component solely responsible for deciding whether and how an "Edit as HTML" button should be rendered?

Copy link
Contributor Author

@youknowriad youknowriad Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be sensible to create a separate component solely responsible for deciding whether and how an "Edit as HTML" button should be rendered?

Sounds like a good idea

Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

import { toggleBlockMode } from '../actions';

export function BlockModeToggle( { blockType, mode, onToggleMode } ) {
if ( blockType.supportHTML === false ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure how defensive we should be here, i.e. what if blockType is null, or in getBlock( state, uid ).name the property accesses on null? Not likely to ever occur, but would be destructive if it did.

@youknowriad youknowriad merged commit 285df53 into master Oct 18, 2017
@youknowriad youknowriad deleted the add/block-api-disable-html branch October 18, 2017 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTML view of "Read More" link is not intuitive.
3 participants