How to use the @remirror/core.Cast 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 / packages / jest-remirror / src / jest-remirror-editor.tsx View on Github external
export const renderEditor = <
  GPlainMarks extends Array>,
  GPlainNodes extends Array>,
  GAttrMarks extends Array>,
  GAttrNodes extends Array>,
  GOthers extends Array>,
  GReturn extends CreateTestEditorReturn,
  GExtension extends GenericExtension,
  GPlainMarkNames extends GetNames,
  GAttrMarkNames extends GetNames,
  GAttrNodeNames extends GetNames,
  GPlainNodeNames extends GetNames | BaseExtensionNodeNames
>(
  {
    plainMarks = Cast([]),
    plainNodes = Cast([]),
    attrMarks = Cast([]),
    attrNodes = Cast([]),
    others = Cast([]),
  }: Partial<
    CreateTestEditorExtensions
  > = Object.create(null),
  props: Partial, 'manager'>> = Object.create(null),
): GReturn => {
  const innerNodeExtensions = nodeExtensions.filter(({ name }) => !plainNodes.some(ext => ext.name === name));
  const extensions = [
    ...innerNodeExtensions,
    ...others,
    ...plainMarks,
    ...plainNodes,
    ...attrMarks,
    ...attrNodes,
github ifiokjr / remirror / @remirror / core-extensions / src / marks / link-extension.ts View on Github external
getAttrs: node => ({
            href: Cast<element>(node).getAttribute('href'),
            ...this.getExtraAttrs(Cast<element>(node)),
          }),
        },</element></element>
github ifiokjr / remirror / @remirror / core-extensions / src / marks / link.ts View on Github external
getAttrs: node =&gt; ({
            href: Cast<element>(node).getAttribute('href'),
            ...this.getExtraAttrs(Cast<element>(node)),
          }),
        },</element></element>
github ifiokjr / remirror / @remirror / core-extensions / src / marks / link-extension.ts View on Github external
getAttrs: node =&gt; ({
            href: Cast<element>(node).getAttribute('href'),
            ...this.getExtraAttrs(Cast<element>(node)),
          }),
        },</element></element>
github ifiokjr / remirror / @remirror / editor-markdown / src / theme.ts View on Github external
import DefaultStyled, { CreateStyled } from '@emotion/styled';
import { Cast } from '@remirror/core';

export const styled = Cast&gt;(DefaultStyled);
export type MarkdownEditorTheme = typeof markdownEditorTheme;

export type ButtonState = 'default' | 'active-default' | 'inverse' | 'active-inverse';

const buttonColors: Record = {
  default: '#aaa',
  'active-default': 'black',
  inverse: '#aaa',
  'active-inverse': 'white',
};

export const markdownEditorTheme = {
  colors: {
    primary: '#1DA1F2',
    warn: '#FFAD1F',
    error: '#E0245E',
github ifiokjr / remirror / packages / jest-remirror / src / jest-remirror-editor.tsx View on Github external
return returnValue;
    };

    return updateContent();
  };

  const { schema } = view.state;

  const nodesWithAttrs: NodeWithAttrs = Object.create(null);
  attrNodes.filter(isNodeExtension).forEach(({ name }) =&gt; {
    nodesWithAttrs[name as GAttrNodeNames] = (attrs: Attrs = Object.create(null)) =&gt;
      nodeFactory({ name, schema, attrs });
  });

  const nodesWithoutAttrs: NodeWithoutAttrs = Cast({
    p: nodeFactory({ name: 'paragraph', schema }),
  });
  [...plainNodes, ...innerNodeExtensions].filter(isNodeExtension).forEach(({ name }) =&gt; {
    nodesWithoutAttrs[name as GPlainNodeNames] = nodeFactory({ name, schema });
  });

  const marksWithAttrs: MarkWithAttrs = Object.create(null);
  attrMarks.filter(isMarkExtension).forEach(({ name }) =&gt; {
    marksWithAttrs[name as GAttrMarkNames] = (attrs: Attrs = Object.create(null)) =&gt;
      markFactory({ name, schema, attrs });
  });

  const marksWithoutAttrs: MarkWithoutAttrs = Object.create(null);
  plainMarks.filter(isMarkExtension).forEach(({ name }) =&gt; {
    marksWithoutAttrs[name as GPlainMarkNames] = markFactory({ name, schema });
  });
github ifiokjr / remirror / @remirror / core-extensions / src / marks / link.ts View on Github external
getAttrs: node =&gt; ({
            href: Cast<element>(node).getAttribute('href'),
            ...this.getExtraAttrs(Cast<element>(node)),
          }),
        },</element></element>
github ifiokjr / remirror / @remirror / core-extensions / src / nodes / ordered-list.ts View on Github external
getAttrs: node =&gt; ({
            order: Cast<element>(node).hasAttribute('start')
              ? +Cast<element>(node).getAttribute('start')!
              : 1,
          }),
        },</element></element>