diff --git a/bin/build-plugin-zip.sh b/bin/build-plugin-zip.sh index 40e265eaa51ed9..1339b8ccec2b8e 100755 --- a/bin/build-plugin-zip.sh +++ b/bin/build-plugin-zip.sh @@ -120,7 +120,6 @@ status "Creating archive... 🎁" zip -r gutenberg.zip \ gutenberg.php \ lib/*.php \ - block-library/*/*.php \ packages/block-library/src/*/*.php \ packages/block-serialization-default-parser/*.php \ post-content.php \ diff --git a/bin/get-server-blocks.php b/bin/get-server-blocks.php index 8e3b2060183811..851dbccfab6e6d 100755 --- a/bin/get-server-blocks.php +++ b/bin/get-server-blocks.php @@ -30,9 +30,6 @@ require_once dirname( dirname( __FILE__ ) ) . '/lib/client-assets.php'; // Register server-side code for individual blocks. -foreach ( glob( dirname( dirname( __FILE__ ) ) . '/block-library/*/index.php' ) as $block_logic ) { - require_once $block_logic; -} foreach ( glob( dirname( dirname( __FILE__ ) ) . '/packages/block-library/src/*/index.php' ) as $block_logic ) { require_once $block_logic; } diff --git a/block-library/editor.scss b/block-library/editor.scss deleted file mode 100644 index 764dac8ca8da9b..00000000000000 --- a/block-library/editor.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../packages/block-library/src/editor.scss"; diff --git a/block-library/html/editor.scss b/block-library/html/editor.scss deleted file mode 100644 index 0d80ba4ebcbea9..00000000000000 --- a/block-library/html/editor.scss +++ /dev/null @@ -1,25 +0,0 @@ -.gutenberg .wp-block-html { - iframe { - display: block; - - // Disable pointer events so that we can click on the block to select it - pointer-events: none; - } - - .CodeMirror { - border-radius: 4px; - border: $border-width solid $light-gray-500; - font-family: $editor-html-font; - font-size: $text-editor-font-size; - height: auto; - } - - .CodeMirror-gutters { - background: $white; - border-right: none; - } - - .CodeMirror-lines { - padding: 8px 8px 8px 0; - } -} diff --git a/block-library/html/test/__snapshots__/index.js.snap b/block-library/html/test/__snapshots__/index.js.snap deleted file mode 100644 index b971fb9bfc9664..00000000000000 --- a/block-library/html/test/__snapshots__/index.js.snap +++ /dev/null @@ -1,22 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`core/html block edit matches snapshot 1`] = ` -
-
-
-
- -
-
-
-`; diff --git a/block-library/index.js b/block-library/index.js deleted file mode 100644 index ba1faf30c115b6..00000000000000 --- a/block-library/index.js +++ /dev/null @@ -1,103 +0,0 @@ -/** - * WordPress dependencies - */ -import { - registerBlockType, - setDefaultBlockName, - setUnknownTypeHandlerName, -} from '@wordpress/blocks'; - -/** - * Internal dependencies - */ -import './style.scss'; -import './editor.scss'; -import './theme.scss'; -import * as paragraph from '../packages/block-library/src/paragraph'; -import * as image from '../packages/block-library/src/image'; -import * as heading from '../packages/block-library/src/heading'; -import * as quote from '../packages/block-library/src/quote'; -import * as gallery from '../packages/block-library/src/gallery'; -import * as archives from '../packages/block-library/src/archives'; -import * as audio from '../packages/block-library/src/audio'; -import * as button from '../packages/block-library/src/button'; -import * as categories from '../packages/block-library/src/categories'; -import * as code from '../packages/block-library/src/code'; -import * as columns from '../packages/block-library/src/columns'; -import * as column from '../packages/block-library/src/columns/column'; -import * as coverImage from '../packages/block-library/src/cover-image'; -import * as embed from '../packages/block-library/src/embed'; -import * as file from '../packages/block-library/src/file'; -import * as latestComments from '../packages/block-library/src/latest-comments'; -import * as latestPosts from '../packages/block-library/src/latest-posts'; -import * as list from '../packages/block-library/src/list'; -import * as more from '../packages/block-library/src/more'; -import * as nextpage from '../packages/block-library/src/nextpage'; -import * as preformatted from '../packages/block-library/src/preformatted'; -import * as pullquote from '../packages/block-library/src/pullquote'; -import * as reusableBlock from '../packages/block-library/src/block'; -import * as separator from '../packages/block-library/src/separator'; -import * as shortcode from '../packages/block-library/src/shortcode'; -import * as spacer from '../packages/block-library/src/spacer'; -import * as subhead from '../packages/block-library/src/subhead'; -import * as table from '../packages/block-library/src/table'; -import * as template from '../packages/block-library/src/template'; -import * as textColumns from '../packages/block-library/src/text-columns'; -import * as verse from '../packages/block-library/src/verse'; -import * as video from '../packages/block-library/src/video'; - -// The freeform block can't be moved to the "npm" packages folder because it requires the wp.oldEditor global. -import * as freeform from './freeform'; - -// The HTML block can't be moved to the "npm" packages folder because it requires the CodeEditor component. -import * as html from './html'; - -export const registerCoreBlocks = () => { - [ - // 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, - categories, - code, - columns, - column, - coverImage, - embed, - ...embed.common, - ...embed.others, - file, - freeform, - html, - latestComments, - latestPosts, - more, - nextpage, - preformatted, - pullquote, - separator, - reusableBlock, - spacer, - subhead, - table, - template, - textColumns, - verse, - video, - ].forEach( ( { name, settings } ) => { - registerBlockType( name, settings ); - } ); - - setDefaultBlockName( paragraph.name ); - setUnknownTypeHandlerName( freeform.name ); -}; diff --git a/block-library/index.native.js b/block-library/index.native.js deleted file mode 100644 index 3779a1214f53ac..00000000000000 --- a/block-library/index.native.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Internal dependencies - */ -import '../packages/block-library/src'; diff --git a/block-library/style.scss b/block-library/style.scss deleted file mode 100644 index 7afe88dde1f2bd..00000000000000 --- a/block-library/style.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../packages/block-library/src/style.scss"; diff --git a/block-library/theme.scss b/block-library/theme.scss deleted file mode 100644 index 39f6af550322ce..00000000000000 --- a/block-library/theme.scss +++ /dev/null @@ -1 +0,0 @@ -@import "../packages/block-library/src/theme.scss"; diff --git a/components/code-editor/index.js b/components/code-editor/index.js index 889f24d24783b3..cc2eb71da18d2b 100644 --- a/components/code-editor/index.js +++ b/components/code-editor/index.js @@ -3,6 +3,7 @@ */ import { Component } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; +import deprecated from '@wordpress/deprecated'; /** * Internal dependencies @@ -76,6 +77,11 @@ class LazyCodeEditor extends Component { this.state = { status: 'pending', }; + + deprecated( 'wp.components.CodeEditor', { + version: '4.2', + alternative: 'wp.codeEditor directly or any alternative React component for syntax highlighting', + } ); } componentDidMount() { diff --git a/docs/reference/deprecated.md b/docs/reference/deprecated.md index dad92900256832..deef0e0d7fbef5 100644 --- a/docs/reference/deprecated.md +++ b/docs/reference/deprecated.md @@ -23,6 +23,7 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo - `getMetaBox` selector (`core/edit-post`) has been removed. Use `isMetaBoxLocationActive` selector (`core/edit-post`) instead. - Attribute type coercion has been removed. Omit the source to preserve type via serialized comment demarcation. - `mediaDetails` in object passed to `onFileChange` callback of `wp.editor.mediaUpload`. Please use `media_details` property instead. +- `wp.components.CodeEditor` has been removed. Used `wp.codeEditor` directly instead. ## 4.1.0 diff --git a/lib/client-assets.php b/lib/client-assets.php index 12726da32ce501..71678b5de04db0 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -731,14 +731,14 @@ function gutenberg_register_scripts_and_styles() { wp_register_style( 'wp-edit-blocks', - gutenberg_url( 'build/block-library/edit-blocks.css' ), + gutenberg_url( 'build/block-library/editor.css' ), array( 'wp-components', 'wp-editor', // Always include visual styles so the editor never appears broken. 'wp-block-library-theme', ), - filemtime( gutenberg_dir_path() . 'build/block-library/edit-blocks.css' ) + filemtime( gutenberg_dir_path() . 'build/block-library/editor.css' ) ); wp_style_add_data( 'wp-edit-blocks', 'rtl', 'replace' ); diff --git a/packages/block-library/CHANGELOG.md b/packages/block-library/CHANGELOG.md index 43b9b38ee17c6f..7213234ec1b044 100644 --- a/packages/block-library/CHANGELOG.md +++ b/packages/block-library/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2.1.0 (Unreleased) + +### New Features + +- Include the classic block if `wp.oldEditor` is defined. +- Include the HTML block. + ## 2.0.0 (2018-09-05) ### Breaking Change diff --git a/block-library/freeform/edit.js b/packages/block-library/src/classic/edit.js similarity index 97% rename from block-library/freeform/edit.js rename to packages/block-library/src/classic/edit.js index 6fa71e20e1ec5a..6bede6a2df3183 100644 --- a/block-library/freeform/edit.js +++ b/packages/block-library/src/classic/edit.js @@ -5,11 +5,6 @@ import { Component } from '@wordpress/element'; import { __, _x } from '@wordpress/i18n'; import { BACKSPACE, DELETE, F10 } from '@wordpress/keycodes'; -/** - * Internal dependencies - */ -import './editor.scss'; - function isTmceEmpty( editor ) { // When tinyMce is empty the content seems to be: //


