How to use the @remirror/core-helpers.Cast function in @remirror/core-helpers

To help you get started, we’ve selected a few @remirror/core-helpers 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-prosemirror / src / jest-prosemirror-nodes.ts View on Github external
if (cursor) {
    return new TextSelection(taggedDoc.resolve(cursor));
  }

  if (gap) {
    const $pos = taggedDoc.resolve(gap);
    return new GapCursor($pos, $pos);
  }

  if (start) {
    return createTextSelection({ taggedDoc, start, end });
  }

  const $anchor = resolveCell(taggedDoc, anchor);
  if ($anchor) {
    return Cast>(
      new CellSelection($anchor, resolveCell(taggedDoc, taggedDoc.tag.head) ?? undefined),
    );
  }
  return null;
};
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / composition / composition-plugin.ts View on Github external
beforeinput: (view, ev: Event) => {
          const event = Cast(ev);
          if (event.inputType === 'deleteContentBackward' && isAndroidOS()) {
            const pluginState = getPluginState(ctx.pluginKey, view.state);
            pluginState.startDelete();
            return patchDeleteContentBackward(ctx.options, view, event, pluginState);
          }
          return true;
        },
      },
github ifiokjr / remirror / @remirror / core / src / extension-manager.helpers.ts View on Github external
const getFn = () => {
    if (isNodeExtension(extension)) {
      return extensionMethod.bind(extension)({
        ...params,
        type: Cast(params.schema.nodes[extension.name]),
      });
    }
    if (isMarkExtension(extension)) {
      return extensionMethod.bind(extension)({ ...params, type: Cast(params.schema.marks[extension.name]) });
    }
    return extensionMethod.bind(extension)(Cast(params));
  };
github ifiokjr / remirror / @remirror / core-utils / src / dom-utils.ts View on Github external
export const closestElement = (domNode: Node | null | undefined, selector: string): HTMLElement | null => {
  if (!isElementDOMNode(domNode)) {
    return null;
  }
  if (isNullOrUndefined(document.documentElement) || !document.documentElement.contains(domNode)) {
    return null;
  }
  const matches = isFunction(domNode.matches) ? 'matches' : Cast<'matches'>('msMatchesSelector');

  do {
    if (isFunction(domNode[matches]) && domNode[matches](selector)) {
      return domNode;
    }
    domNode = (domNode.parentElement ?? domNode.parentNode) as HTMLElement;
  } while (isElementDOMNode(domNode));
  return null;
};