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

Post editor: add temporary flag to disable iframe #48064

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/block-library/src/paragraph/block.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"temporarilyDisableIframe": "I understand that this flag will only work for two releases (6.2 and 6.3) and that the block must be updated to avoid breakage in WP 6.4.",
Copy link
Member Author

Choose a reason for hiding this comment

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

Just added this for testing. Can't quite get it to work with the schema.

"name": "core/paragraph",
"title": "Paragraph",
"category": "text",
Expand Down
17 changes: 15 additions & 2 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
import { useMergeRefs } from '@wordpress/compose';
import { arrowLeft } from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { parse } from '@wordpress/blocks';
import { parse, store as blocksStore } from '@wordpress/blocks';
import { store as coreStore } from '@wordpress/core-data';

/**
Expand Down Expand Up @@ -155,6 +155,17 @@ export default function VisualEditor( { styles } ) {
( select ) => select( editPostStore ).hasMetaBoxes(),
[]
);
const hasIframeIncompatibleBlocks = useSelect(
( select ) =>
select( blocksStore )
.getBlockTypes()
.some(
( { temporarilyDisableIframe } ) =>
temporarilyDisableIframe ===
'I understand that this flag will only work for two releases (6.2 and 6.3) and that the block must be updated to avoid breakage in WP 6.4.'
),
[]
);
const { themeHasDisabledLayoutStyles, themeSupportsLayout, isFocusMode } =
useSelect( ( select ) => {
const _settings = select( blockEditorStore ).getSettings();
Expand Down Expand Up @@ -339,7 +350,9 @@ export default function VisualEditor( { styles } ) {
>
<MaybeIframe
shouldIframe={
( isBlockBasedTheme && ! hasMetaBoxes ) ||
( isBlockBasedTheme &&
! hasMetaBoxes &&
! hasIframeIncompatibleBlocks ) ||
isTemplateMode ||
deviceType === 'Tablet' ||
deviceType === 'Mobile'
Expand Down
7 changes: 7 additions & 0 deletions schemas/json/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
"default": 1,
"enum": [ 1, 2 ]
},
"temporarilyDisableIframe": {
"type": "string",
"description": "This property is used to temporarily disable the iframe.",
"enum": [
"I understand that this flag will only work for two releases (6.2 and 6.3) and that the block must be updated to avoid breakage in WP 6.4."
]
},
"name": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$",
Expand Down