Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/caption for gallery block #17001

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6465790
Basic gallery caption.
tellthemachines Aug 9, 2019
9fc6699
add block deprecation
tellthemachines Aug 9, 2019
f635ed9
Regenerate test fixtures and fix failures
tellthemachines Aug 12, 2019
3f90fa4
e2e snapshot update
tellthemachines Aug 12, 2019
9751b39
Fix editor styles
tellthemachines Aug 12, 2019
bbaf7a3
Fix block transforms e2e
tellthemachines Aug 12, 2019
4a79b86
Workaround for failing tests
tellthemachines Aug 12, 2019
f4f8ba9
Undo package-lock changes
tellthemachines Aug 13, 2019
321d469
Revert "Undo package-lock changes"
tellthemachines Aug 13, 2019
18b194a
Update github action exit codes (#17002)
talldan Aug 13, 2019
f6acb42
Fix messed up styles.
tellthemachines Aug 13, 2019
9aa06d3
Try to fix package-lock issue _again_
tellthemachines Aug 13, 2019
eebf33b
chore: Update: Use mixins in button instead of media queries (#17012)
jorgefilipecosta Aug 13, 2019
bbe692b
[RNMobile] Reset toolbar scroll on content change
mchowning Aug 7, 2019
4cfbd64
Add editor-styles-wrapper class to the widgets screen block list (#17…
jorgefilipecosta Aug 13, 2019
387d85a
Add: Button Block appender to the widgets screen. (#16971)
jorgefilipecosta Aug 13, 2019
a94e907
Scripts: Add section about updating package after new releases (#17026)
gziolo Aug 14, 2019
949c088
Addressed design feedback.
tellthemachines Aug 14, 2019
940184c
Fix: Duplicate button appears even if the block is not allowed (#17007)
jorgefilipecosta Aug 14, 2019
9a0876c
Change caption name and remove deprecation.
tellthemachines Aug 14, 2019
9c4ee6f
Fix the double scrollbar appearing in full screen mode (#17031)
youknowriad Aug 14, 2019
be7db4f
Core Data: Return updated record in `saveEntityRecord`. (#17030)
epiqueras Aug 14, 2019
8d62c26
Fix performance tests with the introduction of the navigation mode (#…
youknowriad Aug 14, 2019
b99ae56
RichText: ignore selection changes during composition (#16960)
ellatrix Aug 14, 2019
989c224
Bump plugin version to 6.3.0
youknowriad Aug 14, 2019
24caaa3
RichText 🧹 (clean up, move Autocomplete, remove DOM dependency) (#16905)
ellatrix Aug 14, 2019
28919d1
RichText (block context): move list controls to list block (#16962)
ellatrix Aug 14, 2019
e07fb3c
Update notifications (#17046)
nosolosw Aug 15, 2019
43250ce
List block: add start and reversed attributes (#15113)
Jackie6 Aug 15, 2019
d83c239
Adds default funcs as props (#17036)
getdave Aug 15, 2019
0ca1b7e
Added ESNext examples to format API tutorial (page 1) (#16804)
bfintal Aug 15, 2019
0f3c147
Added ESNext examples to format API tutorial (page 2) (#16803)
bfintal Aug 15, 2019
2a7c8a6
Added ESNext examples to format API tutorial (page 3) (#16802)
bfintal Aug 15, 2019
0f3058e
Scripts: Improve the way test files are discovered (#17033)
gziolo Aug 16, 2019
fbf1938
Fix: Button block does not centers on the editor (#17063)
jorgefilipecosta Aug 16, 2019
15f5ff4
[RNMobile] Extract caption component (#16825)
mchowning Aug 16, 2019
d80b024
Update: Latest Posts Block: Use (no title) instead of (Untitled) for …
donmhico Aug 17, 2019
82fcf2b
Revert "Change caption name and remove deprecation."
tellthemachines Aug 19, 2019
7b06d77
Re-add gallery caption name change.
tellthemachines Aug 19, 2019
b5bea97
Basic gallery caption.
tellthemachines Aug 9, 2019
647adf0
add block deprecation
tellthemachines Aug 9, 2019
752c993
Regenerate test fixtures and fix failures
tellthemachines Aug 12, 2019
40ada1d
e2e snapshot update
tellthemachines Aug 12, 2019
09a571d
Fix editor styles
tellthemachines Aug 12, 2019
1fe3d2e
Fix block transforms e2e
tellthemachines Aug 12, 2019
2572f36
Workaround for failing tests
tellthemachines Aug 12, 2019
b978a02
Undo package-lock changes
tellthemachines Aug 13, 2019
220968e
Fix messed up styles.
tellthemachines Aug 13, 2019
02171ed
Addressed design feedback.
tellthemachines Aug 14, 2019
1302a85
Change caption name and remove deprecation.
tellthemachines Aug 14, 2019
1361712
Revert "Change caption name and remove deprecation."
tellthemachines Aug 19, 2019
c401419
Re-add gallery caption name change.
tellthemachines Aug 19, 2019
5e65169
Merge branch 'add/caption-for-gallery-block' of github.com:WordPress/…
tellthemachines Aug 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/packages/library-export-default-webpack-plugin @gziolo @ntwb @nerrad @ajitbohra
/packages/npm-package-json-lint-config @gziolo @ntwb @nerrad @ajitbohra
/packages/postcss-themes @youknowriad @ntwb @nerrad @ajitbohra
/packages/scripts @youknowriad @gziolo @ntwb @nerrad @ajitbohra @nosolosw
/packages/scripts @youknowriad @gziolo @ntwb @nerrad @ajitbohra

# UI Components
/packages/components @youknowriad @gziolo @ajitbohra @jaymanpandya @jorgefilipecosta @talldan @chrisvanpatten
Expand Down
19 changes: 14 additions & 5 deletions .github/actions/assign-fixed-issues/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/bin/bash
set -e

# 1. Find the issues that this PR 'fixes'.
# 1. Proceed only when acting on an opened pull request.

action=$(jq -r '.action' $GITHUB_EVENT_PATH)

if [ "$action" != 'closed' ]; then
echo "Action '$action' not a close action. Aborting."
exit 0;
fi

# 2. Find the issues that this PR 'fixes'.

issues=$(
jq -r '.pull_request.body' $GITHUB_EVENT_PATH | perl -nle 'print $1 while /
Expand All @@ -15,18 +24,18 @@ issues=$(

if [ -z "$issues" ]; then
echo "Pull request does not 'fix' any issues. Aborting."
exit 78
exit 0
fi

# 2. Grab the author of the PR.
# 3. Grab the author of the PR.

author=$(jq -r '.pull_request.user.login' $GITHUB_EVENT_PATH)

# 3. Loop through each 'fixed' issue.
# 4. Loop through each 'fixed' issue.

for issue in $issues; do

# 3a. Add the author as an asignee to the issue. This fails if the author is
# 4a. Add the author as an asignee to the issue. This fails if the author is
# already assigned, which is expected and ignored.

curl \
Expand Down
20 changes: 14 additions & 6 deletions .github/actions/first-time-contributor/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#!/bin/bash
set -e

# 1. Get the author and pr number for the pull request.
# 1. Proceed only when acting on an opened pull request.
action=$(jq -r '.action' $GITHUB_EVENT_PATH)

if [ "$action" != 'opened' ]; then
echo "Action '$action' not a close action. Aborting."
exit 0;
fi

# 2. Get the author and pr number for the pull request.
author=$(jq -r '.pull_request.user.login' $GITHUB_EVENT_PATH)
pr_number=$(jq -r '.number' $GITHUB_EVENT_PATH)

if [ "$pr_number" = "null" ] || [ "$author" = "null" ]; then
echo "Could not find PR number or author. $pr_number / $author"
exit 78
exit 0
fi

# 2. Fetch the author's commit count for the repo to determine if they're a first-time contributor.
# 3. Fetch the author's commit count for the repo to determine if they're a first-time contributor.
commit_count=$(
curl \
--silent \
Expand All @@ -19,13 +27,13 @@ commit_count=$(
| jq -r '.total_count'
)

# 3. If the response has a commit count of zero, exit early, the author is not a first time contributor.
# 4. If the response has a commit count of zero, exit early, the author is not a first time contributor.
if [ "$commit_count" != "0" ]; then
echo "Pull request #$pr_number was not created by a first-time contributor ($author)."
exit 78
exit 0
fi

# 4. Assign the 'First Time Contributor' label.
# 5. Assign the 'First Time Contributor' label.
curl \
--silent \
-X POST \
Expand Down
8 changes: 4 additions & 4 deletions .github/actions/milestone-it/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ action=$(jq -r '.action' $GITHUB_EVENT_PATH)

if [ "$action" != 'closed' ]; then
echo "Action '$action' not a close action. Aborting."
exit 78;
exit 0;
fi

merged=$(jq -r '.pull_request.merged' $GITHUB_EVENT_PATH)

if [ "$merged" != 'true' ]; then
echo "Pull request closed without merge. Aborting."
exit 78;
exit 0;
fi

base=$(jq -r '.pull_request.base.ref' $GITHUB_EVENT_PATH)

if [ "$base" != 'master' ]; then
echo 'Milestones apply only to master merge. Aborting.'
exit 78;
exit 0;
fi

# 2. Determine if milestone already exists (don't replace one which has already
Expand All @@ -39,7 +39,7 @@ current_milestone=$(

if [ "$current_milestone" != 'null' ]; then
echo 'Milestone already applied. Aborting.'
exit 78;
exit 0;
fi

# 3. Read current version.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
on: pull_request
name: Add the First-time Contributor label to PRs opened by first-time contributors
name: Add the First-time Contributor label
jobs:
filterOpened:
name: Filter opened
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Filter opened
uses: actions/bin/filter@0dbb077f64d0ec1068a644d25c71b1db66148a24
with:
args: action opened
- name: First Time Contributor
uses: ./.github/actions/first-time-contributor
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Filter opened
uses: actions/bin/filter@0dbb077f64d0ec1068a644d25c71b1db66148a24
with:
args: action opened
- name: Assign Fixed Issues
uses: ./.github/actions/assign-fixed-issues
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ add_action( 'enqueue_block_editor_assets', 'my_custom_format_enqueue_assets_edit

Then add a new file named `my-custom-format.js` with the following contents:

{% codetabs %}
{% ES5 %}
```js
( function( wp ) {
wp.richText.registerFormatType(
Expand All @@ -38,6 +40,19 @@ Then add a new file named `my-custom-format.js` with the following contents:
);
} )( window.wp );
```
{% ESNext %}
```js
const { registerFormatType } = wp.richText;

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

Make that plugin available in your WordPress setup and activate it. Then, load a new page/post.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Now that the format is available, the next step is to surface it to the UI. You

Paste this code in `my-custom-format.js`:

{% codetabs %}
{% ES5 %}
```js
( function( wp ) {
var MyCustomButton = function( props ) {
Expand All @@ -27,6 +29,31 @@ Paste this code in `my-custom-format.js`:
);
} )( window.wp );
```
{% ESNext %}
```js
const { registerFormatType } = wp.richText;
const { RichTextToolbarButton } = wp.blockEditor;

const MyCustomButton = props => {
return <RichTextToolbarButton
icon='editor-code'
title='Sample output'
onClick={ () => {
console.log( 'toggle format' );
} }
/>
};

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

**Important**: note that this code is using two new utilities (`wp.element.createElement`, and `wp.editor.RichTextToolbarButton`) so don't forget adding the corresponding `wp-element` and `wp-editor` packages to the dependencies array in the PHP file along with the existing `wp-rich-text`.

Expand All @@ -42,6 +69,8 @@ By default, the button is rendered on every rich text toolbar (image captions, b
It is possible to render the button only on blocks of a certain type by using `wp.data.withSelect` together with `wp.compose.ifCondition`.
The following sample code renders the previously shown button only on Paragraph blocks:

{% codetabs %}
{% ES5 %}
```js
( function( wp ) {
var withSelect = wp.data.withSelect;
Expand Down Expand Up @@ -82,6 +111,47 @@ The following sample code renders the previously shown button only on Paragraph
);
} )( window.wp );
```
{% ESNext %}
```js
const { compose, ifCondition } = wp.compose;
const { registerFormatType } = wp.richText;
const { RichTextToolbarButton } = wp.blockEditor;
const { withSelect } = wp.data;

const MyCustomButton = props => {
return <RichTextToolbarButton
icon='editor-code'
title='Sample output'
onClick={ () => {
console.log( 'toggle format' );
} }
/>
};

const ConditionalButton = compose(
withSelect( function( select ) {
return {
selectedBlock: select( 'core/editor' ).getSelectedBlock()
}
} ),
ifCondition( function( props ) {
return (
props.selectedBlock &&
props.selectedBlock.name === 'core/paragraph'
);
} )
)( MyCustomButton );

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

Don't forget adding `wp-compose` and `wp-data` to the dependencies array in the PHP script.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ The [rich-text package](/packages/rich-text/README.md) offers a few utilities to

Update `my-custom-format.js` with this new code:

{% codetabs %}
{% ES5 %}
```js
( function( wp ) {
var MyCustomButton = function( props ) {
return wp.element.createElement(
wp.editor.RichTextToolbarButton, {
wp.blockEditor.RichTextToolbarButton, {
icon: 'editor-code',
title: 'Sample output',
onClick: function() {
Expand All @@ -33,6 +35,35 @@ Update `my-custom-format.js` with this new code:
);
} )( window.wp );
```
{% ESNext %}
```js
const { registerFormatType, toggleFormat } = wp.richText
const { RichTextToolbarButton } = wp.blockEditor;

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

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

Now, let's check that is working as intended: reload the post/page, make a text selection, click the button, and then change to HTML view to confirm that the tag was effectively applied.

Expand Down
2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Gutenberg
* Plugin URI: https://github.com/WordPress/gutenberg
* Description: Printing since 1440. This is the development plugin for the new block editor in core.
* Version: 6.3.0-rc.1
* Version: 6.3.0
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
Loading