@@ -26,7 +21,7 @@ function isTmceEmpty( editor ) { return /^\n?$/.test( body.innerText || body.textContent ); } -export default class FreeformEdit extends Component { +export default class ClassicEdit extends Component { constructor( props ) { super( props ); this.initialize = this.initialize.bind( this ); @@ -176,7 +171,7 @@ export default class FreeformEdit extends Component { key="toolbar" id={ `toolbar-${ clientId }` } ref={ ( ref ) => this.ref = ref } - className="freeform-toolbar" + className="block-library-classic__toolbar" onClick={ this.focus } data-placeholder={ __( 'Classic' ) } onKeyDown={ this.onToolbarKeyDown } diff --git a/block-library/freeform/editor.scss b/packages/block-library/src/classic/editor.scss similarity index 99% rename from block-library/freeform/editor.scss rename to packages/block-library/src/classic/editor.scss index 9c03b0667461d2..70c8e819c2169b 100644 --- a/block-library/freeform/editor.scss +++ b/packages/block-library/src/classic/editor.scss @@ -144,7 +144,7 @@ div[data-type="core/freeform"] .editor-block-contextual-toolbar + div { padding-top: 0; } -.freeform-toolbar { +.block-library-classic__toolbar { width: auto; margin: 0 #{ -$block-padding }; position: sticky; diff --git a/block-library/freeform/index.js b/packages/block-library/src/classic/index.js similarity index 100% rename from block-library/freeform/index.js rename to packages/block-library/src/classic/index.js diff --git a/block-library/freeform/test/__snapshots__/index.js.snap b/packages/block-library/src/classic/test/__snapshots__/index.js.snap similarity index 87% rename from block-library/freeform/test/__snapshots__/index.js.snap rename to packages/block-library/src/classic/test/__snapshots__/index.js.snap index c14bc40ad32de8..690b0d5e30fdd1 100644 --- a/block-library/freeform/test/__snapshots__/index.js.snap +++ b/packages/block-library/src/classic/test/__snapshots__/index.js.snap @@ -3,7 +3,7 @@ exports[`core/freeform block edit matches snapshot 1`] = ` Array [
, diff --git a/block-library/freeform/test/index.js b/packages/block-library/src/classic/test/index.js similarity index 75% rename from block-library/freeform/test/index.js rename to packages/block-library/src/classic/test/index.js index 36e3735c12bc75..824c835543e7bc 100644 --- a/block-library/freeform/test/index.js +++ b/packages/block-library/src/classic/test/index.js @@ -2,7 +2,7 @@ * Internal dependencies */ import { name, settings } from '../'; -import { blockEditRender } from '../../../packages/block-library/src/test/helpers'; +import { blockEditRender } from '../../test/helpers'; describe( 'core/freeform', () => { test( 'block edit matches snapshot', () => { diff --git a/packages/block-library/src/editor.scss b/packages/block-library/src/editor.scss index c994183e6fcf03..70aa75c35b7f05 100644 --- a/packages/block-library/src/editor.scss +++ b/packages/block-library/src/editor.scss @@ -7,8 +7,10 @@ @import "./cover-image/editor.scss"; @import "./embed/editor.scss"; @import "./file/editor.scss"; +@import "./classic/editor.scss"; @import "./gallery/editor.scss"; @import "./heading/editor.scss"; +@import "./html/editor.scss"; @import "./image/editor.scss"; @import "./latest-comments/editor.scss"; @import "./latest-posts/editor.scss"; diff --git a/packages/block-library/src/html/editor.scss b/packages/block-library/src/html/editor.scss new file mode 100644 index 00000000000000..44daf03dd370af --- /dev/null +++ b/packages/block-library/src/html/editor.scss @@ -0,0 +1,12 @@ +.wp-block-html .editor-plain-text { + font-family: $editor-html-font; + font-size: $text-editor-font-size; + color: $dark-gray-800; + padding: 0.8em 1em; + border: 1px solid $light-gray-500; + border-radius: 4px; + + &:focus { + box-shadow: none; + } +} diff --git a/block-library/html/index.js b/packages/block-library/src/html/index.js similarity index 86% rename from block-library/html/index.js rename to packages/block-library/src/html/index.js index ecb51907e6cf71..b5f858d537a93b 100644 --- a/block-library/html/index.js +++ b/packages/block-library/src/html/index.js @@ -3,16 +3,11 @@ */ import { RawHTML } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { Disabled, SandBox, CodeEditor } from '@wordpress/components'; +import { Disabled, SandBox } from '@wordpress/components'; import { getPhrasingContentSchema } from '@wordpress/blocks'; -import { BlockControls } from '@wordpress/editor'; +import { BlockControls, PlainText } from '@wordpress/editor'; import { withState } from '@wordpress/compose'; -/** - * Internal dependencies - */ -import './editor.scss'; - export const name = 'core/html'; export const settings = { @@ -63,7 +58,7 @@ export const settings = { edit: withState( { isPreview: false, - } )( ( { attributes, setAttributes, setState, isSelected, toggleSelection, isPreview } ) => ( + } )( ( { attributes, setAttributes, setState, isPreview } ) => (
@@ -86,11 +81,11 @@ export const settings = { ( isPreview || isDisabled ) ? ( ) : ( - setAttributes( { content } ) } + placeholder={ __( 'Write HTML…' ) } + aria-label={ __( 'HTML' ) } /> ) ) } diff --git a/packages/block-library/src/html/test/__snapshots__/index.js.snap b/packages/block-library/src/html/test/__snapshots__/index.js.snap new file mode 100644 index 00000000000000..5d35f054994fb2 --- /dev/null +++ b/packages/block-library/src/html/test/__snapshots__/index.js.snap @@ -0,0 +1,14 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`core/html block edit matches snapshot 1`] = ` +
+