From f5852b98d160d42d81423252f9538ff4aaa1525b Mon Sep 17 00:00:00 2001
From: Robert Anderson my text my text my text ` tags with two line breaks. "Opposite" of autop().
+
+Replaces ` ` tags with two line breaks except where the ` ` has attributes.
+Unifies whitespace. Indents ` my text my text my text
+ Child
+ currently ) ) .
+ // Fix for heading issue is to skip reset of html variable if tag is heading and platform is Android.
+ // This fix will intentionally introduce original issue with placeholder (on Android)
+ // which has lower priority then heading issue .
+ // New issue is raised : https://github.com/wordpress-mobile/gutenberg-mobile/issues/707
+ if ( ! sendEmptyTag ) {
+ html = '';
+ }
+
this.lastEventCount = undefined; // force a refresh on the native side
}
let minHeight = 0;
From 8f82fd30315a7bec4054fbd2de7e6fdd29b459c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9rgio=20Est=C3=AAv=C3=A3o?=
diff --git a/packages/a11y/package.json b/packages/a11y/package.json
index 975ab31b994b3..bd564572960a6 100644
--- a/packages/a11y/package.json
+++ b/packages/a11y/package.json
@@ -1,6 +1,6 @@
{
"name": "@wordpress/a11y",
- "version": "2.0.2",
+ "version": "2.1.0",
"description": "Accessibility (a11y) utilities for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
@@ -12,7 +12,8 @@
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/a11y/README.md",
"repository": {
"type": "git",
- "url": "https://github.com/WordPress/gutenberg.git"
+ "url": "https://github.com/WordPress/gutenberg.git",
+ "directory": "packages/a11y"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
diff --git a/packages/a11y/src/index.js b/packages/a11y/src/index.js
index e082e15ca6fb7..525ea63b87968 100644
--- a/packages/a11y/src/index.js
+++ b/packages/a11y/src/index.js
@@ -31,11 +31,23 @@ export const setup = function() {
domReady( setup );
/**
- * Update the ARIA live notification area text node.
+ * Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions.
+ * This module is inspired by the `speak` function in wp-a11y.js
*
* @param {string} message The message to be announced by Assistive Technologies.
* @param {string} ariaLive Optional. The politeness level for aria-live. Possible values:
* polite or assertive. Default polite.
+ *
+ * @example
+ * ```js
+ * import { speak } from '@wordpress/a11y';
+ *
+ * // For polite messages that shouldn't interrupt what screen readers are currently announcing.
+ * speak( 'The message you want to send to the ARIA live region' );
+ *
+ * // For assertive messages that should interrupt what screen readers are currently announcing.
+ * speak( 'The message you want to send to the ARIA live region', 'assertive' );
+ * ```
*/
export const speak = function( message, ariaLive ) {
// Clear previous messages to allow repeated strings being read out.
diff --git a/packages/annotations/package.json b/packages/annotations/package.json
index ebbc0b39ca84f..34c055841844f 100644
--- a/packages/annotations/package.json
+++ b/packages/annotations/package.json
@@ -1,6 +1,6 @@
{
"name": "@wordpress/annotations",
- "version": "1.0.8",
+ "version": "1.1.0",
"description": "Annotate content in the Gutenberg editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
@@ -11,7 +11,8 @@
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/annotations/README.md",
"repository": {
"type": "git",
- "url": "https://github.com/WordPress/gutenberg.git"
+ "url": "https://github.com/WordPress/gutenberg.git",
+ "directory": "packages/annotations"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
diff --git a/packages/api-fetch/CHANGELOG.md b/packages/api-fetch/CHANGELOG.md
index 1727529b88366..dc7dcdeb3defe 100644
--- a/packages/api-fetch/CHANGELOG.md
+++ b/packages/api-fetch/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 3.0.0 (Unreleased)
+## 3.0.0 (2019-03-06)
### Breaking Changes
diff --git a/packages/api-fetch/package.json b/packages/api-fetch/package.json
index 8f9b6568013a7..67f99e6907d7a 100644
--- a/packages/api-fetch/package.json
+++ b/packages/api-fetch/package.json
@@ -1,6 +1,6 @@
{
"name": "@wordpress/api-fetch",
- "version": "2.2.8",
+ "version": "3.0.0",
"description": "Utility to make WordPress REST API requests.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
@@ -12,7 +12,8 @@
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/api-fetch/README.md",
"repository": {
"type": "git",
- "url": "https://github.com/WordPress/gutenberg.git"
+ "url": "https://github.com/WordPress/gutenberg.git",
+ "directory": "packages/api-fetch"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
diff --git a/packages/autop/CHANGELOG.md b/packages/autop/CHANGELOG.md
index 184ca54078a38..53373272a2459 100644
--- a/packages/autop/CHANGELOG.md
+++ b/packages/autop/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 2.0.1 (Unreleased)
+## 2.1.0 (2019-03-06)
### Bug Fix
diff --git a/packages/autop/README.md b/packages/autop/README.md
index 4aecd9cafa3de..ffb9168b63f20 100644
--- a/packages/autop/README.md
+++ b/packages/autop/README.md
@@ -12,23 +12,61 @@ npm install @wordpress/autop --save
_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._
-### Usage
+### API
-Import the desired function(s) from `@wordpress/autop`:
+
+
+#### autop
+
+[src/index.js#L129-L285](src/index.js#L129-L285)
+
+Replaces double line-breaks with paragraph elements.
+
+A group of regex replaces used to identify text formatted with newlines and
+replace double line-breaks with HTML paragraph tags. The remaining line-
+breaks after conversion become `
` tags, unless br is set to 'false'.
+
+**Usage**
```js
-import { autop, removep } from '@wordpress/autop';
+import { autop } from '@wordpress/autop';
+autop( 'my text' ); // "
diff --git a/packages/autop/package.json b/packages/autop/package.json
index 9735d5475aac5..4f1441ff2024f 100644
--- a/packages/autop/package.json
+++ b/packages/autop/package.json
@@ -1,6 +1,6 @@
{
"name": "@wordpress/autop",
- "version": "2.0.2",
+ "version": "2.1.0",
"description": "WordPress's automatic paragraph functions `autop` and `removep`.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
@@ -11,7 +11,8 @@
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/autop/README.md",
"repository": {
"type": "git",
- "url": "https://github.com/WordPress/gutenberg.git"
+ "url": "https://github.com/WordPress/gutenberg.git",
+ "directory": "packages/autop"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
diff --git a/packages/autop/src/index.js b/packages/autop/src/index.js
index 916f56a4be5f2..809a66b412d69 100644
--- a/packages/autop/src/index.js
+++ b/packages/autop/src/index.js
@@ -117,6 +117,13 @@ function replaceInHtmlTags( haystack, replacePairs ) {
* @param {string} text The text which has to be formatted.
* @param {boolean} br Optional. If set, will convert all remaining line-
* breaks after paragraphing. Default true.
+ *
+ * @example
+ *```js
+ * import { autop } from '@wordpress/autop';
+ * autop( 'my text' ); // "
diff --git a/packages/blob/package.json b/packages/blob/package.json
index f8c08ee648276..a4032f11d80d5 100644
--- a/packages/blob/package.json
+++ b/packages/blob/package.json
@@ -1,6 +1,6 @@
{
"name": "@wordpress/blob",
- "version": "2.1.0",
+ "version": "2.2.0",
"description": "Blob utilities for WordPress.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
@@ -11,7 +11,8 @@
"homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/blob/README.md",
"repository": {
"type": "git",
- "url": "https://github.com/WordPress/gutenberg.git"
+ "url": "https://github.com/WordPress/gutenberg.git",
+ "directory": "packages/blob"
},
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
diff --git a/packages/block-editor/.npmrc b/packages/block-editor/.npmrc
new file mode 100644
index 0000000000000..43c97e719a5a8
--- /dev/null
+++ b/packages/block-editor/.npmrc
@@ -0,0 +1 @@
+package-lock=false
diff --git a/packages/block-editor/CHANGELOG.md b/packages/block-editor/CHANGELOG.md
new file mode 100644
index 0000000000000..5c4cae61450ac
--- /dev/null
+++ b/packages/block-editor/CHANGELOG.md
@@ -0,0 +1,5 @@
+## 1.0.0 (2019-03-06)
+
+### New Features
+
+- Initial version.
diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md
new file mode 100644
index 0000000000000..b626857134ee3
--- /dev/null
+++ b/packages/block-editor/README.md
@@ -0,0 +1,486 @@
+# Block Editor
+
+Generic block editor module.
+
+## Installation
+
+Install the module
+
+```bash
+npm install @wordpress/block-editor --save
+```
+
+_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._
+
+## API
+
+
+
+### AlignmentToolbar
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### Autocomplete
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockAlignmentToolbar
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockControls
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockEdit
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockEditorKeyboardShortcuts
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockEditorProvider
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockFormatControls
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockIcon
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockInspector
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockList
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockMover
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockNavigationDropdown
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockSelectionClearer
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockSettingsMenu
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockTitle
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### BlockToolbar
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### ColorPalette
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### ContrastChecker
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### CopyHandler
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### createCustomColorsHOC
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic
+for class generation color value, retrieval and color attribute setting.
+
+Use this higher-order component to work with a custom set of colors.
+
+**Usage**
+
+```jsx
+const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];
+const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );
+// ...
+export default compose(
+ withCustomColors( 'backgroundColor', 'borderColor' ),
+ MyColorfulComponent,
+);
+```
+
+**Parameters**
+
+- **colorsArray** `Array`: The array of color objects (name, slug, color, etc... ).
+
+**Returns**
+
+`Function`: Higher-order component.
+
+### DefaultBlockAppender
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### FontSizePicker
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### getColorClassName
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Returns a class based on the context a color is being used and its slug.
+
+**Parameters**
+
+- **colorContextName** `string`: Context/place where color is being used e.g: background, text etc...
+- **colorSlug** `string`: Slug of the color.
+
+**Returns**
+
+`string`: String with the class corresponding to the color in the provided context.
+
+### getColorObjectByAttributeValues
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Provided an array of color objects as set by the theme or by the editor defaults,
+and the values of the defined color or custom color returns a color object describing the color.
+
+**Parameters**
+
+- **colors** `Array`: Array of color objects as set by the theme or by the editor defaults.
+- **definedColor** `?string`: A string containing the color slug.
+- **customColor** `?string`: A string containing the customColor value.
+
+**Returns**
+
+`?string`: If definedColor is passed and the name is found in colors, the color object exactly as set by the theme or editor defaults is returned. Otherwise, an object that just sets the color is defined.
+
+### getColorObjectByColorValue
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Provided an array of color objects as set by the theme or by the editor defaults, and a color value returns the color object matching that value or undefined.
+
+**Parameters**
+
+- **colors** `Array`: Array of color objects as set by the theme or by the editor defaults.
+- **colorValue** `?string`: A string containing the color value.
+
+**Returns**
+
+`?string`: Returns the color object included in the colors array whose color property equals colorValue. Returns undefined if no color object matches this requirement.
+
+### getFontSize
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values.
+ If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned.
+
+**Parameters**
+
+- **fontSizes** `Array`: Array of font size objects containing at least the "name" and "size" values as properties.
+- **fontSizeAttribute** `?string`: Content of the font size attribute (slug).
+- **customFontSizeAttribute** `?number`: Contents of the custom font size attribute (value).
+
+**Returns**
+
+`?string`: If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug. Otherwise, an object with just the size value based on customFontSize is returned.
+
+### getFontSizeClass
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Returns a class based on fontSizeName.
+
+**Parameters**
+
+- **fontSizeSlug** `string`: Slug of the fontSize.
+
+**Returns**
+
+`string`: String with the class corresponding to the fontSize passed. The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.
+
+### InnerBlocks
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### Inserter
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### InspectorAdvancedControls
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### InspectorControls
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### MediaPlaceholder
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### MediaUpload
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### MediaUploadCheck
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### MultiBlocksSwitcher
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### MultiSelectScrollIntoView
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### NavigableToolbar
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### ObserveTyping
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### PanelColorSettings
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### PlainText
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### PreserveScrollInReorder
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### RichText
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### RichTextShortcut
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### RichTextToolbarButton
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### SETTINGS_DEFAULTS
+
+[src/index.js#L18-L18](src/index.js#L18-L18)
+
+The default editor settings
+
+ alignWide boolean Enable/Disable Wide/Full Alignments
+ availableLegacyWidgets Array Array of objects representing the legacy widgets available.
+ colors Array Palette colors
+ disableCustomColors boolean Whether or not the custom colors are disabled
+ fontSizes Array Available font sizes
+ disableCustomFontSizes boolean Whether or not the custom font sizes are disabled
+ imageSizes Array Available image sizes
+ maxWidth number Max width to constraint resizing
+ allowedBlockTypes boolean|Array Allowed block types
+ hasFixedToolbar boolean Whether or not the editor toolbar is fixed
+ hasPermissionsToManageWidgets boolean Whether or not the user is able to manage widgets.
+ focusMode boolean Whether the focus mode is enabled or not
+ styles Array Editor Styles
+ isRTL boolean Whether the editor is in RTL mode
+ bodyPlaceholder string Empty post placeholder
+ titlePlaceholder string Empty title placeholder
+
+### SkipToSelectedBlock
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### UnstableRichTextInputEvent
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### URLInput
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### URLInputButton
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### URLPopover
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### Warning
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### withColorContext
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### withColors
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.
+
+For use with the default editor/theme color palette.
+
+**Usage**
+
+```jsx
+export default compose(
+ withColors( 'backgroundColor', { textColor: 'color' } ),
+ MyColorfulComponent,
+);
+```
+
+**Parameters**
+
+- **colorTypes** `...(object|string)`: The arguments can be strings or objects. If the argument is an object, it should contain the color attribute name as key and the color context as value. If the argument is a string the value should be the color attribute name, the color context is computed by applying a kebab case transform to the value. Color context represents the context/place where the color is going to be used. The class name of the color is generated using 'has' followed by the color name and ending with the color context all in kebab case e.g: has-green-background-color.
+
+**Returns**
+
+`Function`: Higher-order component.
+
+### withFontSizes
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Higher-order component, which handles font size logic for class generation,
+font size value retrieval, and font size change handling.
+
+**Parameters**
+
+- **args** `...(object|string)`: The arguments should all be strings Each string contains the font size attribute name e.g: 'fontSize'.
+
+**Returns**
+
+`Function`: Higher-order component.
+
+### WritingFlow
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### \_BlockSettingsMenuFirstItem
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+### \_BlockSettingsMenuPluginsExtension
+
+[src/index.js#L16-L16](src/index.js#L16-L16)
+
+Undocumented declaration.
+
+
+
+
+
diff --git a/packages/block-editor/package.json b/packages/block-editor/package.json
new file mode 100644
index 0000000000000..b6f19c50b0f15
--- /dev/null
+++ b/packages/block-editor/package.json
@@ -0,0 +1,56 @@
+{
+ "name": "@wordpress/block-editor",
+ "version": "1.0.0",
+ "description": "Generic block editor.",
+ "author": "The WordPress Contributors",
+ "license": "GPL-2.0-or-later",
+ "keywords": [
+ "wordpress",
+ "editor",
+ "blocks"
+ ],
+ "homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/block-editor/README.md",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/WordPress/gutenberg.git",
+ "directory": "packages/block-editor"
+ },
+ "bugs": {
+ "url": "https://github.com/WordPress/gutenberg/issues"
+ },
+ "main": "build/index.js",
+ "module": "build-module/index.js",
+ "react-native": "src/index",
+ "dependencies": {
+ "@babel/runtime": "^7.0.0",
+ "@wordpress/a11y": "file:../a11y",
+ "@wordpress/blob": "file:../blob",
+ "@wordpress/blocks": "file:../blocks",
+ "@wordpress/components": "file:../components",
+ "@wordpress/compose": "file:../compose",
+ "@wordpress/core-data": "file:../core-data",
+ "@wordpress/data": "file:../data",
+ "@wordpress/dom": "file:../dom",
+ "@wordpress/element": "file:../element",
+ "@wordpress/hooks": "file:../hooks",
+ "@wordpress/html-entities": "file:../html-entities",
+ "@wordpress/i18n": "file:../i18n",
+ "@wordpress/is-shallow-equal": "file:../is-shallow-equal",
+ "@wordpress/keycodes": "file:../keycodes",
+ "@wordpress/rich-text": "file:../rich-text",
+ "@wordpress/token-list": "file:../token-list",
+ "@wordpress/url": "file:../url",
+ "@wordpress/viewport": "file:../viewport",
+ "@wordpress/wordcount": "file:../wordcount",
+ "classnames": "^2.2.5",
+ "dom-scroll-into-view": "^1.2.1",
+ "lodash": "^4.17.10",
+ "redux-multi": "^0.1.12",
+ "refx": "^3.0.0",
+ "rememo": "^3.0.0",
+ "tinycolor2": "^1.4.1"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/packages/editor/src/components/alignment-toolbar/index.js b/packages/block-editor/src/components/alignment-toolbar/index.js
similarity index 93%
rename from packages/editor/src/components/alignment-toolbar/index.js
rename to packages/block-editor/src/components/alignment-toolbar/index.js
index e06ee34f4d7d6..1124f44f033e1 100644
--- a/packages/editor/src/components/alignment-toolbar/index.js
+++ b/packages/block-editor/src/components/alignment-toolbar/index.js
@@ -69,10 +69,10 @@ export default compose(
} ),
withViewportMatch( { isLargeViewport: 'medium' } ),
withSelect( ( select, { clientId, isLargeViewport, isCollapsed } ) => {
- const { getBlockRootClientId, getEditorSettings } = select( 'core/editor' );
+ const { getBlockRootClientId, getSettings } = select( 'core/block-editor' );
return {
isCollapsed: isCollapsed || ! isLargeViewport || (
- ! getEditorSettings().hasFixedToolbar &&
+ ! getSettings().hasFixedToolbar &&
getBlockRootClientId( clientId )
),
};
diff --git a/packages/editor/src/components/alignment-toolbar/test/__snapshots__/index.js.snap b/packages/block-editor/src/components/alignment-toolbar/test/__snapshots__/index.js.snap
similarity index 100%
rename from packages/editor/src/components/alignment-toolbar/test/__snapshots__/index.js.snap
rename to packages/block-editor/src/components/alignment-toolbar/test/__snapshots__/index.js.snap
diff --git a/packages/editor/src/components/alignment-toolbar/test/index.js b/packages/block-editor/src/components/alignment-toolbar/test/index.js
similarity index 100%
rename from packages/editor/src/components/alignment-toolbar/test/index.js
rename to packages/block-editor/src/components/alignment-toolbar/test/index.js
diff --git a/packages/editor/src/components/autocomplete/README.md b/packages/block-editor/src/components/autocomplete/README.md
similarity index 100%
rename from packages/editor/src/components/autocomplete/README.md
rename to packages/block-editor/src/components/autocomplete/README.md
diff --git a/packages/editor/src/components/autocomplete/index.js b/packages/block-editor/src/components/autocomplete/index.js
similarity index 100%
rename from packages/editor/src/components/autocomplete/index.js
rename to packages/block-editor/src/components/autocomplete/index.js
diff --git a/packages/editor/src/components/autocomplete/test/index.js b/packages/block-editor/src/components/autocomplete/test/index.js
similarity index 100%
rename from packages/editor/src/components/autocomplete/test/index.js
rename to packages/block-editor/src/components/autocomplete/test/index.js
diff --git a/packages/editor/src/components/block-actions/index.js b/packages/block-editor/src/components/block-actions/index.js
similarity index 90%
rename from packages/editor/src/components/block-actions/index.js
rename to packages/block-editor/src/components/block-actions/index.js
index b90325b0affd5..3b3f8032432e8 100644
--- a/packages/editor/src/components/block-actions/index.js
+++ b/packages/block-editor/src/components/block-actions/index.js
@@ -35,7 +35,7 @@ export default compose( [
getBlocksByClientId,
getTemplateLock,
getBlockRootClientId,
- } = select( 'core/editor' );
+ } = select( 'core/block-editor' );
const blocks = getBlocksByClientId( props.clientIds );
const canDuplicate = every( blocks, ( block ) => {
@@ -65,7 +65,7 @@ export default compose( [
multiSelect,
removeBlocks,
insertDefaultBlock,
- } = dispatch( 'core/editor' );
+ } = dispatch( 'core/block-editor' );
return {
onDuplicate() {
@@ -73,7 +73,7 @@ export default compose( [
return;
}
- const { getBlockIndex } = select( 'core/editor' );
+ const { getBlockIndex } = select( 'core/block-editor' );
const lastSelectedIndex = getBlockIndex( last( castArray( clientIds ) ), rootClientId );
const clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );
insertBlocks(
@@ -95,14 +95,14 @@ export default compose( [
},
onInsertBefore() {
if ( ! isLocked ) {
- const { getBlockIndex } = select( 'core/editor' );
+ const { getBlockIndex } = select( 'core/block-editor' );
const firstSelectedIndex = getBlockIndex( first( castArray( clientIds ) ), rootClientId );
insertDefaultBlock( {}, rootClientId, firstSelectedIndex );
}
},
onInsertAfter() {
if ( ! isLocked ) {
- const { getBlockIndex } = select( 'core/editor' );
+ const { getBlockIndex } = select( 'core/block-editor' );
const lastSelectedIndex = getBlockIndex( last( castArray( clientIds ) ), rootClientId );
insertDefaultBlock( {}, rootClientId, lastSelectedIndex + 1 );
}
diff --git a/packages/editor/src/components/block-alignment-toolbar/index.js b/packages/block-editor/src/components/block-alignment-toolbar/index.js
similarity index 90%
rename from packages/editor/src/components/block-alignment-toolbar/index.js
rename to packages/block-editor/src/components/block-alignment-toolbar/index.js
index acfe1cb4ed344..adf02cd90b08b 100644
--- a/packages/editor/src/components/block-alignment-toolbar/index.js
+++ b/packages/block-editor/src/components/block-alignment-toolbar/index.js
@@ -75,11 +75,12 @@ export default compose(
} ),
withViewportMatch( { isLargeViewport: 'medium' } ),
withSelect( ( select, { clientId, isLargeViewport, isCollapsed } ) => {
- const { getBlockRootClientId, getEditorSettings } = select( 'core/editor' );
+ const { getBlockRootClientId, getSettings } = select( 'core/block-editor' );
+ const settings = getSettings();
return {
- wideControlsEnabled: select( 'core/editor' ).getEditorSettings().alignWide,
+ wideControlsEnabled: settings.alignWide,
isCollapsed: isCollapsed || ! isLargeViewport || (
- ! getEditorSettings().hasFixedToolbar &&
+ ! settings.hasFixedToolbar &&
getBlockRootClientId( clientId )
),
};
diff --git a/packages/editor/src/components/block-alignment-toolbar/test/__snapshots__/index.js.snap b/packages/block-editor/src/components/block-alignment-toolbar/test/__snapshots__/index.js.snap
similarity index 100%
rename from packages/editor/src/components/block-alignment-toolbar/test/__snapshots__/index.js.snap
rename to packages/block-editor/src/components/block-alignment-toolbar/test/__snapshots__/index.js.snap
diff --git a/packages/editor/src/components/block-alignment-toolbar/test/index.js b/packages/block-editor/src/components/block-alignment-toolbar/test/index.js
similarity index 100%
rename from packages/editor/src/components/block-alignment-toolbar/test/index.js
rename to packages/block-editor/src/components/block-alignment-toolbar/test/index.js
diff --git a/packages/editor/src/components/block-compare/README.md b/packages/block-editor/src/components/block-compare/README.md
similarity index 100%
rename from packages/editor/src/components/block-compare/README.md
rename to packages/block-editor/src/components/block-compare/README.md
diff --git a/packages/editor/src/components/block-compare/block-view.js b/packages/block-editor/src/components/block-compare/block-view.js
similarity index 100%
rename from packages/editor/src/components/block-compare/block-view.js
rename to packages/block-editor/src/components/block-compare/block-view.js
diff --git a/packages/editor/src/components/block-compare/index.js b/packages/block-editor/src/components/block-compare/index.js
similarity index 100%
rename from packages/editor/src/components/block-compare/index.js
rename to packages/block-editor/src/components/block-compare/index.js
diff --git a/packages/editor/src/components/block-compare/style.scss b/packages/block-editor/src/components/block-compare/style.scss
similarity index 100%
rename from packages/editor/src/components/block-compare/style.scss
rename to packages/block-editor/src/components/block-compare/style.scss
diff --git a/packages/editor/src/components/block-compare/test/__snapshots__/block-view.js.snap b/packages/block-editor/src/components/block-compare/test/__snapshots__/block-view.js.snap
similarity index 100%
rename from packages/editor/src/components/block-compare/test/__snapshots__/block-view.js.snap
rename to packages/block-editor/src/components/block-compare/test/__snapshots__/block-view.js.snap
diff --git a/packages/editor/src/components/block-compare/test/block-view.js b/packages/block-editor/src/components/block-compare/test/block-view.js
similarity index 100%
rename from packages/editor/src/components/block-compare/test/block-view.js
rename to packages/block-editor/src/components/block-compare/test/block-view.js
diff --git a/packages/editor/src/components/block-controls/index.js b/packages/block-editor/src/components/block-controls/index.js
similarity index 100%
rename from packages/editor/src/components/block-controls/index.js
rename to packages/block-editor/src/components/block-controls/index.js
diff --git a/packages/block-editor/src/components/block-controls/test/__snapshots__/index.js.snap b/packages/block-editor/src/components/block-controls/test/__snapshots__/index.js.snap
new file mode 100644
index 0000000000000..681c33a42d997
--- /dev/null
+++ b/packages/block-editor/src/components/block-controls/test/__snapshots__/index.js.snap
@@ -0,0 +1,45 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`BlockControls should render a dynamic toolbar of controls 1`] = `
+
Child
+{ __( 'Sorry, this embedded content cannot be previewed in the editor.' ) }
++ { + /* translators: %s: host providing embed content e.g: www.youtube.com */ + sprintf( __( "Embedded content from %s can't be previewed in the editor." ), parsedHostBaseUrl ) + } +
) : embedWrapper } { ( ! RichText.isEmpty( caption ) || isSelected ) && ( diff --git a/packages/block-library/src/embed/settings.js b/packages/block-library/src/embed/settings.js index 7995939c325a3..17d97cee43da6 100644 --- a/packages/block-library/src/embed/settings.js +++ b/packages/block-library/src/embed/settings.js @@ -13,7 +13,7 @@ import classnames from 'classnames/dedupe'; */ import { __ } from '@wordpress/i18n'; import { compose } from '@wordpress/compose'; -import { RichText } from '@wordpress/editor'; +import { RichText } from '@wordpress/block-editor'; import { withSelect, withDispatch } from '@wordpress/data'; const embedAttributes = { diff --git a/packages/block-library/src/file/edit.js b/packages/block-library/src/file/edit.js index 9dca21987bc8c..3ce7211eceb85 100644 --- a/packages/block-library/src/file/edit.js +++ b/packages/block-library/src/file/edit.js @@ -26,8 +26,8 @@ import { MediaUploadCheck, MediaPlaceholder, RichText, - mediaUpload, -} from '@wordpress/editor'; +} from '@wordpress/block-editor'; +import { mediaUpload } from '@wordpress/editor'; import { Component, Fragment } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; diff --git a/packages/block-library/src/file/index.js b/packages/block-library/src/file/index.js index 1c7087039a5cc..7a58074192e21 100644 --- a/packages/block-library/src/file/index.js +++ b/packages/block-library/src/file/index.js @@ -10,7 +10,7 @@ import { __, _x } from '@wordpress/i18n'; import { createBlobURL } from '@wordpress/blob'; import { createBlock } from '@wordpress/blocks'; import { select } from '@wordpress/data'; -import { RichText } from '@wordpress/editor'; +import { RichText } from '@wordpress/block-editor'; /** * Internal dependencies @@ -86,7 +86,7 @@ export const settings = { transform: ( files ) => { const blocks = []; - files.map( ( file ) => { + files.forEach( ( file ) => { const blobURL = createBlobURL( file ); // File will be uploaded in componentDidMount() diff --git a/packages/block-library/src/file/inspector.js b/packages/block-library/src/file/inspector.js index 4c686ad5afe6d..6ed6747f4455c 100644 --- a/packages/block-library/src/file/inspector.js +++ b/packages/block-library/src/file/inspector.js @@ -8,7 +8,7 @@ import { ToggleControl, } from '@wordpress/components'; import { Fragment } from '@wordpress/element'; -import { InspectorControls } from '@wordpress/editor'; +import { InspectorControls } from '@wordpress/block-editor'; export default function FileBlockInspector( { hrefs, diff --git a/packages/block-library/src/gallery/edit.js b/packages/block-library/src/gallery/edit.js index 203403023abd2..868a6a083723d 100644 --- a/packages/block-library/src/gallery/edit.js +++ b/packages/block-library/src/gallery/edit.js @@ -24,8 +24,8 @@ import { MediaPlaceholder, MediaUpload, InspectorControls, - mediaUpload, -} from '@wordpress/editor'; +} from '@wordpress/block-editor'; +import { mediaUpload } from '@wordpress/editor'; import { Component, Fragment } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; diff --git a/packages/block-library/src/gallery/gallery-image.js b/packages/block-library/src/gallery/gallery-image.js index ff95dd1cc49cb..de18796926500 100644 --- a/packages/block-library/src/gallery/gallery-image.js +++ b/packages/block-library/src/gallery/gallery-image.js @@ -11,7 +11,7 @@ import { IconButton, Spinner } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { BACKSPACE, DELETE } from '@wordpress/keycodes'; import { withSelect } from '@wordpress/data'; -import { RichText } from '@wordpress/editor'; +import { RichText } from '@wordpress/block-editor'; import { isBlobURL } from '@wordpress/blob'; class GalleryImage extends Component { diff --git a/packages/block-library/src/gallery/index.js b/packages/block-library/src/gallery/index.js index 9e616efa3684f..4387f9a5e7083 100644 --- a/packages/block-library/src/gallery/index.js +++ b/packages/block-library/src/gallery/index.js @@ -8,7 +8,8 @@ import { filter, every, map, some } from 'lodash'; */ import { __ } from '@wordpress/i18n'; import { createBlock } from '@wordpress/blocks'; -import { RichText, mediaUpload } from '@wordpress/editor'; +import { RichText } from '@wordpress/block-editor'; +import { mediaUpload } from '@wordpress/editor'; import { createBlobURL } from '@wordpress/blob'; /** diff --git a/packages/block-library/src/gallery/test/__snapshots__/index.js.snap b/packages/block-library/src/gallery/test/__snapshots__/index.js.snap deleted file mode 100644 index 9fd3dff017b9d..0000000000000 --- a/packages/block-library/src/gallery/test/__snapshots__/index.js.snap +++ /dev/null @@ -1,78 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`core/gallery block edit matches snapshot 1`] = ` -
-
-
- Start writing or type / to choose a block -
---
-
- Write preformatted text… --
--`; diff --git a/packages/block-library/src/quote/test/index.js b/packages/block-library/src/quote/test/index.js deleted file mode 100644 index 08553f5d8fd09..0000000000000 --- a/packages/block-library/src/quote/test/index.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Internal dependencies - */ -import { name, settings } from '../'; -import { blockEditRender } from '../../test/helpers'; - -describe( 'core/quote', () => { - test( 'block edit matches snapshot', () => { - const wrapper = blockEditRender( name, settings ); - - expect( wrapper ).toMatchSnapshot(); - } ); -} ); diff --git a/packages/block-library/src/rss/edit.js b/packages/block-library/src/rss/edit.js index a08e7fc8fe4d5..e7262e11b2bc1 100644 --- a/packages/block-library/src/rss/edit.js +++ b/packages/block-library/src/rss/edit.js @@ -17,7 +17,7 @@ import { __ } from '@wordpress/i18n'; import { BlockControls, InspectorControls, -} from '@wordpress/editor'; +} from '@wordpress/block-editor'; const DEFAULT_MIN_ITEMS = 1; const DEFAULT_MAX_ITEMS = 10; diff --git a/packages/block-library/src/search/edit.js b/packages/block-library/src/search/edit.js index f5a5acd20c498..6525f5a82408f 100644 --- a/packages/block-library/src/search/edit.js +++ b/packages/block-library/src/search/edit.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { RichText } from '@wordpress/editor'; +import { RichText } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; export default function SearchEdit( { className, attributes, setAttributes } ) { diff --git a/packages/block-library/src/separator/test/__snapshots__/index.js.snap b/packages/block-library/src/separator/test/__snapshots__/index.js.snap deleted file mode 100644 index 2985274d75ea3..0000000000000 --- a/packages/block-library/src/separator/test/__snapshots__/index.js.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`core/separator block edit matches snapshot 1`] = ` ------------
-
---- Write quote… -
-
-
-
- New Column -
-
-
-
- New Column -
---
-
- Write… --
Left
+ *Middle
+ *Left
\n" + * } + * ], + * innerHTML: '\n\n' + * }, + * { + * blockName: "core/column", + * attrs: null, + * innerBlocks: [ + * { + * blockName: "core/paragraph", + * attrs: null, + * innerBlocks: [], + * innerHTML: "\nMiddle
\n" + * } + * ], + * innerHTML: '\n\n' + * }, + * { + * blockName: "core/column", + * attrs: null, + * innerBlocks: [], + * innerHTML: '\n\n' + * } + * ], + * innerHTML: '\nGuten Berg!
+ ++ Guten Berg! +
+ +Guten Berg!
\n\n\t\t\tGuten Berg!\n\t\t
" + } + ], + "originalContent": "Guten Berg!
\n\n\t\t\tGuten Berg!\n\t\t
\n\t\t", + "innerContent": [ + "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" + ] + } + ], + "innerHTML": "\nGuten Berg!
\nGuten Berg!
+ Guten Berg! +
+Guten Berg!
++ Guten Berg! +
+ +Guten Berg!
\n\n\t\t\tGuten Berg!\n\t\t
" + } + ], + "originalContent": "Guten Berg!
\n\n\t\t\tGuten Berg!\n\t\t
\n\t\t", + "innerContent": [ + "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" + ] + } + ], + "innerHTML": "\nGuten Berg!
\nGuten Berg!
+ Guten Berg! +
+Guten Berg!
++ Guten Berg! +
+ +Guten Berg!
\n\n\t\t\tGuten Berg!\n\t\t
" + } + ], + "originalContent": "Guten Berg!
\n\n\t\t\tGuten Berg!\n\t\t
\n\t\t", + "innerContent": [ + "\n\t\t\n\t\t\tGuten Berg!\n\t\t
\n\t\t" + ] + } + ], + "innerHTML": "\nGuten Berg!
\nGuten Berg!
+ Guten Berg! +
+First paragraph
@@ -90,7 +90,7 @@ exports[`block deletion - deleting third third and fourth blocks using backspace " `; -exports[`block deletion - deleting third third and fourth blocks using backspace with multi-block selection results in two remaining blocks and positions the caret at the end of the second block 2`] = ` +exports[`block deletion - deleting the third and fourth blocks using backspace with multi-block selection results in two remaining blocks and positions the caret at the end of the second block 2`] = ` "First paragraph
diff --git a/packages/e2e-tests/specs/__snapshots__/compatibility-classic-editor.test.js.snap b/packages/e2e-tests/specs/__snapshots__/compatibility-classic-editor.test.js.snap index e310008a220d3..3115d36a3b64c 100644 --- a/packages/e2e-tests/specs/__snapshots__/compatibility-classic-editor.test.js.snap +++ b/packages/e2e-tests/specs/__snapshots__/compatibility-classic-editor.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Compatibility with Classic Editor Should not apply autop when rendering blocks 1`] = ` +exports[`Compatibility with classic editor Should not apply autop when rendering blocks 1`] = ` " Random Link " diff --git a/packages/e2e-tests/specs/__snapshots__/writing-flow.test.js.snap b/packages/e2e-tests/specs/__snapshots__/writing-flow.test.js.snap index 0d02a8e655bfa..41f6fe04a2b53 100644 --- a/packages/e2e-tests/specs/__snapshots__/writing-flow.test.js.snap +++ b/packages/e2e-tests/specs/__snapshots__/writing-flow.test.js.snap @@ -72,7 +72,7 @@ exports[`adding blocks should create valid paragraph blocks when rapidly pressin exports[`adding blocks should insert line break at end 1`] = ` " -a
a
+" +`; + exports[`adding blocks should not delete surrounding space when deleting a selected word 1`] = ` "
alpha gamma
diff --git a/packages/e2e-tests/specs/adding-inline-tokens.test.js b/packages/e2e-tests/specs/adding-inline-tokens.test.js index 6fe5d42e84912..5bcd55498489c 100644 --- a/packages/e2e-tests/specs/adding-inline-tokens.test.js +++ b/packages/e2e-tests/specs/adding-inline-tokens.test.js @@ -12,8 +12,9 @@ import uuid from 'uuid/v4'; import { clickBlockAppender, getEditedPostContent, - insertBlock, createNewPost, + clickBlockToolbarButton, + clickButton, } from '@wordpress/e2e-test-utils'; describe( 'adding inline tokens', () => { @@ -26,7 +27,8 @@ describe( 'adding inline tokens', () => { await clickBlockAppender(); await page.keyboard.type( 'a ' ); - await insertBlock( 'Inline Image', 'Inline Elements' ); + await clickBlockToolbarButton( 'More Rich Text Controls' ); + await clickButton( 'Inline Image' ); // Wait for media modal to appear and upload image. await page.waitForSelector( '.media-modal input[type=file]' ); diff --git a/packages/e2e-tests/specs/block-deletion.test.js b/packages/e2e-tests/specs/block-deletion.test.js index b08eacd1f6d62..b9013b3572f9e 100644 --- a/packages/e2e-tests/specs/block-deletion.test.js +++ b/packages/e2e-tests/specs/block-deletion.test.js @@ -5,6 +5,7 @@ import { clickBlockAppender, getEditedPostContent, createNewPost, + isInDefaultBlock, pressKeyWithModifier, } from '@wordpress/e2e-test-utils'; @@ -90,7 +91,7 @@ describe( 'block deletion -', () => { } ); } ); - describe( 'deleting third third and fourth blocks using backspace with multi-block selection', () => { + describe( 'deleting the third and fourth blocks using backspace with multi-block selection', () => { it( 'results in two remaining blocks and positions the caret at the end of the second block', async () => { // Add a third paragraph for this test. await page.keyboard.type( 'Third paragraph' ); @@ -109,3 +110,24 @@ describe( 'block deletion -', () => { } ); } ); } ); + +describe( 'deleting all blocks', () => { + it( 'results in the default block getting selected', async () => { + await createNewPost(); + await clickBlockAppender(); + await page.keyboard.type( 'Paragraph' ); + + await page.keyboard.press( 'Escape' ); + + await clickOnBlockSettingsMenuItem( 'Remove Block' ); + + // There is a default block: + expect( await page.$$( '.editor-block-list__block' ) ).toHaveLength( 1 ); + + // But the effective saved content is still empty: + expect( await getEditedPostContent() ).toBe( '' ); + + // And focus is retained: + expect( await isInDefaultBlock() ).toBe( true ); + } ); +} ); diff --git a/packages/e2e-tests/specs/block-hierarchy-navigation.test.js b/packages/e2e-tests/specs/block-hierarchy-navigation.test.js index 4745768f812c7..28b5c88b9d2c2 100644 --- a/packages/e2e-tests/specs/block-hierarchy-navigation.test.js +++ b/packages/e2e-tests/specs/block-hierarchy-navigation.test.js @@ -31,10 +31,10 @@ describe( 'Navigating the block hierarchy', () => { // Tweak the columns count. await page.focus( '.edit-post-settings-sidebar__panel-block .components-range-control__number[aria-label="Columns"]' ); - page.keyboard.down( 'Shift' ); - page.keyboard.press( 'ArrowLeft' ); - page.keyboard.up( 'Shift' ); - page.keyboard.type( '3' ); + await page.keyboard.down( 'Shift' ); + await page.keyboard.press( 'ArrowLeft' ); + await page.keyboard.up( 'Shift' ); + await page.keyboard.type( '3' ); // Navigate to the last column block. await page.click( '[aria-label="Block Navigation"]' ); diff --git a/packages/e2e-tests/specs/blocks/__snapshots__/list.test.js.snap b/packages/e2e-tests/specs/blocks/__snapshots__/list.test.js.snap index efc3b6d274373..4d473f282a17a 100644 --- a/packages/e2e-tests/specs/blocks/__snapshots__/list.test.js.snap +++ b/packages/e2e-tests/specs/blocks/__snapshots__/list.test.js.snap @@ -76,7 +76,7 @@ exports[`List can be created by using an asterisk at the start of a paragraph bl exports[`List can undo asterisk transform 1`] = ` " -1.
+1.
" `; @@ -98,6 +98,44 @@ exports[`List should change the indented list type 1`] = ` " `; +exports[`List should create and remove indented list with keyboard only 1`] = ` +" +-" -`; - -exports[`Quote can be converted to headings 2`] = ` -" -two
cite
cite-" -`; - -exports[`Quote can be converted to headings 3`] = ` -" -
one
@@ -117,3 +79,73 @@ exports[`Quote can be merged into from a paragraph 1`] = `" `; + +exports[`Quote is transformed to a heading and a quote if the quote contains a citation 1`] = ` +" +test
cite+" +`; + +exports[`Quote is transformed to a heading and a quote if the quote contains multiple paragraphs 1`] = ` +" +
+" +`; + +exports[`Quote is transformed to a heading if the quote just contains one paragraph 1`] = ` +" +two
three
+" +`; + +exports[`Quote the resuling quote after transforming to a heading can be transformed again 2`] = ` +" +two
cite
cite+" +`; + +exports[`Quote the resuling quote after transforming to a heading can be transformed again 3`] = ` +" +
First paragraph
" `; diff --git a/packages/e2e-tests/specs/plugins/allowed-blocks.test.js b/packages/e2e-tests/specs/plugins/allowed-blocks.test.js new file mode 100644 index 0000000000000..9e86e4ad01990 --- /dev/null +++ b/packages/e2e-tests/specs/plugins/allowed-blocks.test.js @@ -0,0 +1,36 @@ +/** + * WordPress dependencies + */ +import { + activatePlugin, + createNewPost, + deactivatePlugin, + searchForBlock, +} from '@wordpress/e2e-test-utils'; + +describe( 'Allowed Blocks Filter', () => { + beforeAll( async () => { + await activatePlugin( 'gutenberg-test-allowed-blocks' ); + } ); + + beforeEach( async () => { + await createNewPost(); + } ); + + afterAll( async () => { + await deactivatePlugin( 'gutenberg-test-allowed-blocks' ); + } ); + + it( 'should restrict the allowed blocks in the inserter', async () => { + // The paragraph block is available. + await searchForBlock( 'Paragraph' ); + const paragraphBlock = await page.$( `button[aria-label="Paragraph"]` ); + expect( paragraphBlock ).not.toBeNull(); + await paragraphBlock.click(); + + // The gallery block is not available. + await searchForBlock( 'Gallery' ); + const galleryBlock = await page.$( `button[aria-label="Gallery"]` ); + expect( galleryBlock ).toBeNull(); + } ); +} ); diff --git a/packages/e2e-tests/specs/plugins/container-blocks.test.js b/packages/e2e-tests/specs/plugins/container-blocks.test.js index 2d32224bb3503..50c4d80854e74 100644 --- a/packages/e2e-tests/specs/plugins/container-blocks.test.js +++ b/packages/e2e-tests/specs/plugins/container-blocks.test.js @@ -31,6 +31,7 @@ describe( 'InnerBlocks Template Sync', () => { `; await insertBlock( blockName ); await switchEditorModeTo( 'Code' ); + await page.waitForSelector( '.editor-post-text-editor' ); await page.$eval( '.editor-post-text-editor', ( element, _paragraph, _blockSlug ) => { const blockDelimiter = ``; element.value = element.value.replace( blockDelimiter, `${ _paragraph }${ blockDelimiter }` ); diff --git a/packages/e2e-tests/specs/plugins/format-api.test.js b/packages/e2e-tests/specs/plugins/format-api.test.js index c8d22a60f356d..814ace8fd842a 100644 --- a/packages/e2e-tests/specs/plugins/format-api.test.js +++ b/packages/e2e-tests/specs/plugins/format-api.test.js @@ -4,10 +4,12 @@ import { activatePlugin, clickBlockAppender, + clickBlockToolbarButton, createNewPost, deactivatePlugin, getEditedPostContent, pressKeyWithModifier, + clickButton, } from '@wordpress/e2e-test-utils'; describe( 'Using Format API', () => { @@ -23,20 +25,12 @@ describe( 'Using Format API', () => { await createNewPost(); } ); - it( 'Format toolbar is present in a paragraph block', async () => { - await clickBlockAppender(); - await page.keyboard.type( 'First paragraph' ); - await page.mouse.move( 200, 300, { steps: 10 } ); - expect( await page.$( '[aria-label="Custom Link"]' ) ).not.toBeNull(); - } ); - it( 'Clicking the control wraps the selected text properly with HTML code', async () => { await clickBlockAppender(); await page.keyboard.type( 'First paragraph' ); await pressKeyWithModifier( 'shiftAlt', 'ArrowLeft' ); - await pressKeyWithModifier( 'primary', 'A' ); - await page.mouse.move( 200, 300, { steps: 10 } ); - await page.click( '[aria-label="Custom Link"]' ); + await clickBlockToolbarButton( 'More Rich Text Controls' ); + await clickButton( 'Custom Link' ); expect( await getEditedPostContent() ).toMatchSnapshot(); } ); } ); diff --git a/packages/e2e-tests/specs/reusable-blocks.test.js b/packages/e2e-tests/specs/reusable-blocks.test.js index f1ef297f311ba..982762b63dfec 100644 --- a/packages/e2e-tests/specs/reusable-blocks.test.js +++ b/packages/e2e-tests/specs/reusable-blocks.test.js @@ -4,6 +4,7 @@ import { insertBlock, createNewPost, + clickBlockToolbarButton, pressKeyWithModifier, searchForBlock, getEditedPostContent, @@ -34,13 +35,8 @@ describe( 'Reusable Blocks', () => { await insertBlock( 'Paragraph' ); await page.keyboard.type( 'Hello there!' ); - // Trigger isTyping = false - await page.mouse.move( 200, 300, { steps: 10 } ); - await page.mouse.move( 250, 350, { steps: 10 } ); + await clickBlockToolbarButton( 'More options' ); - // Convert block to a reusable block - await page.waitForSelector( 'button[aria-label="More options"]' ); - await page.click( 'button[aria-label="More options"]' ); const convertButton = await page.waitForXPath( '//button[text()="Add to Reusable Blocks"]' ); await convertButton.click(); @@ -81,13 +77,8 @@ describe( 'Reusable Blocks', () => { await insertBlock( 'Paragraph' ); await page.keyboard.type( 'Hello there!' ); - // Trigger isTyping = false - await page.mouse.move( 200, 300, { steps: 10 } ); - await page.mouse.move( 250, 350, { steps: 10 } ); + await clickBlockToolbarButton( 'More options' ); - // Convert block to a reusable block - await page.waitForSelector( 'button[aria-label="More options"]' ); - await page.click( 'button[aria-label="More options"]' ); const convertButton = await page.waitForXPath( '//button[text()="Add to Reusable Blocks"]' ); await convertButton.click(); @@ -222,10 +213,6 @@ describe( 'Reusable Blocks', () => { await pressKeyWithModifier( 'primary', 'a' ); await pressKeyWithModifier( 'primary', 'a' ); - // Trigger isTyping = false - await page.mouse.move( 200, 300, { steps: 10 } ); - await page.mouse.move( 250, 350, { steps: 10 } ); - // Convert block to a reusable block await page.waitForSelector( 'button[aria-label="More options"]' ); await page.click( 'button[aria-label="More options"]' ); diff --git a/packages/e2e-tests/specs/splitting-merging.test.js b/packages/e2e-tests/specs/splitting-merging.test.js index 1120f04a2b767..c5ea8bf94ce77 100644 --- a/packages/e2e-tests/specs/splitting-merging.test.js +++ b/packages/e2e-tests/specs/splitting-merging.test.js @@ -4,6 +4,7 @@ import { createNewPost, insertBlock, + isInDefaultBlock, getEditedPostContent, pressKeyTimes, pressKeyWithModifier, @@ -199,15 +200,6 @@ describe( 'splitting and merging blocks', () => { expect( await getEditedPostContent() ).toBe( '' ); // And focus is retained: - const isInDefaultBlock = await page.evaluate( () => { - const activeBlockName = document.activeElement - .closest( '[data-type]' ) - .getAttribute( 'data-type' ); - const defaultBlockName = window.wp.blocks.getDefaultBlockName(); - - return activeBlockName === defaultBlockName; - } ); - - expect( isInDefaultBlock ).toBe( true ); + expect( await isInDefaultBlock() ).toBe( true ); } ); } ); diff --git a/packages/e2e-tests/specs/style-variation.test.js b/packages/e2e-tests/specs/style-variation.test.js index 0d1c2e758b042..33ddcc3c2f809 100644 --- a/packages/e2e-tests/specs/style-variation.test.js +++ b/packages/e2e-tests/specs/style-variation.test.js @@ -1,7 +1,12 @@ /** * WordPress dependencies */ -import { createNewPost, insertBlock, getEditedPostContent } from '@wordpress/e2e-test-utils'; +import { + createNewPost, + clickBlockToolbarButton, + insertBlock, + getEditedPostContent, +} from '@wordpress/e2e-test-utils'; describe( 'adding blocks', () => { beforeAll( async () => { @@ -13,13 +18,8 @@ describe( 'adding blocks', () => { await insertBlock( 'Quote' ); await page.keyboard.type( 'Quote content' ); - // we need to trigger isTyping = false - await page.mouse.move( 200, 300, { steps: 10 } ); - await page.mouse.move( 250, 350, { steps: 10 } ); + await clickBlockToolbarButton( 'Change block type' ); - // Use a different style variation - await page.waitForSelector( 'button[aria-label="Change block type"]' ); - await page.click( 'button[aria-label="Change block type"]' ); const styleVariations = await page.$$( '.editor-block-styles__item' ); await styleVariations[ 1 ].click(); diff --git a/packages/e2e-tests/specs/taxonomies.test.js b/packages/e2e-tests/specs/taxonomies.test.js index 087da816f4d6a..2cd8e7665eda4 100644 --- a/packages/e2e-tests/specs/taxonomies.test.js +++ b/packages/e2e-tests/specs/taxonomies.test.js @@ -8,6 +8,11 @@ import { publishPost, } from '@wordpress/e2e-test-utils'; +/** + * Module constants + */ +const TAG_TOKEN_SELECTOR = '.components-form-token-field__token-text span:not(.screen-reader-text)'; + describe( 'Taxonomies', () => { const canCreatTermInTaxonomy = ( taxonomy ) => { return page.evaluate( @@ -38,13 +43,13 @@ describe( 'Taxonomies', () => { const getCurrentTags = async () => { const tagsPanel = await findSidebarPanelWithTitle( 'Tags' ); - return page.evaluate( ( node ) => { + return page.evaluate( ( node, selector ) => { return Array.from( node.querySelectorAll( - '.components-form-token-field__token-text span:not(.screen-reader-text)' + selector ) ).map( ( field ) => { return field.innerText; } ); - }, tagsPanel ); + }, tagsPanel, TAG_TOKEN_SELECTOR ); }; it( 'should be able to open the categories panel and create a new main category if the user has the right capabilities', async () => { @@ -123,6 +128,13 @@ describe( 'Taxonomies', () => { // Open the tags panel. await tagsPanel.click( 'button' ); + // At the start there are no tag tokens + expect( + await page.$$( + TAG_TOKEN_SELECTOR + ) + ).toHaveLength( 0 ); + const tagInput = await tagsPanel.$( '.components-form-token-field__input' ); // Click the tag input field. @@ -134,7 +146,7 @@ describe( 'Taxonomies', () => { // Press enter to create a new tag. await tagInput.press( 'Enter' ); - await page.waitForSelector( '.components-form-token-field__token' ); + await page.waitForSelector( TAG_TOKEN_SELECTOR ); // Get an array with the tags of the post. let tags = await getCurrentTags(); @@ -153,7 +165,7 @@ describe( 'Taxonomies', () => { await page.reload(); // Wait for the tags to load. - page.waitForSelector( '.components-form-token-field__token' ); + await page.waitForSelector( '.components-form-token-field__token' ); tags = await getCurrentTags(); diff --git a/packages/e2e-tests/specs/writing-flow.test.js b/packages/e2e-tests/specs/writing-flow.test.js index d0b46970c87f4..62ece15801640 100644 --- a/packages/e2e-tests/specs/writing-flow.test.js +++ b/packages/e2e-tests/specs/writing-flow.test.js @@ -7,6 +7,7 @@ import { createNewPost, pressKeyTimes, pressKeyWithModifier, + insertBlock, } from '@wordpress/e2e-test-utils'; describe( 'adding blocks', () => { @@ -208,6 +209,13 @@ describe( 'adding blocks', () => { expect( await getEditedPostContent() ).toMatchSnapshot(); } ); + it( 'should not create extra line breaks in multiline value', async () => { + await insertBlock( 'Quote' ); + await page.keyboard.type( 'a' ); + await page.keyboard.press( 'Backspace' ); + expect( await getEditedPostContent() ).toMatchSnapshot(); + } ); + it( 'should navigate native inputs vertically, not horizontally', async () => { // See: https://github.com/WordPress/gutenberg/issues/9626 diff --git a/packages/edit-post/README.md b/packages/edit-post/README.md index ca4fc9e947dd2..0c8eb1326e884 100644 --- a/packages/edit-post/README.md +++ b/packages/edit-post/README.md @@ -20,21 +20,40 @@ Extending the editor UI can be accomplished with the `registerPlugin` API, allow Refer to [the plugins module documentation](/packages/plugins/README.md) for more information. -## Plugin Components - -The following components can be used with the `registerPlugin` ([see documentation](/packages/plugins/README.md)) API. +The components exported through the API can be used with the `registerPlugin` ([see documentation](/packages/plugins/README.md)) API. They can be found in the global variable `wp.editPost` when defining `wp-edit-post` as a script dependency. -### `PluginBlockSettingsMenuItem` +## API -Renders a new item in the block settings menu. + + +### initializeEditor + +[src/index.js#L66-L96](src/index.js#L66-L96) + +Initializes and returns an instance of Editor. + +The return value of this function is not necessary if we change where we +call initializeEditor(). This is due to metaBox timing. + +**Parameters** -Example: +- **id** `string`: Unique identifier for editor instance. +- **postType** `Object`: Post type of the post to edit. +- **postId** `Object`: ID of the post to edit. +- **settings** `?Object`: Editor settings object. +- **initialEdits** `Object`: Programmatic edits to apply initially, to be considered as non-user-initiated (bypass for unsaved changes prompt). -{% codetabs %} +### PluginBlockSettingsMenuItem + +[src/index.js#L98-L98](src/index.js#L98-L98) + +Renders a new item in the block settings menu. + +**Usage** -{% ES5 %} ```js +// Using ES5 syntax var __ = wp.i18n.__; var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem; @@ -55,8 +74,8 @@ function MyPluginBlockSettingsMenuItem() { } ``` -{% ESNext %} ```jsx +// Using ESNext syntax import { __ } from wp.i18n; import { PluginBlockSettingsMenuItem } from wp.editPost; @@ -73,149 +92,29 @@ const MyPluginBlockSettingsMenuItem = () => ( ); ``` -{% end %} - -#### Props - -##### allowedBlockNames - -An array containing a whitelist of block names for which the item should be shown. If this prop is not present the item will be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the whitelist. - -- Type: `Array` -- Required: No -- Default: Menu item is shown for any block - -##### icon - -The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label. - -- Type: `String` | `Element` -- Required: No -- Default: Menu item wil be rendered without icon - -##### label - -A string containing the menu item text. - -- Type: `String` -- Required: Yes - -##### onClick - -The callback function to be executed when the user clicks the menu item. - -- Type: `function` -- Required: Yes - -### `PluginSidebar` - -Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar. - -If you wish to display the sidebar, you can with use the [`PluginSidebarMoreMenuItem`](#pluginsidebarmoremenuitem) component or the `wp.data.dispatch` API: - -```js -wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' ); -``` - -_Example:_ - -{% codetabs %} - -{% ES5 %} -```js -var __ = wp.i18n.__; -var el = wp.element.createElement; -var PanelBody = wp.components.PanelBody; -var PluginSidebar = wp.editPost.PluginSidebar; - - -function MyPluginSidebar() { - return el( - PluginSidebar, - { - name: 'my-sidebar', - title: 'My sidebar title', - icon: 'smiley', - }, - el( - PanelBody, - {}, - __( 'My sidebar content' ) - ) - ); -} -``` - -{% ESNext %} -```jsx -const { __ } = wp.i18n; -const { PanelBody } = wp.components; -const { PluginSidebar } = wp.editPost; - -const MyPluginSidebar = () => ( -- Child -
-