How to use the @remirror/core.isString function in @remirror/core

To help you get started, we’ve selected a few @remirror/core 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 / react-renderer / src / renderer.tsx View on Github external
}) => {
  if (json.type === 'text' && json.text && (!json.marks || !json.marks.length)) {
    return {json.text}; // For some reason FunctionalComponent don't allow returning react-nodes
  }

  const rest = { markMap, typeMap, skipUnknownMarks, skipUnknownTypes };

  const TypeHandler = typeMap[json.type];
  if (!TypeHandler) {
    if (!skipUnknownTypes) {
      throw new Error(`No handler for node type \`${json.type}\` registered`);
    }
    return null;
  }

  const props = isString(TypeHandler) ? json.attrs ?? Object.create(null) : { ...rest, node: json };
  const { content } = json;
  if (!content || !content.length) {
    return ;
  }

  const children = content.map((child, ii) => {
    return ;
  });

  return {children};
};
github ifiokjr / remirror / @remirror / core-extensions / src / marks / bold.ts View on Github external
          getAttrs: node => (isString(node) && /^(bold(er)?|[5-9]\d{2,})$/.test(node) ? null : false),
        },
github ifiokjr / remirror / @remirror / core-extensions / src / marks / bold-extension.ts View on Github external
          getAttrs: node => (isString(node) && /^(bold(er)?|[5-9]\d{2,})$/.test(node) ? null : false),
        },
github ifiokjr / remirror / @remirror / extension-mention / src / mention.extension.ts View on Github external
getAttrs: dom => {
            if (isString(dom)) {
              return false;
            }

            const id = (dom as Element).getAttribute(dataAttribute);
            const label = (dom as HTMLElement).innerText;
            return { id, label };
          },
        },
github ifiokjr / remirror / @remirror / editor-markdown / src / markdown-editor.tsx View on Github external
const createInitialContent = ({ content, schema }: CreateInitialContentParams): Content => {
  if (isString(content)) {
    return {
      markdown: content,
      wysiwyg: fromMarkdown(content, schema),
    };
  }

  if (isProsemirrorNode(content)) {
    return {
      markdown: toMarkdown(content),
      wysiwyg: content,
    };
  }

  if (!isObjectNode(content)) {
    throw new Error('Invalid content passed into the editor');
  }
github ifiokjr / remirror / @remirror / react-renderer / src / react-serializer.tsx View on Github external
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];
        }
      }
    }
github ifiokjr / remirror / packages / jest-remirror / src / jest-remirror-builder.ts View on Github external
  const taggedContent = content.map(item => (isString(item) ? text(item, schema) : item)) as Array<
    TaggedContentItem | TaggedContentItem[]
github ifiokjr / remirror / @remirror / extension-mention / src / mention-utils.ts View on Github external
export const getAppendText = (preferred: string | undefined, fallback: string | undefined) => {
  if (isString(preferred)) {
    return preferred;
  }
  if (isString(fallback)) {
    return fallback;
  }
  return DEFAULT_MATCHER.appendText;
};
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 / extension-mention / src / mention-utils.ts View on Github external
export const getAppendText = (preferred: string | undefined, fallback: string | undefined) => {
  if (isString(preferred)) {
    return preferred;
  }
  if (isString(fallback)) {
    return fallback;
  }
  return DEFAULT_MATCHER.appendText;
};