Automattic / isolated-block-editor

Repackages Gutenberg's editor playground as a full-featured multi-instance editor that does not require WordPress.
328 stars 48 forks source link

Not working with WordPress 6.6 #260

Open rafaucau opened 1 month ago

rafaucau commented 1 month ago

ref: #254

After updating to WordPress 6.6, the Isolated Block Editor is not working. Error in the console:

Uncaught Error: You tried to opt-in to unstable APIs without confirming you know the consequences. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on the next WordPress release.
    at __dangerousOptInToUnstableAPIsOnlyForCoreModules (private-apis.js?ver=53100b466d825a8b9022:115:11)
    at ../../../node_modules/.pnpm/@automattic+isolated-block-editor@2.29.0_@babel+helper-module-imports@7.24.7_@babel+types@7.2_4lglvpqjpsedbgvkrr4wlluyyq/node_modules/@automattic/isolated-block-editor/build-module/components/block-editor/unlock.js (unlock.js:7:53)
    at __webpack_require__ (chunk loaded:30:1)
    at ../../../node_modules/.pnpm/@automattic+isolated-block-editor@2.29.0_@babel+helper-module-imports@7.24.7_@babel+types@7.2_4lglvpqjpsedbgvkrr4wlluyyq/node_modules/@automattic/isolated-block-editor/build-module/components/block-editor/sidebar-heading.js (post-text-editor.js:114:1)
    at __webpack_require__ (chunk loaded:30:1)
    at ../../../node_modules/.pnpm/@automattic+isolated-block-editor@2.29.0_@babel+helper-module-imports@7.24.7_@babel+types@7.2_4lglvpqjpsedbgvkrr4wlluyyq/node_modules/@automattic/isolated-block-editor/build-module/components/block-editor/sidebar.js (sidebar-heading.js:41:1)
    at __webpack_require__ (chunk loaded:30:1)
    at ../../../node_modules/.pnpm/@automattic+isolated-block-editor@2.29.0_@babel+helper-module-imports@7.24.7_@babel+types@7.2_4lglvpqjpsedbgvkrr4wlluyyq/node_modules/@automattic/isolated-block-editor/build-module/components/block-editor/index.js (footer.js:44:1)
    at __webpack_require__ (chunk loaded:30:1)
    at ../../../node_modules/.pnpm/@automattic+isolated-block-editor@2.29.0_@babel+helper-module-imports@7.24.7_@babel+types@7.2_4lglvpqjpsedbgvkrr4wlluyyq/node_modules/@automattic/isolated-block-editor/build-module/components/block-editor-contents/index.js (editor-content.js:45:1)

Opt-in string was changed in https://github.com/WordPress/gutenberg/pull/62635, so ISO Editor also needs to update it

johngodley commented 1 month ago

Yes, it is not compatible with WP 6.6

rafaucau commented 1 month ago

I did for a test search replace all occurrences of I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress. on I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress. in the package files, and it seems to work. Only the toolbar styles are messed up.

lihsaa591 commented 1 month ago

Yes, it is not compatible with WP 6.6

Is there any info about the new update? Compatible with WP6.6? @johngodley

johngodley commented 1 month ago

Is there any info about the new update? Compatible with WP6.6

No, there is no info.

imrantushar commented 1 month ago

We are also facing same issues

lihsaa591 commented 1 month ago

I make a workaround by overriding private-api.js and now it's working.

lihsaa591 commented 1 month ago

if ( version_compare( get_bloginfo( 'version' ), '6.6', '>=' ) ) { $suffix = SCRIPT_DEBUG ? '.js' : '.min.js'; wp_deregister_script( 'wp-private-apis' ); wp_register_script( 'wp-private-apis', plugins_url( 'libs/private-apis' . $suffix, PLUGIN_FILE ), array(), PLUGIN_VERSION, true ); }

Download private-api.js from the previous WP and add it to your plugin folder.

rafaucau commented 1 month ago

Here is my workaround:

  1. Install replace-in-file: npm i replace-in-file.
  2. Create fix-iso-editor.json:
    {
    "files": "node_modules/@automattic/isolated-block-editor/**/*",
    "from": "I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress",
    "to": "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress"
    }
  3. Add postinstall script to package.json:
    "postinstall": "replace-in-file --configFile=fix-iso-editor.json"
  4. Run npm install.

Full package.json example:

{
    "private": true,
    "scripts": {
        "dev": "wp-scripts start",
        "dev:hot": "wp-scripts start --hot",
        "build": "wp-scripts build",
        "postinstall": "replace-in-file --configFile=fix-iso-editor.json"
    },
    "dependencies": {
        "@automattic/isolated-block-editor": "^2.29.0",
        "replace-in-file": "^8.1.0"
    }
}