From 6a8b8bb62840e069a9b59ab3127a911b02a92eed Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Fri, 22 Feb 2019 00:42:26 +0100 Subject: [PATCH 1/6] Expose required methods for better unsupported blocks --- packages/block-library/src/index.native.js | 87 +++++++++++++++++++++- packages/blocks/src/api/index.native.js | 1 + packages/components/src/index.native.js | 7 +- 3 files changed, 91 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/index.native.js b/packages/block-library/src/index.native.js index a1bd0b0d2f4f8..3e426e3dfead2 100644 --- a/packages/block-library/src/index.native.js +++ b/packages/block-library/src/index.native.js @@ -9,12 +9,93 @@ import { /** * Internal dependencies */ -import * as code from './code'; -import * as heading from './heading'; -import * as more from './more'; import * as paragraph from './paragraph'; import * as image from './image'; +import * as heading from './heading'; +import * as quote from './quote'; +import * as gallery from './gallery'; +import * as archives from './archives'; +import * as audio from './audio'; +import * as button from './button'; +import * as calendar from './calendar'; +import * as categories from './categories'; +import * as code from './code'; +import * as columns from './columns'; +import * as column from './columns/column'; +import * as cover from './cover'; +import * as embed from './embed'; +import * as file from './file'; +import * as html from './html'; +import * as mediaText from './media-text'; +import * as latestComments from './latest-comments'; +import * as latestPosts from './latest-posts'; +import * as list from './list'; +import * as missing from './missing'; +import * as more from './more'; import * as nextpage from './nextpage'; +import * as preformatted from './preformatted'; +import * as pullquote from './pullquote'; +import * as reusableBlock from './block'; +import * as rss from './rss'; +import * as search from './search'; +import * as separator from './separator'; +import * as shortcode from './shortcode'; +import * as spacer from './spacer'; +import * as subhead from './subhead'; +import * as table from './table'; +import * as template from './template'; +import * as textColumns from './text-columns'; +import * as verse from './verse'; +import * as video from './video'; +import * as tagCloud from './tag-cloud'; + +export const coreBlocks = [ + // Common blocks are grouped at the top to prioritize their display + // in various contexts — like the inserter and auto-complete components. + paragraph, + image, + heading, + gallery, + list, + quote, + + // Register all remaining core blocks. + shortcode, + archives, + audio, + button, + calendar, + categories, + code, + columns, + column, + cover, + embed, + ...embed.common, + ...embed.others, + file, + html, + mediaText, + latestComments, + latestPosts, + missing, + more, + nextpage, + preformatted, + pullquote, + rss, + search, + separator, + reusableBlock, + spacer, + subhead, + table, + tagCloud, + template, + textColumns, + verse, + video, +].reduce( ( memo, block ) => { memo[block.name] = block; return memo; }, {} ); export const registerCoreBlocks = () => { [ diff --git a/packages/blocks/src/api/index.native.js b/packages/blocks/src/api/index.native.js index 2f850d36108cb..123be1e132a99 100644 --- a/packages/blocks/src/api/index.native.js +++ b/packages/blocks/src/api/index.native.js @@ -28,6 +28,7 @@ export { } from './registration'; export { isUnmodifiedDefaultBlock, + normalizeIconObject, } from './utils'; export { pasteHandler, getPhrasingContentSchema } from './raw-handling'; export { default as children } from './children'; diff --git a/packages/components/src/index.native.js b/packages/components/src/index.native.js index b66663af05285..b68e70efb0011 100644 --- a/packages/components/src/index.native.js +++ b/packages/components/src/index.native.js @@ -3,7 +3,7 @@ export * from './primitives'; export { default as Dashicon } from './dashicon'; export { default as Toolbar } from './toolbar'; export { default as ToolbarButton } from './toolbar-button'; -export { default as withSpokenMessages } from './higher-order/with-spoken-messages'; +export { default as Icon } from './icon'; export { default as IconButton } from './icon-button'; export { default as Spinner } from './spinner'; export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot-fill'; @@ -11,5 +11,10 @@ export { default as BaseControl } from './base-control'; export { default as TextareaControl } from './textarea-control'; // Higher-Order Components +export { default as withConstrainedTabbing } from './higher-order/with-constrained-tabbing'; +export { default as withFallbackStyles } from './higher-order/with-fallback-styles'; export { default as withFilters } from './higher-order/with-filters'; export { default as withFocusOutside } from './higher-order/with-focus-outside'; +export { default as withFocusReturn } from './higher-order/with-focus-return'; +export { default as withNotices } from './higher-order/with-notices'; +export { default as withSpokenMessages } from './higher-order/with-spoken-messages'; From cc21fb41b0426bd7839107ee4734e9fa10772d17 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Wed, 20 Mar 2019 12:20:56 +0100 Subject: [PATCH 2/6] Show unsupported block title/icon when possible --- .../components/mobile/unsupported-block/edit.js | 14 +++++++++++++- .../components/mobile/unsupported-block/index.js | 3 +++ .../components/mobile/unsupported-block/style.scss | 8 +++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/mobile/unsupported-block/edit.js b/packages/editor/src/components/mobile/unsupported-block/edit.js index c9fd637886977..061efe6a6dedb 100644 --- a/packages/editor/src/components/mobile/unsupported-block/edit.js +++ b/packages/editor/src/components/mobile/unsupported-block/edit.js @@ -6,7 +6,11 @@ import { View, Text } from 'react-native'; /** * WordPress dependencies */ +import { Icon } from '@wordpress/components'; +import { coreBlocks } from '@wordpress/block-library'; +import { normalizeIconObject } from '@wordpress/blocks'; import { Component } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies @@ -15,9 +19,17 @@ import styles from './style.scss'; export default class UnsupportedBlockEdit extends Component { render() { + const { originalName } = this.props.attributes; + const blockType = coreBlocks[ originalName ]; + const title = blockType ? blockType.settings.title : __( 'Unsupported' ); + const icon = blockType ? normalizeIconObject( blockType.settings.icon ) : 'admin-plugins'; + return ( - Unsupported + + + + { title } ); } diff --git a/packages/editor/src/components/mobile/unsupported-block/index.js b/packages/editor/src/components/mobile/unsupported-block/index.js index 486b4a03abd64..7e22c6dfee262 100644 --- a/packages/editor/src/components/mobile/unsupported-block/index.js +++ b/packages/editor/src/components/mobile/unsupported-block/index.js @@ -21,6 +21,9 @@ export const settings = { category: 'formatting', attributes: { + originalname: { + type: 'string', + }, content: { type: 'string', source: 'html', diff --git a/packages/editor/src/components/mobile/unsupported-block/style.scss b/packages/editor/src/components/mobile/unsupported-block/style.scss index 93cd55274fd0b..d2e3a304f4317 100644 --- a/packages/editor/src/components/mobile/unsupported-block/style.scss +++ b/packages/editor/src/components/mobile/unsupported-block/style.scss @@ -8,11 +8,17 @@ padding-right: 8; } +.unsupportedBlockIcon { + width: 20; + height: 20; + margin-bottom: 6px; +} + .unsupportedBlockMessage { text-align: center; color: #4f748e; // grey darken 20 padding-top: 24; padding-bottom: 24; - font-size: 16px; + font-size: 14px; font-family: $default-regular-font; } From f4daa430c84197893d0751fa3f6b58acb764f72c Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Wed, 20 Mar 2019 13:42:17 +0100 Subject: [PATCH 3/6] Remove native variant of editor package --- packages/editor/src/index.native.js | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 packages/editor/src/index.native.js diff --git a/packages/editor/src/index.native.js b/packages/editor/src/index.native.js deleted file mode 100644 index 5577700ddf021..0000000000000 --- a/packages/editor/src/index.native.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * WordPress dependencies - */ -import '@wordpress/blocks'; -import '@wordpress/core-data'; - -/** - * Internal dependencies - */ -import './store'; -import './hooks'; - -export * from './components'; -export * from './utils'; From 95d80c2a7fa10c5d6697d30e3336eb3b5639dd35 Mon Sep 17 00:00:00 2001 From: Tugdual de Kerviler Date: Wed, 20 Mar 2019 16:26:52 +0100 Subject: [PATCH 4/6] Refactor mobile blocks to fix circle dependencies --- .../src/components/index.native.js | 4 + .../mobile/bottom-sheet/button.native.js | 0 .../mobile/bottom-sheet/cell.native.js | 0 .../bottom-sheet/cellStyles.android.scss | 0 .../mobile/bottom-sheet/cellStyles.ios.scss | 0 .../mobile/bottom-sheet/index.native.js | 0 .../keyboard-avoiding-view.native.js | 0 .../mobile/bottom-sheet/picker-cell.native.js | 0 .../mobile/bottom-sheet/styles.native.scss | 0 .../components/mobile/picker/index.android.js | 2 +- .../src/components/mobile/picker/index.ios.js | 0 .../block-library/src/image/edit.native.js | 4 +- packages/block-library/src/index.native.js | 96 ++++++++++--------- .../src}/mobile/unsupported-block/edit.js | 0 .../src}/mobile/unsupported-block/index.js | 2 +- .../src}/mobile/unsupported-block/style.scss | 0 packages/edit-post/src/index.native.js | 4 +- .../editor/src/components/index.native.js | 9 -- packages/editor/src/index.native.js | 16 ++++ .../format-library/src/link/modal.native.js | 2 +- 20 files changed, 76 insertions(+), 63 deletions(-) rename packages/{editor => block-editor}/src/components/mobile/bottom-sheet/button.native.js (100%) rename packages/{editor => block-editor}/src/components/mobile/bottom-sheet/cell.native.js (100%) rename packages/{editor => block-editor}/src/components/mobile/bottom-sheet/cellStyles.android.scss (100%) rename packages/{editor => block-editor}/src/components/mobile/bottom-sheet/cellStyles.ios.scss (100%) rename packages/{editor => block-editor}/src/components/mobile/bottom-sheet/index.native.js (100%) rename packages/{editor => block-editor}/src/components/mobile/bottom-sheet/keyboard-avoiding-view.native.js (100%) rename packages/{editor => block-editor}/src/components/mobile/bottom-sheet/picker-cell.native.js (100%) rename packages/{editor => block-editor}/src/components/mobile/bottom-sheet/styles.native.scss (100%) rename packages/{editor => block-editor}/src/components/mobile/picker/index.android.js (95%) rename packages/{editor => block-editor}/src/components/mobile/picker/index.ios.js (100%) rename packages/{editor/src/components => block-library/src}/mobile/unsupported-block/edit.js (100%) rename packages/{editor/src/components => block-library/src}/mobile/unsupported-block/index.js (97%) rename packages/{editor/src/components => block-library/src}/mobile/unsupported-block/style.scss (100%) create mode 100644 packages/editor/src/index.native.js diff --git a/packages/block-editor/src/components/index.native.js b/packages/block-editor/src/components/index.native.js index 7b026253b7cd6..cb6169440765a 100644 --- a/packages/block-editor/src/components/index.native.js +++ b/packages/block-editor/src/components/index.native.js @@ -20,3 +20,7 @@ export { default as DefaultBlockAppender } from './default-block-appender'; // State Related Components export { default as BlockEditorProvider } from './provider'; + +// Mobile Editor Related Components +export { default as BottomSheet } from './mobile/bottom-sheet'; +export { default as Picker } from './mobile/picker'; diff --git a/packages/editor/src/components/mobile/bottom-sheet/button.native.js b/packages/block-editor/src/components/mobile/bottom-sheet/button.native.js similarity index 100% rename from packages/editor/src/components/mobile/bottom-sheet/button.native.js rename to packages/block-editor/src/components/mobile/bottom-sheet/button.native.js diff --git a/packages/editor/src/components/mobile/bottom-sheet/cell.native.js b/packages/block-editor/src/components/mobile/bottom-sheet/cell.native.js similarity index 100% rename from packages/editor/src/components/mobile/bottom-sheet/cell.native.js rename to packages/block-editor/src/components/mobile/bottom-sheet/cell.native.js diff --git a/packages/editor/src/components/mobile/bottom-sheet/cellStyles.android.scss b/packages/block-editor/src/components/mobile/bottom-sheet/cellStyles.android.scss similarity index 100% rename from packages/editor/src/components/mobile/bottom-sheet/cellStyles.android.scss rename to packages/block-editor/src/components/mobile/bottom-sheet/cellStyles.android.scss diff --git a/packages/editor/src/components/mobile/bottom-sheet/cellStyles.ios.scss b/packages/block-editor/src/components/mobile/bottom-sheet/cellStyles.ios.scss similarity index 100% rename from packages/editor/src/components/mobile/bottom-sheet/cellStyles.ios.scss rename to packages/block-editor/src/components/mobile/bottom-sheet/cellStyles.ios.scss diff --git a/packages/editor/src/components/mobile/bottom-sheet/index.native.js b/packages/block-editor/src/components/mobile/bottom-sheet/index.native.js similarity index 100% rename from packages/editor/src/components/mobile/bottom-sheet/index.native.js rename to packages/block-editor/src/components/mobile/bottom-sheet/index.native.js diff --git a/packages/editor/src/components/mobile/bottom-sheet/keyboard-avoiding-view.native.js b/packages/block-editor/src/components/mobile/bottom-sheet/keyboard-avoiding-view.native.js similarity index 100% rename from packages/editor/src/components/mobile/bottom-sheet/keyboard-avoiding-view.native.js rename to packages/block-editor/src/components/mobile/bottom-sheet/keyboard-avoiding-view.native.js diff --git a/packages/editor/src/components/mobile/bottom-sheet/picker-cell.native.js b/packages/block-editor/src/components/mobile/bottom-sheet/picker-cell.native.js similarity index 100% rename from packages/editor/src/components/mobile/bottom-sheet/picker-cell.native.js rename to packages/block-editor/src/components/mobile/bottom-sheet/picker-cell.native.js diff --git a/packages/editor/src/components/mobile/bottom-sheet/styles.native.scss b/packages/block-editor/src/components/mobile/bottom-sheet/styles.native.scss similarity index 100% rename from packages/editor/src/components/mobile/bottom-sheet/styles.native.scss rename to packages/block-editor/src/components/mobile/bottom-sheet/styles.native.scss diff --git a/packages/editor/src/components/mobile/picker/index.android.js b/packages/block-editor/src/components/mobile/picker/index.android.js similarity index 95% rename from packages/editor/src/components/mobile/picker/index.android.js rename to packages/block-editor/src/components/mobile/picker/index.android.js index a0b85caf96382..50f264adaa55d 100644 --- a/packages/editor/src/components/mobile/picker/index.android.js +++ b/packages/block-editor/src/components/mobile/picker/index.android.js @@ -9,7 +9,7 @@ import { View } from 'react-native'; */ import { __ } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; -import { BottomSheet } from '@wordpress/editor'; +import { BottomSheet } from '@wordpress/block-editor'; export default class Picker extends Component { constructor() { diff --git a/packages/editor/src/components/mobile/picker/index.ios.js b/packages/block-editor/src/components/mobile/picker/index.ios.js similarity index 100% rename from packages/editor/src/components/mobile/picker/index.ios.js rename to packages/block-editor/src/components/mobile/picker/index.ios.js diff --git a/packages/block-library/src/image/edit.native.js b/packages/block-library/src/image/edit.native.js index 2481d1ce3184a..ef84bda80239e 100644 --- a/packages/block-library/src/image/edit.native.js +++ b/packages/block-library/src/image/edit.native.js @@ -27,11 +27,9 @@ import { RichText, BlockControls, InspectorControls, -} from '@wordpress/block-editor'; -import { BottomSheet, Picker, -} from '@wordpress/editor'; +} from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { isURL } from '@wordpress/url'; import { doAction, hasAction } from '@wordpress/hooks'; diff --git a/packages/block-library/src/index.native.js b/packages/block-library/src/index.native.js index 3e426e3dfead2..3e9b04ce9e14d 100644 --- a/packages/block-library/src/index.native.js +++ b/packages/block-library/src/index.native.js @@ -49,53 +49,59 @@ import * as verse from './verse'; import * as video from './video'; import * as tagCloud from './tag-cloud'; +import * as UnsupportedBlock from './mobile/unsupported-block'; +export { UnsupportedBlock }; + export const coreBlocks = [ - // Common blocks are grouped at the top to prioritize their display - // in various contexts — like the inserter and auto-complete components. - paragraph, - image, - heading, - gallery, - list, - quote, + // Common blocks are grouped at the top to prioritize their display + // in various contexts — like the inserter and auto-complete components. + paragraph, + image, + heading, + gallery, + list, + quote, - // Register all remaining core blocks. - shortcode, - archives, - audio, - button, - calendar, - categories, - code, - columns, - column, - cover, - embed, - ...embed.common, - ...embed.others, - file, - html, - mediaText, - latestComments, - latestPosts, - missing, - more, - nextpage, - preformatted, - pullquote, - rss, - search, - separator, - reusableBlock, - spacer, - subhead, - table, - tagCloud, - template, - textColumns, - verse, - video, -].reduce( ( memo, block ) => { memo[block.name] = block; return memo; }, {} ); + // Register all remaining core blocks. + shortcode, + archives, + audio, + button, + calendar, + categories, + code, + columns, + column, + cover, + embed, + ...embed.common, + ...embed.others, + file, + html, + mediaText, + latestComments, + latestPosts, + missing, + more, + nextpage, + preformatted, + pullquote, + rss, + search, + separator, + reusableBlock, + spacer, + subhead, + table, + tagCloud, + template, + textColumns, + verse, + video, +].reduce( ( memo, block ) => { + memo[ block.name ] = block; + return memo; +}, {} ); export const registerCoreBlocks = () => { [ diff --git a/packages/editor/src/components/mobile/unsupported-block/edit.js b/packages/block-library/src/mobile/unsupported-block/edit.js similarity index 100% rename from packages/editor/src/components/mobile/unsupported-block/edit.js rename to packages/block-library/src/mobile/unsupported-block/edit.js diff --git a/packages/editor/src/components/mobile/unsupported-block/index.js b/packages/block-library/src/mobile/unsupported-block/index.js similarity index 97% rename from packages/editor/src/components/mobile/unsupported-block/index.js rename to packages/block-library/src/mobile/unsupported-block/index.js index 7e22c6dfee262..d72bf8526804b 100644 --- a/packages/editor/src/components/mobile/unsupported-block/index.js +++ b/packages/block-library/src/mobile/unsupported-block/index.js @@ -21,7 +21,7 @@ export const settings = { category: 'formatting', attributes: { - originalname: { + originalName: { type: 'string', }, content: { diff --git a/packages/editor/src/components/mobile/unsupported-block/style.scss b/packages/block-library/src/mobile/unsupported-block/style.scss similarity index 100% rename from packages/editor/src/components/mobile/unsupported-block/style.scss rename to packages/block-library/src/mobile/unsupported-block/style.scss diff --git a/packages/edit-post/src/index.native.js b/packages/edit-post/src/index.native.js index d097853f5a371..9454c2707d862 100644 --- a/packages/edit-post/src/index.native.js +++ b/packages/edit-post/src/index.native.js @@ -2,10 +2,8 @@ * WordPress dependencies */ import '@wordpress/core-data'; -import '@wordpress/block-editor'; -import { UnsupportedBlock } from '@wordpress/editor'; import '@wordpress/notices'; -import { registerCoreBlocks } from '@wordpress/block-library'; +import { registerCoreBlocks, UnsupportedBlock } from '@wordpress/block-library'; import { registerBlockType, setUnregisteredTypeHandlerName, unregisterBlockType } from '@wordpress/blocks'; /** diff --git a/packages/editor/src/components/index.native.js b/packages/editor/src/components/index.native.js index 8611b08dc2f03..85a33d69bf251 100644 --- a/packages/editor/src/components/index.native.js +++ b/packages/editor/src/components/index.native.js @@ -1,16 +1,7 @@ -/** - * Internal dependencies - */ -import * as UnsupportedBlock from './mobile/unsupported-block'; // Post Related Components export { default as PostTitle } from './post-title'; export { default as EditorHistoryRedo } from './editor-history/redo'; export { default as EditorHistoryUndo } from './editor-history/undo'; -export { default as BottomSheet } from './mobile/bottom-sheet'; -export { default as Picker } from './mobile/picker'; - -// Mobile Editor Related Components -export { UnsupportedBlock }; export * from './deprecated'; diff --git a/packages/editor/src/index.native.js b/packages/editor/src/index.native.js new file mode 100644 index 0000000000000..97a922ba6423e --- /dev/null +++ b/packages/editor/src/index.native.js @@ -0,0 +1,16 @@ +/** + * WordPress dependencies + */ +import '@wordpress/block-editor'; +import '@wordpress/blocks'; +import '@wordpress/core-data'; +import '@wordpress/rich-text'; + +/** + * Internal dependencies + */ +import './store'; +import './hooks'; + +export * from './components'; +export * from './utils'; diff --git a/packages/format-library/src/link/modal.native.js b/packages/format-library/src/link/modal.native.js index f828c9adc58d3..57bc01b9f28ef 100644 --- a/packages/format-library/src/link/modal.native.js +++ b/packages/format-library/src/link/modal.native.js @@ -9,7 +9,7 @@ import { Switch, Platform } from 'react-native'; */ import { __ } from '@wordpress/i18n'; import { Component } from '@wordpress/element'; -import { BottomSheet } from '@wordpress/editor'; +import { BottomSheet } from '@wordpress/block-editor'; import { prependHTTP } from '@wordpress/url'; import { withSpokenMessages, From e1e1d30af3565259cef82f97f61319ca4d16d0c3 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Thu, 21 Mar 2019 10:01:59 +0100 Subject: [PATCH 5/6] Fix styles for unsupported block --- .../src/mobile/unsupported-block/edit.js | 4 +--- .../src/mobile/unsupported-block/style.scss | 18 ++++++++---------- .../src/primitives/svg/style.native.scss | 5 +++++ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/block-library/src/mobile/unsupported-block/edit.js b/packages/block-library/src/mobile/unsupported-block/edit.js index 061efe6a6dedb..838c64d88b56c 100644 --- a/packages/block-library/src/mobile/unsupported-block/edit.js +++ b/packages/block-library/src/mobile/unsupported-block/edit.js @@ -26,9 +26,7 @@ export default class UnsupportedBlockEdit extends Component { return ( - - - + { title } ); diff --git a/packages/block-library/src/mobile/unsupported-block/style.scss b/packages/block-library/src/mobile/unsupported-block/style.scss index d2e3a304f4317..95a86122d7098 100644 --- a/packages/block-library/src/mobile/unsupported-block/style.scss +++ b/packages/block-library/src/mobile/unsupported-block/style.scss @@ -2,23 +2,21 @@ .unsupportedBlock { background-color: #e9eff3; // grey lighten 30 - padding-top: 8; - padding-bottom: 8; + padding-top: 24; + padding-bottom: 24; padding-left: 8; padding-right: 8; + align-items: center; + justify-content: center; } .unsupportedBlockIcon { - width: 20; - height: 20; - margin-bottom: 6px; + color: $gray-dark; } .unsupportedBlockMessage { + margin-top: 2; text-align: center; - color: #4f748e; // grey darken 20 - padding-top: 24; - padding-bottom: 24; - font-size: 14px; - font-family: $default-regular-font; + color: $gray-dark; + font-size: 14; } diff --git a/packages/components/src/primitives/svg/style.native.scss b/packages/components/src/primitives/svg/style.native.scss index a6017e488b922..83a99c47bd35a 100644 --- a/packages/components/src/primitives/svg/style.native.scss +++ b/packages/components/src/primitives/svg/style.native.scss @@ -12,3 +12,8 @@ color: #87a6bc; fill: currentColor; } + +.unsupported-icon { + color: $gray-dark; + fill: currentColor; +} From 9bf5acf9111009bcfef4ecc477670e6fbd56dfac Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Thu, 21 Mar 2019 11:05:31 +0100 Subject: [PATCH 6/6] Remove UnsupportedBlock in favor of core/missing --- packages/block-library/src/index.native.js | 6 +- packages/block-library/src/missing/edit.js | 54 ++++++++++++++++++ .../edit.js => missing/edit.native.js} | 0 packages/block-library/src/missing/index.js | 56 ++----------------- .../style.scss => missing/style.native.scss} | 0 .../src/mobile/unsupported-block/index.js | 46 --------------- packages/edit-post/src/index.native.js | 6 +- 7 files changed, 65 insertions(+), 103 deletions(-) create mode 100644 packages/block-library/src/missing/edit.js rename packages/block-library/src/{mobile/unsupported-block/edit.js => missing/edit.native.js} (100%) rename packages/block-library/src/{mobile/unsupported-block/style.scss => missing/style.native.scss} (100%) delete mode 100644 packages/block-library/src/mobile/unsupported-block/index.js diff --git a/packages/block-library/src/index.native.js b/packages/block-library/src/index.native.js index 3e9b04ce9e14d..0326be07c92ca 100644 --- a/packages/block-library/src/index.native.js +++ b/packages/block-library/src/index.native.js @@ -4,6 +4,7 @@ import { registerBlockType, setDefaultBlockName, + setUnregisteredTypeHandlerName, } from '@wordpress/blocks'; /** @@ -49,9 +50,6 @@ import * as verse from './verse'; import * as video from './video'; import * as tagCloud from './tag-cloud'; -import * as UnsupportedBlock from './mobile/unsupported-block'; -export { UnsupportedBlock }; - export const coreBlocks = [ // Common blocks are grouped at the top to prioritize their display // in various contexts — like the inserter and auto-complete components. @@ -108,6 +106,7 @@ export const registerCoreBlocks = () => { paragraph, heading, code, + missing, more, image, nextpage, @@ -117,3 +116,4 @@ export const registerCoreBlocks = () => { }; setDefaultBlockName( paragraph.name ); +setUnregisteredTypeHandlerName( missing.name ); diff --git a/packages/block-library/src/missing/edit.js b/packages/block-library/src/missing/edit.js new file mode 100644 index 0000000000000..a80710044f1ba --- /dev/null +++ b/packages/block-library/src/missing/edit.js @@ -0,0 +1,54 @@ +/** + * WordPress dependencies + */ +import { __, sprintf } from '@wordpress/i18n'; +import { RawHTML, Fragment } from '@wordpress/element'; +import { Button } from '@wordpress/components'; +import { getBlockType, createBlock } from '@wordpress/blocks'; +import { withDispatch } from '@wordpress/data'; +import { Warning } from '@wordpress/block-editor'; + +function MissingBlockWarning( { attributes, convertToHTML } ) { + const { originalName, originalUndelimitedContent } = attributes; + const hasContent = !! originalUndelimitedContent; + const hasHTMLBlock = getBlockType( 'core/html' ); + + const actions = []; + let messageHTML; + if ( hasContent && hasHTMLBlock ) { + messageHTML = sprintf( + __( 'Your site doesn’t include support for the "%s" block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely.' ), + originalName + ); + actions.push( + + ); + } else { + messageHTML = sprintf( + __( 'Your site doesn’t include support for the "%s" block. You can leave this block intact or remove it entirely.' ), + originalName + ); + } + + return ( + + + { messageHTML } + + { originalUndelimitedContent } + + ); +} + +export default withDispatch( ( dispatch, { clientId, attributes } ) => { + const { replaceBlock } = dispatch( 'core/block-editor' ); + return { + convertToHTML() { + replaceBlock( clientId, createBlock( 'core/html', { + content: attributes.originalUndelimitedContent, + } ) ); + }, + }; +} )( MissingBlockWarning ); diff --git a/packages/block-library/src/mobile/unsupported-block/edit.js b/packages/block-library/src/missing/edit.native.js similarity index 100% rename from packages/block-library/src/mobile/unsupported-block/edit.js rename to packages/block-library/src/missing/edit.native.js diff --git a/packages/block-library/src/missing/index.js b/packages/block-library/src/missing/index.js index bee4d275fa85b..8f2c001498c09 100644 --- a/packages/block-library/src/missing/index.js +++ b/packages/block-library/src/missing/index.js @@ -1,57 +1,13 @@ /** * WordPress dependencies */ -import { __, sprintf } from '@wordpress/i18n'; -import { RawHTML, Fragment } from '@wordpress/element'; -import { Button } from '@wordpress/components'; -import { getBlockType, createBlock } from '@wordpress/blocks'; -import { withDispatch } from '@wordpress/data'; -import { Warning } from '@wordpress/block-editor'; +import { __ } from '@wordpress/i18n'; +import { RawHTML } from '@wordpress/element'; -function MissingBlockWarning( { attributes, convertToHTML } ) { - const { originalName, originalUndelimitedContent } = attributes; - const hasContent = !! originalUndelimitedContent; - const hasHTMLBlock = getBlockType( 'core/html' ); - - const actions = []; - let messageHTML; - if ( hasContent && hasHTMLBlock ) { - messageHTML = sprintf( - __( 'Your site doesn’t include support for the "%s" block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely.' ), - originalName - ); - actions.push( - - ); - } else { - messageHTML = sprintf( - __( 'Your site doesn’t include support for the "%s" block. You can leave this block intact or remove it entirely.' ), - originalName - ); - } - - return ( - - - { messageHTML } - - { originalUndelimitedContent } - - ); -} - -const edit = withDispatch( ( dispatch, { clientId, attributes } ) => { - const { replaceBlock } = dispatch( 'core/block-editor' ); - return { - convertToHTML() { - replaceBlock( clientId, createBlock( 'core/html', { - content: attributes.originalUndelimitedContent, - } ) ); - }, - }; -} )( MissingBlockWarning ); +/** + * Internal dependencies + */ +import edit from './edit'; export const name = 'core/missing'; diff --git a/packages/block-library/src/mobile/unsupported-block/style.scss b/packages/block-library/src/missing/style.native.scss similarity index 100% rename from packages/block-library/src/mobile/unsupported-block/style.scss rename to packages/block-library/src/missing/style.native.scss diff --git a/packages/block-library/src/mobile/unsupported-block/index.js b/packages/block-library/src/mobile/unsupported-block/index.js deleted file mode 100644 index d72bf8526804b..0000000000000 --- a/packages/block-library/src/mobile/unsupported-block/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { RawHTML } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import edit from './edit'; - -export const name = 'gmobile/unsupported'; - -export const settings = { - title: __( 'Unsupported Block' ), - - description: __( 'Unsupported block type.' ), - - icon: 'editor-code', - - category: 'formatting', - - attributes: { - originalName: { - type: 'string', - }, - content: { - type: 'string', - source: 'html', - }, - }, - - supports: { - className: false, - customClassName: false, - }, - - transforms: { - }, - - edit, - - save( { attributes } ) { - return { attributes.content }; - }, -}; diff --git a/packages/edit-post/src/index.native.js b/packages/edit-post/src/index.native.js index 9454c2707d862..6ada9eb995ead 100644 --- a/packages/edit-post/src/index.native.js +++ b/packages/edit-post/src/index.native.js @@ -3,8 +3,8 @@ */ import '@wordpress/core-data'; import '@wordpress/notices'; -import { registerCoreBlocks, UnsupportedBlock } from '@wordpress/block-library'; -import { registerBlockType, setUnregisteredTypeHandlerName, unregisterBlockType } from '@wordpress/blocks'; +import { registerCoreBlocks } from '@wordpress/block-library'; +import { unregisterBlockType } from '@wordpress/blocks'; /** * Internal dependencies @@ -17,8 +17,6 @@ import './store'; export function initializeEditor() { // register and setup blocks registerCoreBlocks(); - registerBlockType( UnsupportedBlock.name, UnsupportedBlock.settings ); - setUnregisteredTypeHandlerName( UnsupportedBlock.name ); // disable Code and More blocks for the release // eslint-disable-next-line no-undef