0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Updated Ghost to handle Lexical snippets (#16630)

refs TryGhost/Team#2904
This commit is contained in:
Elena Baidakova 2023-04-14 16:08:48 +04:00 committed by GitHub
parent b76f93ea5a
commit 3235f22da6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 11 deletions

View file

@ -1 +1 @@
<div {{react-render this.ReactComponent}}></div>
<div {{react-render this.ReactComponent props=(hash cardConfig=@cardConfig) }}></div>

View file

@ -146,7 +146,7 @@ export default class KoenigLexicalEditor extends Component {
// don't rethrow, Lexical will attempt to gracefully recover
}
ReactComponent = () => {
ReactComponent = (props) => {
const defaultCardConfig = {
unsplash: {
defaultHeaders: {
@ -159,7 +159,7 @@ export default class KoenigLexicalEditor extends Component {
},
tenor: this.config.tenor?.googleApiKey ? this.config.tenor : null
};
const cardConfig = Object.assign({}, defaultCardConfig, this.args.cardConfig);
const cardConfig = Object.assign({}, defaultCardConfig, props.cardConfig);
const useFileUpload = (type = 'image') => {
const [progress, setProgress] = React.useState(0);

View file

@ -16,15 +16,11 @@ export default class ReactRenderModifier extends Modifier {
}
modify(element, [reactComponent], {props}) {
if (!this.didSetup) {
if (!this.root) {
this.root = createRoot(element);
}
this.root.render(React.createElement(reactComponent, {...props}));
this.didSetup = true;
if (!this.root) {
this.root = createRoot(element);
}
this.root.render(React.createElement(reactComponent, {...props}));
}
cleanup = () => {

View file

@ -90,6 +90,8 @@
@clearFeatureImage={{this.clearFeatureImage}}
@cardOptions={{hash
post=this.post
snippets=this.snippets
deleteSnippet=this.confirmDeleteSnippet
}}
@postType={{this.post.displayName}}
/>