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

Move the HTML block into the blocks library package #10396

Merged
merged 3 commits into from Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion bin/build-plugin-zip.sh
Expand Up @@ -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 \
Expand Down
3 changes: 0 additions & 3 deletions bin/get-server-blocks.php
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion block-library/editor.scss

This file was deleted.

25 changes: 0 additions & 25 deletions block-library/html/editor.scss

This file was deleted.

22 changes: 0 additions & 22 deletions block-library/html/test/__snapshots__/index.js.snap

This file was deleted.

103 changes: 0 additions & 103 deletions block-library/index.js

This file was deleted.

4 changes: 0 additions & 4 deletions block-library/index.native.js

This file was deleted.

1 change: 0 additions & 1 deletion block-library/style.scss

This file was deleted.

1 change: 0 additions & 1 deletion block-library/theme.scss

This file was deleted.

6 changes: 6 additions & 0 deletions components/code-editor/index.js
Expand Up @@ -3,6 +3,7 @@
*/
import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down Expand Up @@ -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',
Copy link
Member

Choose a reason for hiding this comment

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

This is going to be confusing in the context of npm package which is out of WordPress context. Not sure if this is bad or not, just noting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, we have a bunch of those and we need to experiment with making the messages opt-in or something and only enable in WP

} );
}

componentDidMount() {
Expand Down
1 change: 1 addition & 0 deletions docs/reference/deprecated.md
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/client-assets.php
Expand Up @@ -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' );

Expand Down
7 changes: 7 additions & 0 deletions 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
Expand Down
Expand Up @@ -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:
// <p><br data-mce-bogus="1"></p>
Expand All @@ -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 );
Expand Down Expand Up @@ -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 }
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -3,7 +3,7 @@
exports[`core/freeform block edit matches snapshot 1`] = `
Array [
<div
class="freeform-toolbar"
class="block-library-classic__toolbar"
data-placeholder="Classic"
id="toolbar-undefined"
/>,
Expand Down
Expand Up @@ -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', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/editor.scss
Expand Up @@ -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";
Expand Down
12 changes: 12 additions & 0 deletions 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;
}
}
Expand Up @@ -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 = {
Expand Down Expand Up @@ -63,7 +58,7 @@ export const settings = {

edit: withState( {
isPreview: false,
} )( ( { attributes, setAttributes, setState, isSelected, toggleSelection, isPreview } ) => (
} )( ( { attributes, setAttributes, setState, isPreview } ) => (
<div className="wp-block-html">
<BlockControls>
<div className="components-toolbar">
Expand All @@ -86,11 +81,11 @@ export const settings = {
( isPreview || isDisabled ) ? (
<SandBox html={ attributes.content } />
) : (
<CodeEditor
<PlainText
value={ attributes.content }
focus={ isSelected }
onFocus={ toggleSelection }
onChange={ ( content ) => setAttributes( { content } ) }
placeholder={ __( 'Write HTML…' ) }
aria-label={ __( 'HTML' ) }
/>
)
) }
Expand Down
14 changes: 14 additions & 0 deletions 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`] = `
<div
class="wp-block-html"
>
<textarea
aria-label="HTML"
class="editor-plain-text"
placeholder="Write HTML…"
rows="1"
/>
</div>
`;
Expand Up @@ -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/html', () => {
test( 'block edit matches snapshot', () => {
Expand Down