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 = {
|
module.exports = {
|
||||||
extends: ['plugin:@wordpress/eslint-plugin/recommended'],
|
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 { compact, map } from 'lodash';
|
||||||
import { createPortal, useContext, useMemo } from '@wordpress/element';
|
|
||||||
import { transformStyles, BlockList } from '@wordpress/block-editor';
|
|
||||||
|
|
||||||
const { elementContext: __stableElementContext, __unstableElementContext } =
|
import { transformStyles } from '@wordpress/block-editor';
|
||||||
BlockList;
|
import { useMemo } from '@wordpress/element';
|
||||||
|
|
||||||
const elementContext = __stableElementContext || __unstableElementContext;
|
|
||||||
|
|
||||||
const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';
|
const EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';
|
||||||
|
|
||||||
|
@ -35,19 +27,11 @@ export default function EditorStyles(props) {
|
||||||
return resultStyles;
|
return resultStyles;
|
||||||
}, [styles]);
|
}, [styles]);
|
||||||
|
|
||||||
const element = useContext(elementContext);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
renderStyles &&
|
<style
|
||||||
element &&
|
dangerouslySetInnerHTML={{
|
||||||
createPortal(
|
__html: renderStyles,
|
||||||
<style
|
}}
|
||||||
// eslint-disable-next-line react/no-danger
|
/>
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html: renderStyles,
|
|
||||||
}}
|
|
||||||
/>,
|
|
||||||
element
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue