Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options?: GetRootPropsConfig,
children?: ReactNode,
): RefKeyRootProps => {
// Ensure that this is the first time `getRootProps` is being called during
// this render.
if (this.rootPropsConfig.called) {
throw new Error(
'`getRootProps` has been called MULTIPLE times. It should only be called ONCE during render.',
);
}
this.rootPropsConfig.called = true;
const { refKey = 'ref', ...config } = options ?? Object.create(null);
const { sx } = this.context;
const css = sx(this.editorStyles);
const extra = bool(css) ? { css } : {};
return {
[refKey]: this.onRef,
key: this.uid,
...extra,
...config,
children: children ?? this.renderChildren(null),
} as RefKeyRootProps;
};
const hasCursor = (arg: T): arg is T & { $cursor: ResolvedPos } => {
return bool(Cast(arg).$cursor);
};
public serializeNode(node: ProsemirrorNode): ReactNode {
const Component = this.components[node.type.name];
const options = this.options[node.type.name];
const toDOM = this.nodes[node.type.name];
let children: ReactNode;
if (node.content.childCount > 0) {
children = this.serializeFragment(node.content);
}
return bool(Component) ? (
{children}
) : (
toDOM && ReactSerializer.renderSpec(toDOM(node), children)
);
}
const hasCursor = (arg: T): arg is T & { $cursor: ResolvedPos } => {
return bool(Cast(arg).$cursor);
};
public serializeMark(mark: Mark, inline: boolean, wrappedElement: ReactNode): ReactNode {
const toDOM = this.marks[mark.type.name];
const Component = this.components[mark.type.name];
const options = this.options[mark.type.name];
return bool(Component) ? (
{wrappedElement}
) : (
toDOM && ReactSerializer.renderSpec(toDOM(mark, inline), wrappedElement)
);
}
export const isBaseEmoji = (emoji: BaseEmoji | CustomEmoji | undefined): emoji is BaseEmoji => {
return bool(emoji && Cast(emoji).native);
};
hasChanged({ oldState, newState }) {
return !(bool(oldState) && oldState.doc.eq(newState.doc) && oldState.selection.eq(newState.selection));
},