From 4cead2718c85d069b60f42d166e4ce3e63a8c133 Mon Sep 17 00:00:00 2001
From: Riad Benguella
Date: Tue, 23 Oct 2018 14:42:37 +0100
Subject: [PATCH 1/7] Remove 4.2 deprecated features
---
components/code-editor/README.md | 88 -----------
components/code-editor/editor.js | 106 -------------
components/code-editor/index.js | 115 --------------
.../test/__snapshots__/editor.js.snap | 7 -
components/code-editor/test/editor.js | 24 ---
components/index.js | 5 -
lib/client-assets.php | 5 -
package-lock.json | 147 ------------------
package.json | 4 -
packages/blocks/src/api/index.js | 2 -
packages/blocks/src/api/index.native.js | 2 -
packages/blocks/src/api/parser.js | 24 +--
packages/blocks/src/api/registration.js | 30 ----
packages/blocks/src/api/test/registration.js | 25 ---
packages/blocks/src/store/actions.js | 22 ---
packages/blocks/src/store/selectors.js | 21 ---
.../components/src/primitives/svg/index.js | 15 --
packages/components/src/tab-panel/index.js | 10 +-
.../data/src/plugins/async-generator/index.js | 38 -----
.../src/plugins/async-generator/middleware.js | 102 ------------
packages/data/src/plugins/controls/index.js | 14 --
packages/data/src/plugins/index.js | 1 -
packages/data/src/registry.js | 3 +-
packages/data/src/test/registry.js | 89 -----------
.../hooks/components/media-upload/index.js | 21 +--
packages/edit-post/src/index.js | 18 +--
packages/edit-post/src/store/actions.js | 39 -----
packages/edit-post/src/store/selectors.js | 45 ------
.../edit-post/src/store/test/selectors.js | 48 ------
.../src/components/media-placeholder/index.js | 26 +---
.../unsaved-changes-warning/index.js | 19 +--
.../editor/src/utils/media-upload/index.js | 21 +--
.../src/utils/media-upload/media-upload.js | 4 -
webpack.config.js | 60 +------
34 files changed, 23 insertions(+), 1177 deletions(-)
delete mode 100644 components/code-editor/README.md
delete mode 100644 components/code-editor/editor.js
delete mode 100644 components/code-editor/index.js
delete mode 100644 components/code-editor/test/__snapshots__/editor.js.snap
delete mode 100644 components/code-editor/test/editor.js
delete mode 100644 components/index.js
delete mode 100644 packages/data/src/plugins/async-generator/index.js
delete mode 100644 packages/data/src/plugins/async-generator/middleware.js
diff --git a/components/code-editor/README.md b/components/code-editor/README.md
deleted file mode 100644
index c48c0545aa0b4..0000000000000
--- a/components/code-editor/README.md
+++ /dev/null
@@ -1,88 +0,0 @@
-CodeEditor
-=======
-
-CodeEditor is a React component that provides the user with a code editor
-that has syntax highlighting and linting.
-
-The components acts as a drop-in replacement for a
' }
- onChange={ value => console.log( value ) }
- />
- );
-}
-```
-
-## Props
-
-The component accepts the following props:
-
-### value
-
-The source code to load into the code editor.
-
-- Type: `string`
-- Required: Yes
-
-### focus
-
-Whether or not the code editor should be focused.
-
-- Type: `boolean`
-- Required: No
-
-### onFocus
-
-The function called when the editor is focused.
-
-- Type: `Function`
-- Required: No
-
-### onChange
-
-The function called when the user has modified the source code via the
-editor. It is passed the new value as an argument.
-
-- Type: `Function`
-- Required: No
-
-### settings
-
-The settings object used to initialize the WordPress code editor. The object contains all of the settings for the editor, including specific settings for CodeMirror. This object is passed into `wp.codeEditor.initialize()`. If you do not specify a settings object, `window._wpGutenbergCodeEditorSettings` will be used instead.
-
-If you are extending `window._wpGutenbergCodeEditorSettings` make sure to clone the object using `Object.assign` or something similar instead of modifying it directly so the default settings remain the same.
-
-```
-const settings = Object.assign( {
- codemirror: {
- mode: css,
- lint: false,
- } },
- window._wpGutenbergCodeEditorSetting
-);
-```
-
-- Type: `Object`
-- Required: No
-
-### editorRef
-
-A reference to the instance of CodeMirror initialized when the editor is loaded so that it can be dynamically updated from a parent component.
-
-`editorRef={ ( ref ) => this.editorInstance = ref }`
-
-`this.editorInstance` will contain a full instance of `CodeMirror` which can then be modified or updated from the component it is being reference from using the [CodeMirror API](https://codemirror.net/doc/manual.html#api). For example, to dynamically change the language mode of CodeMirror to CSS you can call:
-
-`this.editorInstance.setOption( 'mode', 'css' );`
-
-- Type `Function`
-- Required: No
diff --git a/components/code-editor/editor.js b/components/code-editor/editor.js
deleted file mode 100644
index 6d0f52b6427f2..0000000000000
--- a/components/code-editor/editor.js
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { Component } from '@wordpress/element';
-import { UP, DOWN } from '@wordpress/keycodes';
-
-class CodeEditor extends Component {
- constructor() {
- super( ...arguments );
-
- this.onFocus = this.onFocus.bind( this );
- this.onBlur = this.onBlur.bind( this );
- this.onCursorActivity = this.onCursorActivity.bind( this );
- this.onKeyHandled = this.onKeyHandled.bind( this );
- }
-
- componentDidMount() {
- const settings = this.props.settings || window._wpGutenbergCodeEditorSettings;
- const instance = wp.codeEditor.initialize( this.textarea, settings );
- this.editor = instance.codemirror;
-
- this.editor.on( 'focus', this.onFocus );
- this.editor.on( 'blur', this.onBlur );
- this.editor.on( 'cursorActivity', this.onCursorActivity );
- this.editor.on( 'keyHandled', this.onKeyHandled );
-
- // Pass a reference to the editor back up.
- if ( this.props.editorRef ) {
- this.props.editorRef( this.editor );
- }
-
- this.updateFocus();
- }
-
- componentDidUpdate( prevProps ) {
- if ( this.props.value !== prevProps.value && this.editor.getValue() !== this.props.value ) {
- this.editor.setValue( this.props.value );
- }
-
- if ( this.props.focus !== prevProps.focus ) {
- this.updateFocus();
- }
- }
-
- componentWillUnmount() {
- this.editor.on( 'focus', this.onFocus );
- this.editor.off( 'blur', this.onBlur );
- this.editor.off( 'cursorActivity', this.onCursorActivity );
- this.editor.off( 'keyHandled', this.onKeyHandled );
-
- this.editor.toTextArea();
- this.editor = null;
- }
-
- onFocus() {
- if ( this.props.onFocus ) {
- this.props.onFocus();
- }
- }
-
- onBlur( editor ) {
- if ( this.props.onChange ) {
- this.props.onChange( editor.getValue() );
- }
- }
-
- onCursorActivity( editor ) {
- this.lastCursor = editor.getCursor();
- }
-
- onKeyHandled( editor, name, event ) {
- /*
- * Pressing UP/DOWN should only move focus to another block if the cursor is
- * at the start or end of the editor.
- *
- * We do this by stopping UP/DOWN from propagating if:
- * - We know what the cursor was before this event; AND
- * - This event caused the cursor to move
- */
- if ( event.keyCode === UP || event.keyCode === DOWN ) {
- const areCursorsEqual = ( a, b ) => a.line === b.line && a.ch === b.ch;
- if ( this.lastCursor && ! areCursorsEqual( editor.getCursor(), this.lastCursor ) ) {
- event.stopImmediatePropagation();
- }
- }
- }
-
- updateFocus() {
- if ( this.props.focus && ! this.editor.hasFocus() ) {
- // Need to wait for the next frame to be painted before we can focus the editor
- window.requestAnimationFrame( () => {
- this.editor.focus();
- } );
- }
-
- if ( ! this.props.focus && this.editor.hasFocus() ) {
- document.activeElement.blur();
- }
- }
-
- render() {
- return