Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public ssrTransformer(element: JSX.Element, { getState }: ExtensionManagerParams) {
const state = getState();
const { emptyNodeClass, placeholder } = this.options;
const { children } = getElementProps(element);
if (Children.count(children) > 1 || !isDocNodeEmpty(state.doc)) {
return element;
}
const props = getElementProps(children);
return cloneElement(
element,
{},
cloneElement(children, {
...props,
className: isString(props.className) ? `${props.className} ${emptyNodeClass}` : emptyNodeClass,
'data-placeholder': placeholder,
}),
);
}
}
const applyState = ({ pluginState, extension, tr, state }: ApplyStateParams) => {
if (!tr.docChanged) {
return pluginState;
}
return { ...extension.options, empty: isDocNodeEmpty(state.doc) };
};