Skip to content

Conversation

@westonruter
Copy link
Owner

@westonruter westonruter commented Oct 19, 2020

See mkaz/code-syntax-block#88

Props @mkaz

Fixes #188
Fixes #201

src/index.js Outdated
};

// GB 9.2, WP 5.6
const blockProps = useBlockProps && useBlockProps();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting an ESLint failure here:

ESLint: React Hook "useBlockProps" is called in function "edit" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter.(react-hooks/rules-of-hooks)

@westonruter
Copy link
Owner Author

Blocked by WordPress/gutenberg#26301.

@mkaz
Copy link

mkaz commented Oct 24, 2020

Thanks for the collaboration 👍

I tested out this PR and it worked fine on WP 5.5 with and without the GB 9.2.1 plugin, also tested on WP 5.6 and it worked fine.

I did see an error when testing in 5.3, it looks like it is in the escapeRichText function, the lodash flow looks like it wants a function and you're passing in the content string, not sure why I only saw the error in 5.3 and not the others, seems like it should be the opposite 🤷‍♂️

lodash.min.js?ver=4.17.15:48 Uncaught (in promise) TypeError: Expected a function
    at lodash.min.js?ver=4.17.15:48
    at n (lodash.min.js?ver=4.17.15:5)
    at lodash.min.js?ver=4.17.15:63
    at index.js?ver=8ab3a5043761424bde13bbf7fc5fccfe:1
    at save (index.js?ver=8ab3a5043761424bde13bbf7fc5fccfe:1)
    at vt (blocks.min.js?ver=6.7.2:2)
    at kt (blocks.min.js?ver=6.7.2:2)
    at block-editor.min.js?ver=3.2.4:49
    at hooks.min.js?ver=2.6.0:1
    at lr (blocks.min.js?ver=6.7.2:2)

Here is a screen grab, run in WP 5.3, add block, save and reload editor:

syntax-highlighter

@westonruter
Copy link
Owner Author

Humm. For some reason it is getting imported as a module:

image

@westonruter
Copy link
Owner Author

westonruter commented Oct 26, 2020

Oh, well it's trying to import escapeEditableHTML from @wordpress/escape-html, but in WordPress 5.3 this was not yet introduced yet: https://github.com/WordPress/gutenberg/blob/%40wordpress/escape-html%401.5.1/packages/escape-html/src/index.js

Still, I thought that importing a non-existent function would result in escapeEditableHTML being null not a module.

@westonruter
Copy link
Owner Author

I did see an error when testing in 5.3, it looks like it is in the escapeRichText function, the lodash flow looks like it wants a function and you're passing in the content string, not sure why I only saw the error in 5.3 and not the others, seems like it should be the opposite 🤷‍♂️

@mkaz How's this work for you now after 061d147?

@westonruter westonruter requested a review from allejo October 26, 2020 20:49
@westonruter westonruter marked this pull request as ready for review October 26, 2020 20:50
@mkaz
Copy link

mkaz commented Oct 26, 2020

@westonruter Latest change works for me both in WP 5.3 and WP 5.6 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Escaped content in save function is now double-escaped in Gutenberg Warning: wp.editor.InspectorControls is deprecated

3 participants