How to use the @remirror/core.hasOwnProperty 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-utils.ts View on Github external
const getPossibleStandardName = (key: string): string => {
  if (!hasOwnProperty(possibleStandardNames, key)) {
    return key;
  }
  return possibleStandardNames[key] || key;
};
github ifiokjr / remirror / packages / jest-remirror / src / jest-remirror-builder.ts View on Github external
export const offsetTags = (tags: Tags, offset: number): Tags => {
  const result: Tags = Object.create(null);
  for (const name in tags) {
    if (hasOwnProperty(tags, name)) {
      result[name] = tags[name] + offset;
    }
  }
  return result;
};
github ifiokjr / remirror / packages / jest-remirror / src / jest-remirror-builder.ts View on Github external
export const nodeFactory = ({
  name,
  schema,
  attrs,
  marks,
}: NodeFactoryParams) => {
  const nodeBuilder = hasOwnProperty(schema.nodes, name) ? schema.nodes[name] : undefined;
  if (!nodeBuilder) {
    throw new Error(
      `Node: "${name}" doesn't exist in schema. It's usually caused by lacking of the extension that contributes this node. Schema contains following nodes: ${Object.keys(
        schema.nodes,
      ).join(', ')}`,
    );
  }
  return (...content: TaggedContentWithText[]): TaggedProsemirrorNode => {
    const { nodes, tags } = coerce({ content, schema });
    const node = nodeBuilder.createChecked(attrs, nodes, marks) as TaggedProsemirrorNode;
    node.tags = tags;
    return node;
  };
};
github ifiokjr / remirror / @remirror / react-renderer / src / renderer-utils.ts View on Github external
export const gatherToDOM = (
  specs: Record,
) => {
  const result: Record = Object.create(null);
  for (const name in specs) {
    if (!hasOwnProperty(specs, name)) {
      continue;
    }
    const toDOM = specs[name].toDOM;
    if (toDOM) {
      result[name] = toDOM;
    }
  }
  return result;
};
github ifiokjr / remirror / packages / jest-remirror / src / jest-remirror-builder.ts View on Github external
export const markFactory = ({ name, schema, attrs, allowDupes = false }: MarkFactoryParams) => {
  const markBuilder = hasOwnProperty(schema.marks, name) ? schema.marks[name] : undefined;
  if (!markBuilder) {
    throw new Error(
      `Mark: "${name}" doesn't exist in schema. It's usually caused by lacking of the extension that contributes this mark. Schema contains following marks: ${Object.keys(
        schema.marks,
      ).join(', ')}`,
    );
  }

  return (...content: TaggedContentWithText[]): TaggedProsemirrorNode[] => {
    const mark = markBuilder.create(attrs);
    const { nodes } = coerce({ content, schema });
    return nodes.map(node => {
      if (!allowDupes && mark.type.isInSet(node.marks)) {
        return node;
      } else {
        const taggedNode = node.mark(mark.addToSet(node.marks)) as TaggedProsemirrorNode;
github ifiokjr / remirror / @remirror / react-renderer / src / renderer-utils.ts View on Github external
export const mapProps = (props: PlainObject) => {
  const transformedProps: PlainObject = Object.create(null);
  for (const key in props) {
    if (!hasOwnProperty(props, key)) {
      continue;
    }

    const name = getPossibleStandardName(key);
    transformedProps[name] = props[key];

    if (name === 'contentEditable') {
      transformedProps.suppressContentEditableWarning = true;
    }
  }
  return transformedProps;
};