Skip to content

Commit

Permalink
prep build 11/05
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Nov 5, 2024
2 parents 8051227 + 2da866b commit 5a9c281
Show file tree
Hide file tree
Showing 37 changed files with 814 additions and 230 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

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

6 changes: 3 additions & 3 deletions packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ When creating a new package, you need to provide at least the following. Package

This assumes that your code is located in the `src` folder and will be transpiled with `Babel`.

For packages that should ship as a WordPress script, include `wpScript: true` in the `package.json` file. This tells the build system to bundle the package for use as a WordPress script.
For production packages that will ship as a WordPress script, include `wpScript: true` in the `package.json` file. This tells the build system to bundle the package for use as a WordPress script.

For packages that should ship as a WordPress script module, include a `wpScriptModuleExports` field the `package.json` file. The value of this field can be a string to expose a single script module, or an object with a [shape like the standard `exports` object](https://nodejs.org/docs/latest-v20.x/api/packages.html#subpath-exports) to expose multiple script modules from a single package:
For production packages that will ship as a WordPress script module, include a `wpScriptModuleExports` field in the `package.json` file. The value of this field can be a string to expose a single script module, or an object with a [shape like the standard `exports` object](https://nodejs.org/docs/latest-v20.x/api/packages.html#subpath-exports) to expose multiple script modules from a single package:

```jsonc
{
Expand All @@ -64,7 +64,7 @@ When creating a new package, you need to provide at least the following. Package
}
```

Both `wpScript` and `wpScriptModuleExports` may be included if the package exposes both a script and a script module.
Both `wpScript` and `wpScriptModuleExports` may be included if the package exposes both a script and a script module. These fields are also essential when performing a license check for all their dependencies, because they trigger strict validation against compatibility with GPL v2. All remaining dependencies WordPress doesn't distribute but uses for development purposes can contain also a few other OSS compatible licenses.
1. `README.md` file containing at least:
- Package name
Expand Down
8 changes: 4 additions & 4 deletions packages/block-editor/src/components/block-popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
*/
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
import usePopoverScroll from './use-popover-scroll';
import { rectUnion, getVisibleElementBounds } from '../../utils/dom';
import { rectUnion, getElementBounds } from '../../utils/dom';

const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;

Expand Down Expand Up @@ -90,10 +90,10 @@ function BlockPopover(
getBoundingClientRect() {
return lastSelectedElement
? rectUnion(
getVisibleElementBounds( selectedElement ),
getVisibleElementBounds( lastSelectedElement )
getElementBounds( selectedElement ),
getElementBounds( lastSelectedElement )
)
: getVisibleElementBounds( selectedElement );
: getElementBounds( selectedElement );
},
contextElement: selectedElement,
};
Expand Down
3 changes: 1 addition & 2 deletions packages/block-editor/src/components/block-tools/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
}
}

// The black plus that shows up on the right side of an empty paragraph block,
// or the initial appender that exists only on empty documents.
// The black plus that shows up on the right side of an empty paragraph block.
.block-editor-block-list__empty-block-inserter.block-editor-block-list__empty-block-inserter {
position: absolute;
top: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { store as blockEditorStore } from '../../store';
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { hasStickyOrFixedPositionValue } from '../../hooks/position';
import { getVisibleElementBounds } from '../../utils/dom';
import { getElementBounds } from '../../utils/dom';

const COMMON_PROPS = {
placement: 'top-start',
Expand Down Expand Up @@ -68,7 +68,7 @@ function getProps(
// Get how far the content area has been scrolled.
const scrollTop = scrollContainer?.scrollTop || 0;

const blockRect = getVisibleElementBounds( selectedBlockElement );
const blockRect = getElementBounds( selectedBlockElement );
const contentRect = contentElement.getBoundingClientRect();

// Get the vertical position of top of the visible content area.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
}
}

// The initial appender that exists only on empty documents.
.block-editor-default-block-appender .block-editor-inserter {
position: absolute;
top: 0;
right: 0;
line-height: 0;

&:disabled {
display: none;
}
}

/**
* Fixed position appender (right bottom corner).
Expand Down
7 changes: 3 additions & 4 deletions packages/block-editor/src/components/url-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,9 @@ class URLInput extends Component {
<Popover placement="bottom" focusOnMount={ false }>
<div
{ ...suggestionsListProps }
className={ clsx(
'block-editor-url-input__suggestions',
`${ className }__suggestions`
) }
className={ clsx( 'block-editor-url-input__suggestions', {
[ `${ className }__suggestions` ]: className,
} ) }
>
{ suggestions.map( ( suggestion, index ) => (
<Button
Expand Down
46 changes: 26 additions & 20 deletions packages/block-editor/src/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,41 +134,47 @@ function isScrollable( element ) {
);
}

export const WITH_OVERFLOW_ELEMENT_BLOCKS = [ 'core/navigation' ];
/**
* Returns the rect of the element including all visible nested elements.
*
* Visible nested elements, including elements that overflow the parent, are
* taken into account.
*
* This function is useful for calculating the visible area of a block that
* contains nested elements that overflow the block, e.g. the Navigation block,
* which can contain overflowing Submenu blocks.
* Returns the bounding rectangle of an element, with special handling for blocks
* that have visible overflowing children (defined in WITH_OVERFLOW_ELEMENT_BLOCKS).
*
* For blocks like Navigation that can have overflowing elements (e.g. submenus),
* this function calculates the combined bounds of both the parent and its visible
* children. The returned rect may extend beyond the viewport.
* The returned rect represents the full extent of the element and its visible
* children, which may extend beyond the viewport.
*
* @param {Element} element Element.
* @return {DOMRect} Bounding client rect of the element and its visible children.
*/
export function getVisibleElementBounds( element ) {
export function getElementBounds( element ) {
const viewport = element.ownerDocument.defaultView;

if ( ! viewport ) {
return new window.DOMRectReadOnly();
}

let bounds = element.getBoundingClientRect();
const stack = [ element ];
let currentElement;

while ( ( currentElement = stack.pop() ) ) {
// Children won’t affect bounds unless the element is not scrollable.
if ( ! isScrollable( currentElement ) ) {
for ( const child of currentElement.children ) {
if ( isElementVisible( child ) ) {
const childBounds = child.getBoundingClientRect();
bounds = rectUnion( bounds, childBounds );
stack.push( child );
const dataType = element.getAttribute( 'data-type' );

/*
* For blocks with overflowing elements (like Navigation), include the bounds
* of visible children that extend beyond the parent container.
*/
if ( dataType && WITH_OVERFLOW_ELEMENT_BLOCKS.includes( dataType ) ) {
const stack = [ element ];
let currentElement;

while ( ( currentElement = stack.pop() ) ) {
// Children won’t affect bounds unless the element is not scrollable.
if ( ! isScrollable( currentElement ) ) {
for ( const child of currentElement.children ) {
if ( isElementVisible( child ) ) {
const childBounds = child.getBoundingClientRect();
bounds = rectUnion( bounds, childBounds );
stack.push( child );
}
}
}
}
Expand Down
Loading

0 comments on commit 5a9c281

Please sign in to comment.