Skip to content

Commit

Permalink
Merge branch 'trunk' of github.com:amitraj2203/gutenberg into fix/iss…
Browse files Browse the repository at this point in the history
…ue-61743
  • Loading branch information
amitraj2203 committed Jun 21, 2024
2 parents 55f3afa + bb73da7 commit 92e1cb8
Show file tree
Hide file tree
Showing 51 changed files with 31,246 additions and 28,747 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' },
},
],
};
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6854.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6854

* https://github.com/WordPress/gutenberg/pull/62670
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,031 changes: 30,470 additions & 28,561 deletions changelog.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Printing since 1440. This is the development plugin for the block editor, site editor, and other future WordPress core functionality.
* Requires at least: 6.4
* Requires PHP: 7.2
* Version: 18.6.0-rc.1
* Version: 18.6.0
* Author: Gutenberg Team
* Text Domain: gutenberg
*
Expand Down
8 changes: 4 additions & 4 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -2933,10 +2933,10 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
$css .= '.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }';
// Alignfull children of the container with left and right padding have negative margins so they can still be full width.
$css .= '.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }';
// Nested children of the container with left and right padding that are not wide or full aligned do not get padding.
$css .= '.has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }';
// Nested children of the container with left and right padding that are not wide or full aligned do not get negative margin applied.
$css .= '.has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0; }';
// Nested children of the container with left and right padding that are not wide or full aligned do not get padding, unless they are direct children of an alignfull flow container.
$css .= '.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }';
// Alignfull direct children of the containers that are targeted by the rule above do not need negative margins.
$css .= '.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0; }';
}

$css .= '.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }';
Expand Down
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' );
117 changes: 90 additions & 27 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "18.6.0-rc.1",
"version": "18.6.0",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down 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 @@ -924,8 +924,8 @@ export const toStyles = (
ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
.has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
.has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }
.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0;
`;
}

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
Loading

0 comments on commit 92e1cb8

Please sign in to comment.