diff --git a/components/higher-order/with-constrained-tabbing/index.js b/components/higher-order/with-constrained-tabbing/index.js index 2b08ad981f8bb..8d1574e0a2019 100644 --- a/components/higher-order/with-constrained-tabbing/index.js +++ b/components/higher-order/with-constrained-tabbing/index.js @@ -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() { diff --git a/core-blocks/latest-posts/edit.js b/core-blocks/latest-posts/edit.js index 859b32f0a2b0d..3cc908799fd5e 100644 --- a/core-blocks/latest-posts/edit.js +++ b/core-blocks/latest-posts/edit.js @@ -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, diff --git a/docs/reference/deprecated.md b/docs/reference/deprecated.md index c3219f238cc9f..9a816ad4c5fea 100644 --- a/docs/reference/deprecated.md +++ b/docs/reference/deprecated.md @@ -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 diff --git a/editor/components/default-block-appender/index.js b/editor/components/default-block-appender/index.js index 9899a92c71346..3c07149a33530 100644 --- a/editor/components/default-block-appender/index.js +++ b/editor/components/default-block-appender/index.js @@ -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'; diff --git a/editor/components/post-text-editor/index.js b/editor/components/post-text-editor/index.js index bf700223da19c..4afadeae292ee 100644 --- a/editor/components/post-text-editor/index.js +++ b/editor/components/post-text-editor/index.js @@ -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'; diff --git a/editor/components/post-title/index.js b/editor/components/post-title/index.js index 6ef155b97a4c8..9aabcacd5fafa 100644 --- a/editor/components/post-title/index.js +++ b/editor/components/post-title/index.js @@ -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'; diff --git a/editor/components/url-input/index.js b/editor/components/url-input/index.js index ea1e4b56fd2ac..78527b600b3db 100644 --- a/editor/components/url-input/index.js +++ b/editor/components/url-input/index.js @@ -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'; diff --git a/lib/client-assets.php b/lib/client-assets.php index 89212a8240ee1..d2769721f7fa8 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -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' ), @@ -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' ), + array( 'lodash', 'wp-deprecated', 'wp-api-request', 'wp-html-entities', 'wp-i18n', 'wp-keycodes' ), filemtime( gutenberg_dir_path() . 'build/utils/index.js' ), true ); @@ -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 ); @@ -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 @@ -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', ), diff --git a/package-lock.json b/package-lock.json index e1926f8c0597e..6a3ae7804fd3c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3102,6 +3102,9 @@ "@wordpress/hooks": { "version": "file:packages/hooks" }, + "@wordpress/html-entities": { + "version": "file:packages/html-entities" + }, "@wordpress/i18n": { "version": "file:packages/i18n", "requires": { diff --git a/package.json b/package.json index 1d8fe5b76eda5..bfd8501b9e18a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/custom-templated-path-webpack-plugin/.npmrc b/packages/custom-templated-path-webpack-plugin/.npmrc new file mode 100644 index 0000000000000..43c97e719a5a8 --- /dev/null +++ b/packages/custom-templated-path-webpack-plugin/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/packages/html-entities/.npmrc b/packages/html-entities/.npmrc new file mode 100644 index 0000000000000..43c97e719a5a8 --- /dev/null +++ b/packages/html-entities/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/packages/html-entities/README.md b/packages/html-entities/README.md new file mode 100644 index 0000000000000..11f6e760994c9 --- /dev/null +++ b/packages/html-entities/README.md @@ -0,0 +1,13 @@ +# @wordpress/html-entities + +HTML entities utils for WordPress. + +## Installation + +Install the module + +```bash +npm install @wordpress/html-entities --save +``` + +

Code is Poetry.

diff --git a/packages/html-entities/package.json b/packages/html-entities/package.json new file mode 100644 index 0000000000000..23049d6f08f20 --- /dev/null +++ b/packages/html-entities/package.json @@ -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" + } +} diff --git a/utils/entities.js b/packages/html-entities/src/index.js similarity index 100% rename from utils/entities.js rename to packages/html-entities/src/index.js diff --git a/utils/test/entities.js b/packages/html-entities/src/test/entities.js similarity index 94% rename from utils/test/entities.js rename to packages/html-entities/src/test/entities.js index 8efd53196b289..37cabd1e059a2 100644 --- a/utils/test/entities.js +++ b/packages/html-entities/src/test/entities.js @@ -1,7 +1,7 @@ /** * Internal dependencies */ -import { decodeEntities } from '../entities'; +import { decodeEntities } from '../'; describe( 'decodeEntities', () => { it( 'should not change html with no entities', () => { diff --git a/packages/shortcode/.npmrc b/packages/shortcode/.npmrc new file mode 100644 index 0000000000000..43c97e719a5a8 --- /dev/null +++ b/packages/shortcode/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/packages/viewport/.npmrc b/packages/viewport/.npmrc new file mode 100644 index 0000000000000..43c97e719a5a8 --- /dev/null +++ b/packages/viewport/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/test/e2e/test-plugins/plugins-api.php b/test/e2e/test-plugins/plugins-api.php index a78ed2d770786..fcd9fb04b6a2f 100644 --- a/test/e2e/test-plugins/plugins-api.php +++ b/test/e2e/test-plugins/plugins-api.php @@ -38,6 +38,7 @@ plugins_url( 'plugins-api/sidebar.js', __FILE__ ), array( 'wp-components', + 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-editor', diff --git a/test/e2e/test-plugins/plugins-api/sidebar.js b/test/e2e/test-plugins/plugins-api/sidebar.js index 4f443ed3ecf7b..291e675e14171 100644 --- a/test/e2e/test-plugins/plugins-api/sidebar.js +++ b/test/e2e/test-plugins/plugins-api/sidebar.js @@ -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; diff --git a/utils/deprecated.js b/utils/deprecated.js index f02e8a2f60171..9633fb1e88964 100644 --- a/utils/deprecated.js +++ b/utils/deprecated.js @@ -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. @@ -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 }`, { diff --git a/utils/index.js b/utils/index.js index 9c43c10bf4504..c96efed8801f9 100644 --- a/utils/index.js +++ b/utils/index.js @@ -1,10 +1,3 @@ -/** - * Internal dependencies - */ -import { decodeEntities } from './entities'; - -export { decodeEntities }; - export * from './mediaupload'; // Deprecations diff --git a/webpack.config.js b/webpack.config.js index 1c24cd7cad30e..7ad43d44b5582 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -159,6 +159,7 @@ const gutenbergPackages = [ 'dom-ready', 'element', 'hooks', + 'html-entities', 'i18n', 'is-shallow-equal', 'keycodes',