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

Packages: Extract entities package #7977

Merged
merged 4 commits into from
Jul 16, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions components/higher-order/with-constrained-tabbing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
*/
import { Component, createRef } from '@wordpress/element';
import { createHigherOrderComponent } from '@wordpress/compose';
import { keycodes } from '@wordpress/utils';
import { TAB } from '@wordpress/keycodes';
import { focus } from '@wordpress/dom';

const { TAB } = keycodes;

const withConstrainedTabbing = createHigherOrderComponent(
( WrappedComponent ) => class extends Component {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion core-blocks/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
withAPIData,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/utils';
import { decodeEntities } from '@wordpress/html-entities';
import {
InspectorControls,
BlockAlignmentToolbar,
Expand Down
1 change: 1 addition & 0 deletions docs/reference/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo
- `wp.element.compose` has been removed. Please use `wp.compose.compose` instead.
- `wp.element.createHigherOrderComponent` has been removed. Please use `wp.compose.createHigherOrderComponent` instead.
- `wp.utils.buildTermsTree` has been removed.
- `wp.utils.decodeEntities` has been removed. Please use `wp.htmlEntities.decodeEntities` instead.

## 3.4.0

Expand Down
2 changes: 1 addition & 1 deletion editor/components/default-block-appender/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { get } from 'lodash';
import { __ } from '@wordpress/i18n';
import { compose } from '@wordpress/compose';
import { getDefaultBlockName } from '@wordpress/blocks';
import { decodeEntities } from '@wordpress/utils';
import { decodeEntities } from '@wordpress/html-entities';
import { withSelect, withDispatch } from '@wordpress/data';
import { DotTip } from '@wordpress/nux';

Expand Down
2 changes: 1 addition & 1 deletion editor/components/post-text-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Textarea from 'react-autosize-textarea';
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/utils';
import { decodeEntities } from '@wordpress/html-entities';
import { Component, Fragment } from '@wordpress/element';
import { parse } from '@wordpress/blocks';
import { withSelect, withDispatch } from '@wordpress/data';
Expand Down
2 changes: 1 addition & 1 deletion editor/components/post-title/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { get } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { decodeEntities } from '@wordpress/utils';
import { decodeEntities } from '@wordpress/html-entities';
import { ENTER } from '@wordpress/keycodes';
import { withSelect, withDispatch } from '@wordpress/data';
import { KeyboardShortcuts, withFocusOutside } from '@wordpress/components';
Expand Down
2 changes: 1 addition & 1 deletion editor/components/url-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { stringify } from 'querystringify';
*/
import { __, sprintf, _n } from '@wordpress/i18n';
import { Component, Fragment } from '@wordpress/element';
import { decodeEntities } from '@wordpress/utils';
import { decodeEntities } from '@wordpress/html-entities';
import { UP, DOWN, ENTER } from '@wordpress/keycodes';
import { Spinner, withSpokenMessages, Popover } from '@wordpress/components';
import apiRequest from '@wordpress/api-request';
Expand Down
15 changes: 11 additions & 4 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ function gutenberg_register_scripts_and_styles() {
filemtime( gutenberg_dir_path() . 'build/keycodes/index.js' ),
true
);
wp_register_script(
'wp-html-entities',
gutenberg_url( 'build/html-entities/index.js' ),
array(),
filemtime( gutenberg_dir_path() . 'build/html-entities/index.js' ),
true
);
wp_register_script(
'wp-data',
gutenberg_url( 'build/data/index.js' ),
Expand Down Expand Up @@ -199,7 +206,7 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-utils',
gutenberg_url( 'build/utils/index.js' ),
array( 'lodash', 'wp-blob', 'wp-deprecated', 'wp-api-request', 'wp-i18n', 'wp-keycodes' ),
Copy link
Member

Choose a reason for hiding this comment

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

Why is blob removed here? Is that intentional/related to this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be removed in one of the previous PRs, it's no longer used inside.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot to mention. Sorry about it.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, just wasn't sure it was related. 👍

array( 'lodash', 'wp-deprecated', 'wp-api-request', 'wp-html-entities', 'wp-i18n', 'wp-keycodes' ),
filemtime( gutenberg_dir_path() . 'build/utils/index.js' ),
true
);
Expand Down Expand Up @@ -248,7 +255,7 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-element',
gutenberg_url( 'build/element/index.js' ),
array( 'react', 'react-dom', 'wp-utils', 'wp-is-shallow-equal', 'lodash' ),
array( 'react', 'react-dom', 'wp-is-shallow-equal', 'lodash' ),
filemtime( gutenberg_dir_path() . 'build/element/index.js' ),
true
);
Expand All @@ -263,11 +270,11 @@ function gutenberg_register_scripts_and_styles() {
'wp-compose',
'wp-dom',
'wp-element',
'wp-html-entities',
'wp-hooks',
'wp-i18n',
'wp-is-shallow-equal',
'wp-keycodes',
'wp-utils',
),
filemtime( gutenberg_dir_path() . 'build/components/index.js' ),
true
Expand Down Expand Up @@ -307,9 +314,9 @@ function gutenberg_register_scripts_and_styles() {
'wp-core-data',
'wp-element',
'wp-editor',
'wp-html-entities',
'wp-i18n',
'wp-keycodes',
'wp-utils',
'wp-viewport',
'wp-api-request',
),
Expand Down
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@wordpress/dom": "file:packages/dom",
"@wordpress/dom-ready": "file:packages/dom-ready",
"@wordpress/element": "file:packages/element",
"@wordpress/html-entities": "file:packages/html-entities",
"@wordpress/hooks": "file:packages/hooks",
"@wordpress/i18n": "file:packages/i18n",
"@wordpress/is-shallow-equal": "file:packages/is-shallow-equal",
Expand Down
1 change: 1 addition & 0 deletions packages/custom-templated-path-webpack-plugin/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
1 change: 1 addition & 0 deletions packages/html-entities/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
13 changes: 13 additions & 0 deletions packages/html-entities/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @wordpress/html-entities

HTML entities utils for WordPress.

## Installation

Install the module

```bash
npm install @wordpress/html-entities --save
```

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
25 changes: 25 additions & 0 deletions packages/html-entities/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@wordpress/html-entities",
"version": "1.0.0-alpha.3",
"description": "HTML entities utils for WordPress",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"keywords": [
"wordpress",
"html",
"entities"
],
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/html-entities/README.md",
"repository": {
"type": "git",
"url": "https://github.com/WordPress/gutenberg.git"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
},
"main": "build/index.js",
"module": "build-module/index.js",
"publishConfig": {
"access": "public"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { decodeEntities } from '../entities';
import { decodeEntities } from '../';

describe( 'decodeEntities', () => {
it( 'should not change html with no entities', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/shortcode/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
1 change: 1 addition & 0 deletions packages/viewport/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
1 change: 1 addition & 0 deletions test/e2e/test-plugins/plugins-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
plugins_url( 'plugins-api/sidebar.js', __FILE__ ),
array(
'wp-components',
'wp-compose',
'wp-data',
'wp-edit-post',
'wp-editor',
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test-plugins/plugins-api/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var Button = wp.components.Button;
var PanelBody = wp.components.PanelBody;
var PanelRow = wp.components.PanelRow;
var compose = wp.compose.compose;
var withDispatch = wp.data.withDispatch;
var withSelect = wp.data.withSelect;
var PlainText = wp.editor.PlainText;
var Fragment = wp.element.Fragment;
var compose = wp.element.compose;
var el = wp.element.createElement;
var __ = wp.i18n.__;
var registerPlugin = wp.plugins.registerPlugin;
Expand Down
21 changes: 16 additions & 5 deletions utils/deprecated.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/**
* WordPress dependencies
* External dependencies
*/
import * as keycodesSource from '@wordpress/keycodes';
import deprecated from '@wordpress/deprecated';
import { groupBy } from 'lodash';

/**
* External dependencies
* WordPress dependencies
*/
import { groupBy } from 'lodash';
import * as keycodesSource from '@wordpress/keycodes';
import { decodeEntities as decodeEntitiesSource } from '@wordpress/html-entities';
import deprecated from '@wordpress/deprecated';

/**
* Returns terms in a tree form.
Expand Down Expand Up @@ -37,6 +38,16 @@ export function buildTermsTree( flatTerms ) {
return fillWithChildren( termsByParent[ '0' ] || [] );
}

// entities
export function decodeEntities( html ) {
deprecated( 'wp.utils.decodeEntities', {
version: '3.5',
alternative: 'wp.htmlEntities.decodeEntities',
plugin: 'Gutenberg',
} );
return decodeEntitiesSource( html );
}

// keycodes
const wrapKeycodeFunction = ( source, functionName ) => ( ...args ) => {
deprecated( `wp.utils.keycodes.${ functionName }`, {
Expand Down
7 changes: 0 additions & 7 deletions utils/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/**
* Internal dependencies
*/
import { decodeEntities } from './entities';

export { decodeEntities };

export * from './mediaupload';

// Deprecations
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const gutenbergPackages = [
'dom-ready',
'element',
'hooks',
'html-entities',
'i18n',
'is-shallow-equal',
'keycodes',
Expand Down