Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const isValidEmojiObject = (value: unknown): value is EmojiObject =>
bool(isPlainObject(value) && isEmojiName(value.name));
export const aliasToName = (name: AliasNames) => aliasObject[name];
export const isValidMentionAttrs = (attrs?: Attrs): attrs is MentionExtensionAttrs =>
bool(attrs && isPlainObject(attrs) && attrs.id && attrs.label);
private renderClonedElement(element: JSX.Element, rootProps?: GetRootPropsConfig | boolean) {
const { children, ...rest } = getElementProps(element);
const props = isPlainObject(rootProps) ? { ...rootProps, ...rest } : rest;
return cloneElement(element, this.internalGetRootProps(props, this.renderChildren(children)));
}
public static renderSpec(structure: DOMOutputSpec, wraps?: ReactNode): ReactNode {
if (isString(structure)) {
return structure;
}
const Component = structure[0];
const props: PlainObject = Object.create(null);
const attrs = structure[1];
const children: ReactNode[] = [];
let currentIndex = 1;
if (isPlainObject(attrs) && !isArray(attrs)) {
currentIndex = 2;
for (const name in attrs) {
if (attrs[name] != null) {
props[name] = attrs[name];
}
}
}
for (let ii = currentIndex; ii < structure.length; ii++) {
const child = structure[ii];
if (child === 0) {
if (ii < structure.length - 1 || ii > currentIndex) {
throw new RangeError('Content hole (0) must be the only child of its parent node');
}
return jsx(Component, mapProps(props), wraps);
}