Skip to content

Commit

Permalink
Update wordpress monorepo (#102)
Browse files Browse the repository at this point in the history
* Update wordpress monorepo

* Override the 'view' and 'edit' core types request

Collab mode seems to trigger a view context

* Register apiFetch handlers in collab test

A request is now made to WP, possibly as a result of an underlying change in Gutenberg.

Use the apiFetch handler to ignore this request

* Child prop is optional, not required

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: John Godley <johng75@gmail.com>
  • Loading branch information
3 people authored Feb 4, 2022
1 parent 1fb1c5a commit 062846e
Show file tree
Hide file tree
Showing 5 changed files with 630 additions and 551 deletions.
100 changes: 50 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,56 +37,56 @@
"author": "Automattic",
"license": "GPL-2.0-or-later",
"dependencies": {
"@wordpress/a11y": "3.2.4",
"@wordpress/annotations": "2.2.7",
"@wordpress/api-fetch": "5.2.6",
"@wordpress/autop": "3.2.3",
"@wordpress/base-styles": "4.0.4",
"@wordpress/blob": "3.2.2",
"@wordpress/block-editor": "8.0.7",
"@wordpress/block-library": "6.0.11",
"@wordpress/block-serialization-default-parser": "4.2.3",
"@wordpress/block-serialization-spec-parser": "4.2.0",
"@wordpress/blocks": "11.1.4",
"@wordpress/components": "19.1.1",
"@wordpress/compose": "5.0.6",
"@wordpress/core-data": "4.0.8",
"@wordpress/data": "6.1.4",
"@wordpress/data-controls": "2.2.7",
"@wordpress/date": "4.2.3",
"@wordpress/deprecated": "3.2.3",
"@wordpress/dom": "3.2.7",
"@wordpress/dom-ready": "3.2.3",
"@wordpress/edit-post": "5.0.13",
"@wordpress/editor": "12.0.10",
"@wordpress/element": "4.0.4",
"@wordpress/escape-html": "2.2.3",
"@wordpress/format-library": "3.0.13",
"@wordpress/hooks": "3.2.2",
"@wordpress/html-entities": "3.2.3",
"@wordpress/i18n": "4.2.4",
"@wordpress/icons": "6.1.1",
"@wordpress/interface": "4.1.9",
"@wordpress/is-shallow-equal": "4.2.1",
"@wordpress/keyboard-shortcuts": "3.0.6",
"@wordpress/keycodes": "3.2.4",
"@wordpress/list-reusable-blocks": "3.0.11",
"@wordpress/media-utils": "3.0.5",
"@wordpress/notices": "3.2.7",
"@wordpress/plugins": "4.0.6",
"@wordpress/primitives": "3.0.4",
"@wordpress/priority-queue": "2.2.3",
"@wordpress/react-i18n": "3.0.4",
"@wordpress/redux-routine": "4.2.2",
"@wordpress/reusable-blocks": "3.0.13",
"@wordpress/rich-text": "5.0.6",
"@wordpress/server-side-render": "3.0.11",
"@wordpress/shortcode": "3.2.3",
"@wordpress/token-list": "2.2.2",
"@wordpress/url": "3.3.1",
"@wordpress/viewport": "4.0.6",
"@wordpress/warning": "2.2.2",
"@wordpress/wordcount": "3.2.3",
"@wordpress/a11y": "3.3.0",
"@wordpress/annotations": "2.3.0",
"@wordpress/api-fetch": "6.0.0",
"@wordpress/autop": "3.3.0",
"@wordpress/base-styles": "4.1.0",
"@wordpress/blob": "3.3.0",
"@wordpress/block-editor": "8.1.0",
"@wordpress/block-library": "6.1.0",
"@wordpress/block-serialization-default-parser": "4.3.0",
"@wordpress/block-serialization-spec-parser": "4.3.0",
"@wordpress/blocks": "11.2.0",
"@wordpress/components": "19.3.0",
"@wordpress/compose": "5.1.0",
"@wordpress/core-data": "4.1.0",
"@wordpress/data": "6.2.0",
"@wordpress/data-controls": "2.3.0",
"@wordpress/date": "4.3.0",
"@wordpress/deprecated": "3.3.0",
"@wordpress/dom": "3.3.0",
"@wordpress/dom-ready": "3.3.0",
"@wordpress/edit-post": "5.1.0",
"@wordpress/editor": "12.1.0",
"@wordpress/element": "4.1.0",
"@wordpress/escape-html": "2.3.0",
"@wordpress/format-library": "3.1.0",
"@wordpress/hooks": "3.3.0",
"@wordpress/html-entities": "3.3.0",
"@wordpress/i18n": "4.3.0",
"@wordpress/icons": "6.2.0",
"@wordpress/interface": "4.2.0",
"@wordpress/is-shallow-equal": "4.3.0",
"@wordpress/keyboard-shortcuts": "3.1.0",
"@wordpress/keycodes": "3.3.0",
"@wordpress/list-reusable-blocks": "3.1.0",
"@wordpress/media-utils": "3.1.0",
"@wordpress/notices": "3.3.0",
"@wordpress/plugins": "4.1.0",
"@wordpress/primitives": "3.1.0",
"@wordpress/priority-queue": "2.3.0",
"@wordpress/react-i18n": "3.1.0",
"@wordpress/redux-routine": "4.3.0",
"@wordpress/reusable-blocks": "3.1.0",
"@wordpress/rich-text": "5.1.0",
"@wordpress/server-side-render": "3.1.0",
"@wordpress/shortcode": "3.3.0",
"@wordpress/token-list": "2.3.0",
"@wordpress/url": "3.4.0",
"@wordpress/viewport": "4.1.0",
"@wordpress/warning": "2.3.0",
"@wordpress/wordcount": "3.3.0",
"classnames": "^2.3.1",
"debug": "^4.3.3",
"lodash": "^4.17.21",
Expand Down
74 changes: 39 additions & 35 deletions src/components/api-fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,43 @@ function getPost() {
};
}

// Enough data for Gutenberg to work
function getTypes() {
return {
body: {
post: {
capabilities: {
edit_post: 'edit_post',
},
description: '',
hierarchical: false,
viewable: true,
name: 'Posts',
slug: 'post',
labels: {
name: 'Posts',
singular_name: 'Post',
},
supports: {
title: false,
editor: true,
author: false,
thumbnail: false,
excerpt: false,
trackbacks: false,
'custom-fields': false,
comments: false,
revisions: false,
'post-formats': false,
'geo-location': false,
},
taxonomies: [],
rest_base: 'posts',
},
},
};
}

// Provide some basic API preloading. This oils the Gutenberg wheels and allows certain operations to happen without making an external request
function registerApiHandlers( options ) {
const preload = {
Expand All @@ -22,41 +59,8 @@ function registerApiHandlers( options ) {
body: [],
},
},
// Enough data for Gutenberg to work
'/wp/v2/types?context=edit': {
body: {
post: {
capabilities: {
edit_post: 'edit_post',
},
description: '',
hierarchical: false,
viewable: true,
name: 'Posts',
slug: 'post',
labels: {
name: 'Posts',
singular_name: 'Post',
},
supports: {
title: false,
editor: true,
author: false,
thumbnail: false,
excerpt: false,
trackbacks: false,
'custom-fields': false,
comments: false,
revisions: false,
'post-formats': false,
'geo-location': false,
},
taxonomies: [],
rest_base: 'posts',
},
},
},

'/wp/v2/types?context=view': getTypes(),
'/wp/v2/types?context=edit': getTypes(),
'/wp/v2/posts/0?context=edit': getPost(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import userEvent from '@testing-library/user-event';
* Internal dependencies
*/
import IsolatedBlockEditor, { CollaborativeEditing } from '../../../../index';
import registerApiHandlers from '../../../../components/api-fetch';
import { getTransports, pauseTyping } from '../__test-helpers__/utils';

const collabSettings = {
Expand All @@ -17,6 +18,11 @@ const collabSettings = {
};

describe( 'CollaborativeEditing: Undo/Redo', () => {
beforeAll( () => {
// Gutenberg issues an apiFetch at some point
registerApiHandlers();
} );

beforeEach( () => {
// Real timers are used so Yjs can merge undo stack items
jest.useRealTimers();
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function initializeIsoEditor() {
* @param {OnError} props.onError - Error callback
* @param {OnLoad} [props.onLoad] - Initial blocks
* @param {BlockEditorSettings} props.settings - Settings
* @param {object} props.children - Child content
* @param {object} [props.children] - Child content
* @param {string} [props.className] - Additional class name
* @param {OnMore} [props.renderMoreMenu] - Callback to render additional items in the more menu
*/
Expand Down
Loading

0 comments on commit 062846e

Please sign in to comment.