How to use the @remirror/core-constants.ExtensionType.Plain function in @remirror/core-constants

To help you get started, we’ve selected a few @remirror/core-constants 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 / core / src / extension.ts View on Github external
protected getExtraAttrs(domNode: Node) {
    if (this.type === ExtensionType.Plain) {
      throw new Error('Invalid use of extraAttrs within a plain extension.');
    }

    const extraAttrs = (this.options.extraAttrs as ExtraAttrs[] | undefined) ?? [];
    const attrs: Attrs = Object.create(null);

    for (const item of extraAttrs) {
      if (Array.isArray(item)) {
        // Use the default
        const [name, , attributeName] = item;
        attrs[name] = attributeName ? (domNode as Element).getAttribute(attributeName) : undefined;
      } else if (isString(item)) {
        // Assume the name is the same
        attrs[item] = (domNode as Element).getAttribute(item);
      } else {
        const { name, getAttrs, default: fallback } = item;
github ifiokjr / remirror / @remirror / core / src / extension-helpers.ts View on Github external
export const isPlainExtension = (extension: unknown): extension is Extension =>
  isExtension(extension) && extension.type === ExtensionType.Plain;