Skip to content

Commit

Permalink
Merge changes published in the Gutenberg plugin "trunk" branch
Browse files Browse the repository at this point in the history
  • Loading branch information
gutenbergplugin committed Aug 29, 2022
1 parent ba8a396 commit f9ba10d
Show file tree
Hide file tree
Showing 550 changed files with 8,068 additions and 6,764 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
const { escapeRegExp } = require( 'lodash' );
const glob = require( 'glob' ).sync;
const { join } = require( 'path' );

Expand All @@ -17,7 +16,8 @@ const { version } = require( './package' );
* @type {string}
*/
const majorMinorRegExp =
escapeRegExp( version.replace( /\.\d+$/, '' ) ) + '(\\.\\d+)?';
version.replace( /\.\d+$/, '' ).replace( /[\\^$.*+?()[\]{}|]/g, '\\$&' ) +
'(\\.\\d+)?';

/**
* The list of patterns matching files used only for development purposes.
Expand Down Expand Up @@ -94,6 +94,7 @@ module.exports = {
'differenceWith',
'dropRight',
'each',
'escapeRegExp',
'extend',
'findIndex',
'findKey',
Expand All @@ -102,6 +103,7 @@ module.exports = {
'flatten',
'flattenDeep',
'fromPairs',
'has',
'identity',
'invoke',
'isArray',
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/stale-issue-flaky-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Mark old flaky tests issues as stale'
on:
schedule:
- cron: '20 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/gutenberg' }}

steps:
- uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has gone 30 days without any activity.'
days-before-stale: 30
days-before-close: 1
only-labels: '[Type] Flaky Test'
stale-issue-label: '[Status] Stale'
1 change: 1 addition & 0 deletions .github/workflows/stale-issue-mark-stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
- uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "Hi,\nThis issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.\nThanks for helping out."
days-before-stale: 30
days-before-close: -1
only-labels: 'Needs Testing'
Expand Down
3 changes: 3 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
build
build-style
node_modules
packages/stylelint-config/test
13 changes: 12 additions & 1 deletion bin/plugin/commands/changelog.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
const { groupBy, escapeRegExp, flow } = require( 'lodash' );
const { groupBy, flow } = require( 'lodash' );
const Octokit = require( '@octokit/rest' );
const { sprintf } = require( 'sprintf-js' );
const semver = require( 'semver' );
Expand Down Expand Up @@ -185,6 +185,17 @@ const REWORD_TERMS = {
docs: 'documentation',
};

/**
* Escapes the RegExp special characters.
*
* @param {string} string Input string.
*
* @return {string} Regex-escaped string.
*/
function escapeRegExp( string ) {
return string.replace( /[\\^$.*+?()[\]{}|]/g, '\\$&' );
}

