mirror of
https://github.com/WenPai-org/wpmind.git
synced 2025-08-03 02:48:41 +08:00
fixed JS error when inserting response to editor
This commit is contained in:
parent
bb7b0b6151
commit
8df21ef245
2 changed files with 10 additions and 23 deletions
|
@ -1,3 +1,6 @@
|
|||
module.exports = {
|
||||
extends: ['plugin:@wordpress/eslint-plugin/recommended'],
|
||||
settings: {
|
||||
'import/core-modules': ['jquery', 'lodash'],
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue