Skip to content

Commit

Permalink
fixed JS error when inserting response to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-o committed Dec 9, 2024
1 parent bb7b0b6 commit 8df21ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
extends: ['plugin:@wordpress/eslint-plugin/recommended'],
settings: {
'import/core-modules': ['jquery', 'lodash'],
},
};
30 changes: 7 additions & 23 deletions src/editor/components/editor-styles/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
/**
* WordPress dependencies
*/
// eslint-disable-next-line import/no-extraneous-dependencies
import { compact, map } from 'lodash';
import { createPortal, useContext, useMemo } from '@wordpress/element';
import { transformStyles, BlockList } from '@wordpress/block-editor';

const { elementContext: __stableElementContext, __unstableElementContext } =
BlockList;

const elementContext = __stableElementContext || __unstableElementContext;
import { transformStyles } from '@wordpress/block-editor';
import { useMemo } from '@wordpress/element';

const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';

Expand All @@ -35,19 +27,11 @@ export default function EditorStyles(props) {
return resultStyles;
}, [styles]);

const element = useContext(elementContext);

return (
renderStyles &&
element &&
createPortal(
<style
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: renderStyles,
}}
/>,
element
)
<style
dangerouslySetInnerHTML={{
__html: renderStyles,
}}
/>
);
}

0 comments on commit 8df21ef

Please sign in to comment.