Skip to content

Commit

Permalink
prep build 6/21
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jun 21, 2024
2 parents b9d39b2 + bb73da7 commit 4f0f9c7
Show file tree
Hide file tree
Showing 41 changed files with 31,192 additions and 28,718 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@

# Directories with vendored code.
packages/edit-site/lib/** linguist-vendored

# The changelog.txt file is authored as markdown.
changelog.txt linguist-language=Markdown
10 changes: 9 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// Import the default config file and expose it in the project root.
// Useful for editor integrations.
module.exports = require( '@wordpress/prettier-config' );
module.exports = {
...require( '@wordpress/prettier-config' ),
overrides: [
{
files: [ 'changelog.txt' ],
options: { parser: 'markdown' },
},
],
};
4 changes: 4 additions & 0 deletions backport-changelog/6.6/6864.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
https://github.com/WordPress/wordpress-develop/pull/6864

* https://github.com/WordPress/gutenberg/pull/62488
* https://github.com/WordPress/gutenberg/pull/62696
59,019 changes: 30,463 additions & 28,556 deletions changelog.txt

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions lib/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,49 @@ function gutenberg_register_edit_site_export_controller_endpoints() {
}

add_action( 'rest_api_init', 'gutenberg_register_edit_site_export_controller_endpoints' );

if ( ! function_exists( 'gutenberg_register_wp_rest_post_types_controller_fields' ) ) {
/**
* Adds `template` and `template_lock` fields to WP_REST_Post_Types_Controller class.
*/
function gutenberg_register_wp_rest_post_types_controller_fields() {
register_rest_field(
'type',
'template',
array(
'get_callback' => function ( $item ) {
$post_type = get_post_type_object( $item['slug'] );
if ( ! empty( $post_type ) && ! empty( $post_type->template ) ) {
return $post_type->template;
}
},
'schema' => array(
'type' => 'array',
'description' => __( 'The block template associated with the post type, if it exists.', 'gutenberg' ),
'readonly' => true,
'context' => array( 'view', 'edit', 'embed' ),
),
)
);
register_rest_field(
'type',
'template_lock',
array(
'get_callback' => function ( $item ) {
$post_type = get_post_type_object( $item['slug'] );
if ( ! empty( $post_type ) && ! empty( $post_type->template_lock ) && false !== $post_type->template_lock ) {
return $post_type->template_lock;
}
},
'schema' => array(
'type' => 'string',
'enum' => array( 'all', 'insert', 'contentOnly' ),
'description' => __( 'The template_lock associated with the post type, if any.', 'gutenberg' ),
'readonly' => true,
'context' => array( 'view', 'edit', 'embed' ),
),
)
);
}
}
add_action( 'rest_api_init', 'gutenberg_register_wp_rest_post_types_controller_fields' );
113 changes: 88 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"@geometricpanda/storybook-addon-badges": "2.0.1",
"@octokit/rest": "16.26.0",
"@octokit/types": "6.34.0",
"@octokit/webhooks-types": "5.6.0",
"@octokit/webhooks-types": "5.8.0",
"@playwright/test": "1.43.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
"@react-native/babel-preset": "0.73.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
START_OF_SELECTED_AREA,
} from '../../../utils/selection';

function findSelection( blocks ) {
export function findSelection( blocks ) {
let i = blocks.length;

while ( i-- ) {
Expand Down
18 changes: 10 additions & 8 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
create,
split,
toHTMLString,
slice,
} from '@wordpress/rich-text';
import { isURL } from '@wordpress/url';

Expand All @@ -46,6 +45,8 @@ import EmbedHandlerPicker from './embed-handler-picker';
import { Content } from './content';
import RichText from './native';
import { withDeprecations } from './with-deprecations';
import { findSelection } from './event-listeners/input-rules';
import { START_OF_SELECTED_AREA } from '../../utils/selection';

const classes = 'block-editor-rich-text__editable';

Expand Down Expand Up @@ -502,7 +503,7 @@ export function RichTextWrapper(
);

const inputRule = useCallback(
( value, valueToFormat ) => {
( value ) => {
if ( ! onReplace ) {
return;
}
Expand All @@ -518,7 +519,7 @@ export function RichTextWrapper(
return;
}

const trimmedTextBefore = text.slice( 0, startPosition ).trim();
const trimmedTextBefore = text.slice( 0, start ).trim();
const prefixTransforms = getBlockTransforms( 'from' ).filter(
( { type } ) => type === 'prefix'
);
Expand All @@ -533,15 +534,16 @@ export function RichTextWrapper(
return;
}

const content = valueToFormat(
slice( value, startPosition, text.length )
);
const content = toHTMLString( {
value: insert( value, START_OF_SELECTED_AREA, 0, start ),
} );
const block = transformation.transform( content );

const currentSelection = findSelection( [ block ] );
onReplace( [ block ] );
selectionChange( ...currentSelection );
__unstableMarkAutomaticChange();
},
[ onReplace, __unstableMarkAutomaticChange ]
[ onReplace, start, selectionChange, __unstableMarkAutomaticChange ]
);

const mergedRef = useMergeRefs( [ providedRef, fallbackRef ] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,23 @@ export class RichText extends Component {
const contentWithoutRootTag = this.removeRootTagsProducedByAztec(
event.nativeEvent.text
);

const { __unstableInputRule } = this.props;
const currentValuePosition = {
end: this.isIOS ? this.selectionEnd : this.selectionEnd + 1,
start: this.isIOS ? this.selectionStart : this.selectionStart + 1,
};

if (
__unstableInputRule &&
__unstableInputRule( {
...currentValuePosition,
...this.formatToValue( contentWithoutRootTag ),
} )
) {
return;
}

// On iOS, onChange can be triggered after selection changes, even though there are no content changes.
if ( contentWithoutRootTag === this.value?.toString() ) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/audio/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Supply caption styles to audio blocks, even if the theme hasn't opted in.
// Reason being: the new markup, <figcaptions>, are not likely to be styled in the majority of existing themes,
// so we supply the styles so as to not appear broken or unstyled in those themes.
figcaption {
:where(figcaption) {
@include caption-style();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/audio/theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.wp-block-audio figcaption {
.wp-block-audio :where(figcaption) {
@include caption-style-theme();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/embed/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// Supply caption styles to embeds, even if the theme hasn't opted in.
// Reason being: the new markup, figcaptions, are not likely to be styled in the majority of existing themes,
// so we supply the styles so as to not appear broken or unstyled in those.
figcaption {
:where(figcaption) {
@include caption-style();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/embed/theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.wp-block-embed figcaption {
.wp-block-embed :where(figcaption) {
@include caption-style-theme();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
// Supply caption styles to images, even if the theme hasn't opted in.
// Reason being: the new markup, <figcaptions>, are not likely to be styled in the majority of existing themes,
// so we supply the styles so as to not appear broken or unstyled in those themes.
figcaption {
:where(figcaption) {
@include caption-style();
}

Expand Down
Loading

0 comments on commit 4f0f9c7

Please sign in to comment.