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

[RNMobile] Add OfflineStatus component to display network connectivity #56627

Closed
wants to merge 85 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
bdd3d5b
Style Revisions: Remove style revisions dropdown menu (#56454)
apeatling Nov 27, 2023
84d2b22
Font Library: fix fonts not displaying correctly (#55393)
jffng Nov 27, 2023
beb4756
(RichText)(Workaround)(17.1.x) Fallback to a string arg in `collapseW…
fullofcaffeine Nov 28, 2023
00edec5
Bump plugin version to 17.1.3
gutenbergplugin Nov 28, 2023
659891d
Update Changelog for 17.1.3
gutenbergplugin Nov 28, 2023
fc23bd3
Add setting to disable custom content size controls (#56236)
tellthemachines Nov 28, 2023
7f393de
Docs: Fundamentals of Block Development - Registration of a block (#5…
juanmaguitar Nov 28, 2023
6b218a3
Docs: Fundamentals of Block Development - Working with Javascript in …
juanmaguitar Nov 28, 2023
7a0cb70
Docs: Fundamentals of Block Development - File structure of a block (…
juanmaguitar Nov 28, 2023
31aa988
File block: Remove anchor tag when copy pasting to file name (#56508)
t-hamano Nov 28, 2023
fa34a42
Migrate 'align hook' e2e tests to Playwright (#56480)
Mamaduka Nov 28, 2023
d4ef84e
Editor styles: scope without adding specificity (#56564)
ellatrix Nov 28, 2023
7d4abbe
Data list view: Make filter row, table header, and pagination sticky …
jameskoster Nov 28, 2023
7dd6ecf
Workflows: Update 'days-before-stale' for flaky test report issues (#…
Mamaduka Nov 28, 2023
df30be2
Gallery Block: Use styled scrollbars for image captions (#56252)
t-hamano Nov 28, 2023
227008b
Documentation: Add the transforms page to the create block tutorial o…
youknowriad Nov 28, 2023
9c63fb9
Dataviews: Add confirmation step before deleting a page (#56504)
ntsekouras Nov 28, 2023
65a6158
Update trash icon (#56569)
jameskoster Nov 28, 2023
b5a07af
Update: Refactor useAddedBy to use authorText and originalSource fiel…
jorgefilipecosta Nov 28, 2023
1bfd62b
WP_Theme_JSON_Gutenberg: Add nested indexed array schema sanitization…
matiasbenedetto Nov 28, 2023
82b4b3e
Mobile - Fix issue when backspacing in an empty Paragraph block (#56496)
Nov 28, 2023
ba95a1e
Rich Text: Update the regex that checks the format of className in Fo…
alexandrebuffet Nov 28, 2023
4db7f07
Raw handling: fix block schema merging (#56558)
ellatrix Nov 28, 2023
2f2e4c5
Dataviews: All Templates: Add filters to template author. (#56338)
jorgefilipecosta Nov 28, 2023
5cdc434
Fundamentals block development - landing and first pages (#56584)
juanmaguitar Nov 28, 2023
9b95b63
Blocks pkg: remove 'browser' dependencies (#56433)
ellatrix Nov 28, 2023
5d41abe
Interactivity API: migration to the new `store()` API (#55459)
DAreRodz Nov 28, 2023
fd866bc
HTML API: Backport updates from Core (#56578)
dmsnell Nov 28, 2023
4cec0c8
Fundamentals of Block Development - fix save definition (#56605)
juanmaguitar Nov 28, 2023
c4df1d7
Core data revisions: extend support to other post types (#56353)
ramonjd Nov 29, 2023
a1e21ab
Migrate 'block directory' e2e tests to Playwright (#56593)
Mamaduka Nov 29, 2023
3e6c130
Add OfflineStatus component to display network connectivity
derekblank Nov 29, 2023
d457f9d
Update CHANGELOG
derekblank Nov 29, 2023
edb40b2
Update packages/react-native-editor/CHANGELOG.md
derekblank Nov 30, 2023
125ca2b
Move offline icon to icons library
derekblank Nov 30, 2023
dc27fa3
Add cleanup function to OfflineStatus animation
derekblank Nov 30, 2023
e32996b
Remove OfflineStatus animation
derekblank Dec 1, 2023
768873f
Move OfflineStatus component to editor package
derekblank Dec 1, 2023
693d54f
Dataviews: Grid layout refinements (#56441)
ntsekouras Nov 29, 2023
365767a
Performance: avoid calling postcss when not needed (#56601)
ellatrix Nov 29, 2023
3de729e
Docs: Fundamentals of Block Development - block.json (#56435)
juanmaguitar Nov 29, 2023
a9b54c1
Restore placeholder to Post Title field (#56580)
getdave Nov 29, 2023
d6d7399
Docs: Fundamentals of Block Development - The block wrapper (#56596)
juanmaguitar Nov 29, 2023
90982db
Add missing changelog entry (#56611)
DAreRodz Nov 29, 2023
2296e54
Migrate 'block icons' e2e tests to Playwright (#56610)
Mamaduka Nov 29, 2023
ab8313a
Create block: Update `interactive-template` to the new `store()` API …
DAreRodz Nov 29, 2023
a81cec4
Restore Post Title visual styles in Code View mode (#56582)
getdave Nov 29, 2023
9cecf39
Migrate Is Typing Test to Playwright (#56616)
jeryj Nov 29, 2023
63a792e
DataViews: document `view.layout` (#56637)
oandregal Nov 29, 2023
6418235
scripts: update `jest-dev-server` to v9 (#56552)
flootr Nov 29, 2023
4be99fb
Dataviews: Add first e2e tests (#56634)
ntsekouras Nov 29, 2023
48abc88
Text and Heading: improve docs around default values and truncation l…
ciampo Nov 29, 2023
f436fa0
FormToggle: refine animation (#56515)
ciampo Nov 29, 2023
8679870
Fix label of columns inspector panel (#56647)
megane9988 Nov 29, 2023
bce6f45
Interactivity API: Use modules instead of scripts in the frontend (#5…
luisherranz Nov 29, 2023
6b3daba
Bump plugin version to 17.2.0-rc.1
gutenbergplugin Nov 29, 2023
557b672
Update Changelog for 17.2.0-rc.1
gutenbergplugin Nov 29, 2023
b934454
Update changelog files
gutenbergplugin Nov 29, 2023
11a12b3
chore(release): publish
gutenbergplugin Nov 29, 2023
f0c1688
Docs: Fundamentals of Block Development ---- Small fixes for "Block w…
juanmaguitar Nov 29, 2023
005d03b
Move the importmap to a folder (#56655)
luisherranz Nov 29, 2023
77f89d2
Move InserterButton from components package to block-editor package (…
derekblank Nov 30, 2023
7a37e42
Social Icons: add Gravatar service (#56544)
jeherve Nov 30, 2023
071ce54
Fix input not showing when switching to "Fixed" width (#56660)
tellthemachines Nov 30, 2023
946cc09
Editor: Fix issue where createBlock in block template caused list vie…
andrewserong Nov 30, 2023
ee7083b
DataViews: make the `mediaField` not hidable (#56643)
oandregal Nov 30, 2023
9733cd3
Decode some characters if used in taxonomy name so it's displayed cor…
kmanijak Nov 30, 2023
f14a23c
DataViews: make `Actions` styles the same as any other column header …
oandregal Nov 30, 2023
f778113
Scripts: Enable skipping Playwright browser installation (#56594)
WunderBart Nov 30, 2023
c152235
Migrate 'editor multi entity saving' e2e tests to Playwright (#56670)
Mamaduka Nov 30, 2023
2ebdbf9
Migrate 'inner-blocks-locking-all-embed' e2e tests to Playwright (#56…
Mamaduka Nov 30, 2023
00fe3b9
Align data view icon usage (#56602)
jameskoster Nov 30, 2023
ccd8dce
Mobile Release v1.109.1 (#56644)
Nov 30, 2023
c33e058
DataViews: export the view components as defaults (#56677)
oandregal Nov 30, 2023
eb35d0c
setImmutably: don't clone all objects (#56612)
ellatrix Nov 30, 2023
4bead47
Migrate 'site editor export' e2e tests to Playwright (#56675)
Mamaduka Nov 30, 2023
04d21d8
Fix order of typography sizes and families (#56659)
ajlende Nov 30, 2023
54d02b4
Editor: Avoid double parsing content in 'getSuggestedPostFormat' sele…
Mamaduka Nov 30, 2023
b6bd315
`QueryControls`: Add opt-in prop for 40px default size (#56576)
brookewp Nov 30, 2023
ba9e58c
[RNMobile] Fixes a crash on pasting MS Word list markup (#56653)
fluiddot Nov 30, 2023
971ecd7
FormToggle: do not use "/" math operator (#56672)
ciampo Nov 30, 2023
b213b80
Remove OfflineStatus styles from layout native style file
derekblank Dec 1, 2023
dc8af65
Update packages/react-native-editor/CHANGELOG.md
derekblank Dec 6, 2023
d628200
Move OfflineStatus component to block-editor package
derekblank Dec 6, 2023
aabe0d1
Add style support for Dark Mode and use BEM scss syntax
derekblank Dec 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ jobs:
npm run wp-env start

- name: Run the tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: |
xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e:playwright -- --shard=${{ matrix.part }}/${{ matrix.totalParts }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stale-issue-gardening.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
remove-stale-when-updated: true
stale-issue-label: '[Status] Stale'
- name: 'Flaky test issues without activity'
message: 'This issue has gone 30 days without any activity.'
days-before-stale: 30
message: 'This issue has gone 15 days without any activity.'
days-before-stale: 15
days-before-close: 1
only-labels: '[Type] Flaky Test'
remove-stale-when-updated: true
Expand Down
1 change: 1 addition & 0 deletions bin/plugin/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async function runTestSuite( testSuite, testRunnerDir, runKey ) {
testRunnerDir,
{
...process.env,
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1',
WP_ARTIFACTS_PATH: ARTIFACTS_PATH,
RESULTS_ID: runKey,
}
Expand Down
323 changes: 323 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions docs/getting-started/fundamentals/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Fundamentals of Block Development

This section provides an introduction to the most relevant concepts in Block Development.

In this section, you will learn:

1. [**File structure of a block**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/file-structure-of-a-block) - The purpose of each one of the types of files available for a block, the relationships between them, and their role in the output of the block.
1. [**`block.json`**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/block-json) - How a block is defined using its `block.json` metadata and some relevant properties of this file.
1. [**Registration of a block**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/registration-of-a-block) - How a block is registered in both the server and the client.
1. [**Block wrapper**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/block-wrapper) - How to set proper attributes to the block's markup wrapper.
1. [**Javascript in the Block Editor**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/javascript-in-the-block-editor) - How to work with Javascript for the Block Editor.
115 changes: 115 additions & 0 deletions docs/getting-started/fundamentals/block-json.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# block.json

The `block.json` file simplifies the processs of defining and registering a block by using the same block's definition in JSON format to register the block in both the server and the client.

[![Open block.json diagram in excalidraw](https://developer.wordpress.org/files/2023/11/block-json.png)](https://excalidraw.com/#json=v1GrIkGsYGKv8P14irBy6,Yy0vl8q7DTTL2VsH5Ww27A "Open block.json diagram in excalidraw")

<div class="callout callout-tip">
Click <a href="https://github.com/WordPress/block-development-examples/tree/trunk/plugins/block-supports-6aa4dd">here</a> to see a full block example and check <a href="https://github.com/WordPress/block-development-examples/blob/trunk/plugins/block-supports-6aa4dd/src/block.json">its <code>block.json</code></a>
</div>

Besides simplifying a block's registration, using a `block.json` has [several benefits](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#benefits-using-the-metadata-file), including improved performance and development.

At [**Metadata in block.json**](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/) you can find a detailed explanation of all the properties you can set in a `block.json` for a block. With these properties you can define things such as:

- Basic metadata of the block
- Files for the block's behavior, style, or output
- Data Storage in the Block
- Setting UI panels for the block

## Basic metadata of the block

Through properties of the `block.json`, we can define how the block will be uniquely identified, how it can be found, and the info displayed for the block in the Block Editor. Some of these properties are:

- `apiVersion`: the version of [the API](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/) used by the block (current version is 2).
- `name`: a unique identifier for a block, including a namespace.
- `title`: a display title for a block.
- `category`: a block category for the block in the Inserter panel.
- `icon`: a [Dashicon](https://developer.wordpress.org/resource/dashicons) slug or a custom SVG icon.
- `description`: a short description visible in the block inspector.
- `keywords`: to locate the block in the inserter.
- `textdomain`: the plugin text-domain (important for things such as translations).

## Files for the block's behavior, output, or style

The `editorScript` and `editorStyle` properties allow defining Javascript and CSS files to be enqueued and loaded **only in the editor**.

The `script` and `style` properties allow the definition of Javascript and CSS files to be enqueued and loaded **in both the editor and the front end**.

The `viewScript` property allow us to define the Javascript file or files to be enqueued and loaded **only in the front end**.

All these properties (`editorScript`, `editorStyle`, `script` `style`,`viewScript`) accept as a value a path for the file, a handle registered with `wp_register_script` or `wp_register_style`, or an array with a mix of both. Paths values in `block.json` are prefixed with `file:`.

The `render` property ([introduced on WordPress 6.1](https://make.wordpress.org/core/2022/10/12/block-api-changes-in-wordpress-6-1/)) sets the path of a `.php` template file that will render the markup returned to the front end. This only method will be used to return the markup for the block on request only if `$render_callback` function has not been passed to the `register_block_type` function.

## Data Storage in the Block with `attributes`

The [`attributes` property](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/) allows a block to declare "variables" that store data or content for the block.

_Example: Attributes as defined in block.json_
```json
"attributes": {
"fallbackCurrentYear": {
"type": "string"
},
"showStartingYear": {
"type": "boolean"
},
"startingYear": {
"type": "string"
}
},
```
By default `attributes` are serialized and stored in the block's delimiter but this [can be configured](https://developer.wordpress.org/news/2023/09/understanding-block-attributes/).

_Example: Atributes stored in the Markup representation of the block_
```html
<!-- wp:block-development-examples/copyright-date-block-09aac3 {"fallbackCurrentYear":"2023","showStartingYear":true,"startingYear":"2020"} -->
<p class="wp-block-block-development-examples-copyright-date-block-09aac3">© 2020–2023</p>
<!-- /wp:block-development-examples/copyright-date-block-09aac3 -->x
```

These attributes are passed to the React component `Edit`(to display in the Block Editor) and the `save` function (to return the markup saved to the DB) of the block, and to any server-side render definition for the block (see `render` prop above).

The `Edit` component receives exclusively the capability of updating the attributes via the `setAttributes` function.

_See how the attributes are passed to the [`Edit` component](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/copyright-date-block-09aac3/src/edit.js), [the `save` function](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/copyright-date-block-09aac3/src/save.js) and [the `render.php`](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/copyright-date-block-09aac3/src/render.php) in this [full block example](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/copyright-date-block-09aac3) of the code above_

<div class="callout callout-info">
Check the <a href="https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/"> <code>attributes</code> </a> reference page for full info about the Attributes API.
</div>

[![Open Attributes diagram in excalidraw](https://developer.wordpress.org/files/2023/11/attributes.png)](https://excalidraw.com/#json=pSgCZy8q9GbH7r0oz2fL1,MFCLd6ddQHqi_UqNp5ZSgg "Open Attributes diagram in excalidraw")


## Enable UI settings panels for the block with `supports`

The `supports` property allows a block to declare support for certain features, enabling users to customize specific settings (like colors or margins) from the Settings Sidebar.

_Example: Supports as defined in block.json_

```json
"supports": {
"color": {
"text": true,
"link": true,
"background": true
}
}
```

The use of `supports` generates a set of properties that need to be manually added to the wrapping element of the block so they're properly stored as part of the block data.

_Example: Supports custom settings stored in the Markup representation of the block_

```html
<!-- wp:block-development-examples/block-supports-6aa4dd {"backgroundColor":"contrast","textColor":"accent-4"} -->
<p class="wp-block-block-development-examples-block-supports-6aa4dd has-accent-4-color has-contrast-background-color has-text-color has-background">Hello World</p>
<!-- /wp:block-development-examples/block-supports-6aa4dd -->
```

_See the [full block example](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/block-supports-6aa4dd) of the [code above](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/block-supports-6aa4dd/src/block.json)_

<div class="callout callout-info">
Check the <a href="https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/"> <code>supports</code> </a> reference page for full info about the Supports API.
</div>
114 changes: 114 additions & 0 deletions docs/getting-started/fundamentals/block-wrapper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# The block wrapper

Each block's markup is wrapped by a container HTML tag that needs to have the proper attributes to fully work in the Block Editor and to reflect the proper block's style settings when rendered in the Block Editor and the front end. As developers, we have full control over the block's markup, and WordPress provides the tools to add the attributes that need to exist on the wrapper to our block's markup.

Ensuring proper attributes to the block wrapper is especially important when using custom styling or features like `supports`.

<div class="callout callout-info">
The use of <code>supports</code> generates a set of properties that need to be manually added to the wrapping element of the block so they're properly stored as part of the block data
</div>

A block can have three sets of markup defined, each one of them with a specific target and purpose:

- The one for the **Block Editor**, defined through a `edit` React component passed to `registerBlockType` when registering the block in the client.
- The one used to **save the block in the DB**, defined through a `save` function passed to `registerBlockType` when registering the block in the client.
- This markup will be returned to the front end on request if no dynamic render has been defined for the block.
- The one used to **dynamically render the markup of the block** returned to the front end on request, defined through the `render_callback` on `register_block_type` or the `render` PHP file in `block.json`
- If defined, this server-side generated markup will be returned to the front end, ignoring the markup stored in DB.

For the React component `edit` and the `save` function, the block wrapper element should be a native DOM element (like `<div>`) or a React component that forwards any additional props to native DOM elements. Using a <Fragment> or <ServerSideRender> component, for instance, would be invalid.


## The Edit component's markup

The `useBlockProps()` hook available on the `@wordpress/block-editor` allows passing the required attributes for the Block Editor to the `edit` block's outer wrapper.

Among other things, the `useBlockProps()` hook takes care of including in this wrapper:
- An `id` for the block's markup
- Some accesibility and `data-` attributes
- Classes and inline styles reflecting custom settings, which include by default:
- The `wp-block` class
- A class that contains the name of the block with its namespace

For example, for the following piece of code of a block's registration in the client...

```js
const Edit = () => <p { ...useBlockProps() }>Hello World - Block Editor</p>;

registerBlockType( ..., {
edit: Edit
} );
```
_(see the [code above](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/minimal-block-ca6eda/src/index.js) in [an example](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/minimal-block-ca6eda))_

...the markup of the block in the Block Editor could look like this:
```html
<p
tabindex="0"
id="block-4462939a-b918-44bb-9b7c-35a0db5ab8fe"
role="document"
aria-label="Block: Minimal Gutenberg Block ca6eda"
data-block="4462939a-b918-44bb-9b7c-35a0db5ab8fe"
data-type="block-development-examples/minimal-block-ca6eda"
data-title="Minimal Gutenberg Block ca6eda"
class="
block-editor-block-list__block
wp-block
is-selected
wp-block-block-development-examples-minimal-block-ca6eda
"
>Hello World - Block Editor</p>
```

Any additional classes and attributes for the `Edit` component of the block should be passed as an argument of `useBlockProps` (see [example](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/stylesheets-79a4c3/src/edit.js)). When you add `support` for any feature, they get added to the object returned by the `useBlockProps` hook.


## The Save component's markup

When saving the markup in the DB, it’s important to add the block props returned by `useBlockProps.save()` to the wrapper element of your block. `useBlockProps.save()` ensures that the block class name is rendered properly in addition to any HTML attribute injected by the block supports API.

For example, for the following piece of code of a block's registration in the client that defines the markup desired for the DB (and returned to the front end by default)...

```js
const Edit = () => <p { ...useBlockProps() }>Hello World - Block Editor</p>;
const save = () => <p { ...useBlockProps.save() }>Hello World - Frontend</p>;

registerBlockType( ..., {
edit: Edit,
save,
} );
```

_(see the [code above](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/minimal-block-ca6eda/src/index.js) in [an example](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/minimal-block-ca6eda))_


...the markup of the block in the front end could look like this:
```html
<p class="wp-block-block-development-examples-minimal-block-ca6eda">Hello World – Frontend</p>
```

Any additional classes and attributes for the `save` function of the block should be passed as an argument of `useBlockProps.save()` (see [example](https://github.com/WordPress/block-development-examples/blob/trunk/plugins/stylesheets-79a4c3/src/save.js)).

When you add `support` for any feature, the proper classes get added to the object returned by the `useBlockProps.save()` hook.

```html
<p class="
wp-block-block-development-examples-block-supports-6aa4dd
has-accent-4-color
has-contrast-background-color
has-text-color
has-background
">Hello World</p>
```

_(check the [example](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/block-supports-6aa4dd) that generated the HTML above in the front end)_

## The server-side render markup

Any markup in the server-side render definition for the block can use the [`get_block_wrapper_attributes()`](https://developer.wordpress.org/reference/functions/get_block_wrapper_attributes/) function to generate the string of attributes required to reflect the block settings (see [example](https://github.com/WordPress/block-development-examples/blob/f68640f42d993f0866d1879f67c73910285ca114/plugins/block-dynamic-rendering-64756b/src/render.php#L11)).

```php
<p <?php echo get_block_wrapper_attributes(); ?>>
<?php esc_html_e( 'Block with Dynamic Rendering – hello!!!', 'block-development-examples' ); ?>
</p>
```
Loading
Loading