How to use the @remirror/core-utils.isDocNodeEmpty function in @remirror/core-utils

To help you get started, we’ve selected a few @remirror/core-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ifiokjr / remirror / @remirror / core-extensions / src / extensions / placeholder / placeholder-extension.ts View on Github external
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,
      }),
    );
  }
}
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / placeholder / placeholder-plugin.ts View on Github external
const applyState = ({ pluginState, extension, tr, state }: ApplyStateParams) => {
  if (!tr.docChanged) {
    return pluginState;
  }

  return { ...extension.options, empty: isDocNodeEmpty(state.doc) };
};