/**
* Returns candidates based on whether the given labels
* are part of the allowed list.
Expand Down
415 changes: 415 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

44 changes: 41 additions & 3 deletions docs/how-to-guides/format-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ registerFormatType( 'my-custom-format/sample-output', {
} );
```

Let's check that everything is working as expected. Build and reload and then select a text block. Confirm the new button was added to the format toolbar.
Let's check that everything is working as expected. Build and reload and then select any block containing text like for example the paragraph block. Confirm the new button was added to the format toolbar.

![Toolbar with custom button](https://developer.wordpress.org/files/2021/12/format-api-toolbar.png)

Expand Down Expand Up @@ -125,13 +125,13 @@ registerFormatType( 'my-custom-format/sample-output', {

Confirm it is working: first build and reload, then make a text selection and click the button. Your browser will likely display that selection differently than the surrounding text.

You can also confirm by switching to HTML view (Code editor Ctrl+Shift+Alt+M) and see the text selection wrapped with `<samp>` HTML tags.
You can also confirm by switching to HTML view (Code editor `Ctrl+Shift+Alt+M`) and see the text selection wrapped with `<samp>` HTML tags.

Use the `className` option when registering to add your own custom class to the tag. You can use that class and custom CSS to target that element and style as you wish.

### Step 4: Show the button only for specific blocks (Optional)

By default, the button is rendered on every rich text toolbar (image captions, buttons, paragraphs, etc). You can render the button only on blocks of a certain type by using `wp.data.withSelect` together with `wp.compose.ifCondition`.
By default, the button is rendered on every rich text toolbar (image captions, buttons, paragraphs, etc). You can render the button only on blocks of a certain type by using [the data API](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-data).

Here is an example that only shows the button for Paragraph blocks:

Expand Down Expand Up @@ -173,6 +173,44 @@ registerFormatType( 'my-custom-format/sample-output', {
} );
```

### Step5: Add a button outside of the dropdown (Optional)

Using the `RichTextToolbarButton` component, the button is added to the default dropdown menu. You can add the button directly to the toolbar by using the `BlockControls` component.

```js
import { registerFormatType, toggleFormat } from '@wordpress/rich-text';
import { BlockControls } from '@wordpress/block-editor';
import { ToolbarGroup, ToolbarButton } from '@wordpress/components';

const MyCustomButton = ( { isActive, onChange, value } ) => {
return (
<BlockControls>
<ToolbarGroup>
<ToolbarButton
icon="editor-code"
title="Sample output"
onClick={ () => {
onChange(
toggleFormat( value, {
type: 'my-custom-format/sample-output',
} )
);
} }
isActive={ isActive }
/>
</ToolbarGroup>
</BlockControls>
);
};

registerFormatType( 'my-custom-format/sample-output', {
title: 'Sample output',
tagName: 'samp',
className: null,
edit: MyCustomButton,
} );
```

## Troubleshooting

If you run into errors:
Expand Down
14 changes: 7 additions & 7 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Create a link that always points to the homepage of the site. Usually not necess

- **Name:** core/home-link
- **Category:** design
- **Supports:** ~~html~~, ~~reusable~~
- **Supports:** typography (fontSize, lineHeight), ~~html~~, ~~reusable~~
- **Attributes:** label

## Custom HTML
Expand Down Expand Up @@ -329,7 +329,7 @@ Display a list of your most recent posts. ([Source](https://github.com/WordPress

- **Name:** core/latest-posts
- **Category:** widgets
- **Supports:** align, ~~html~~
- **Supports:** align, typography (fontSize, lineHeight), ~~html~~
- **Attributes:** addLinkToFeaturedImage, categories, columns, displayAuthor, displayFeaturedImage, displayPostContent, displayPostContentRadio, displayPostDate, excerptLength, featuredImageAlign, featuredImageSizeHeight, featuredImageSizeSlug, featuredImageSizeWidth, order, orderBy, postLayout, postsToShow, selectedAuthor

## List
Expand All @@ -338,7 +338,7 @@ Create a bulleted or numbered list. ([Source](https://github.com/WordPress/guten

- **Name:** core/list
- **Category:** text
- **Supports:** __unstablePasteTextInline, anchor, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~className~~
- **Supports:** __unstablePasteTextInline, anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~className~~
- **Attributes:** ordered, placeholder, reversed, start, type, values

## List item
Expand All @@ -365,7 +365,7 @@ Set media and words side-by-side for a richer layout. ([Source](https://github.c

- **Name:** core/media-text
- **Category:** media
- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~
- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** align, focalPoint, href, imageFill, isStackedOnMobile, linkClass, linkDestination, linkTarget, mediaAlt, mediaId, mediaLink, mediaPosition, mediaSizeSlug, mediaType, mediaUrl, mediaWidth, rel, verticalAlignment

## Unsupported
Expand Down Expand Up @@ -617,7 +617,7 @@ Contains the block elements used to render content when no query results are fou

- **Name:** core/query-no-results
- **Category:** theme
- **Supports:** align, color (background, gradients, link, text), ~~html~~, ~~reusable~~
- **Supports:** align, color (background, gradients, link, text), typography (fontSize, lineHeight), ~~html~~, ~~reusable~~
- **Attributes:**

## Pagination
Expand Down Expand Up @@ -761,7 +761,7 @@ Display icons linking to your social media profiles or sites. ([Source](https://

- **Name:** core/social-links
- **Category:** widgets
- **Supports:** align (center, left, right), anchor, spacing (blockGap, margin, units)
- **Supports:** align (center, left, right), anchor, color (background, gradients, ~~enableContrastChecker~~, ~~text~~), spacing (blockGap, margin, units)
- **Attributes:** customIconBackgroundColor, customIconColor, iconBackgroundColor, iconBackgroundColorValue, iconColor, iconColorValue, openInNewTab, showLabels, size

## Spacer
Expand All @@ -788,7 +788,7 @@ Summarize your post with a list of headings. Add HTML anchors to Heading blocks

- **Name:** core/table-of-contents
- **Category:** layout
- **Supports:** color (background, gradients, link, text), spacing (margin, padding), ~~html~~
- **Supports:** color (background, gradients, link, text), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~
- **Attributes:** headings, onlyIncludeCurrentPage

## Tag Cloud
Expand Down
Loading

0 comments on commit f9ba10d

Please sign in to comment.