How to use the @remirror/core-helpers.uniqueArray 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 / @remirror / core-extensions / src / extensions / trailing-node-extension.ts View on Github external
export const createTrailingNodePlugin = ({ extension, tags, schema }: CreateTrailingNodePluginParams) => {
  const { options, pluginKey } = extension;
  const { disableTags, ignoredNodes, nodeName } = options;

  // The names of the nodes for whom this rule should not be applied.
  const notAfter: string[] = disableTags
    ? uniqueArray([...ignoredNodes, nodeName])
    : uniqueArray([...ignoredNodes, ...tags.general.lastNodeCompatible, nodeName]);

  // The node that will be inserted when the criteria match.
  const type = schema.nodes[nodeName];

  // The list of nodes for this schema that should have content injected after
  // them.
  const types = entries(schema.nodes)
    .map(([, entry]) => entry)
    .filter(entry => !notAfter.includes(entry.name));

  return new Plugin({
    key: extension.pluginKey,
    view() {
      return {
        update: view => {
github ifiokjr / remirror / packages / multishift / src / multishift-utils.ts View on Github external
end,
  indexes,
  items,
  hoveredIndex,
}: GetHighlightedIndexesParams) => {
  const max = items.length - 1;
  const groupIndexes = isValidIndex(start)
    ? range(
        clamp({ min: 0, max, value: start }),
        clamp({ min: 0, max, value: isValidIndex(end) ? end : start }),
      )
    : [];

  const hoveredIndexes = isValidIndex(hoveredIndex) ? [hoveredIndex] : [];

  return uniqueArray([...hoveredIndexes, ...indexes, ...groupIndexes], true);
};
github ifiokjr / remirror / @remirror / react-utils / src / react-utils.ts View on Github external
export const cloneElement =  }> = any>(
  element: ReactElement,
  props: GProps,
  ...rest: ReactNode[]
) => {
  const children = uniqueArray([
    ...(isArray(props.children) ? props.children : props.children ? [props.children] : []),
    ...rest,
  ]);

  return jsx(
    element.type,
    {
      key: element.key,
      ref: element.props.ref,
      ...element.props,
      ...props,
    },
    ...children,
  );
};
github ifiokjr / remirror / packages / multishift / src / multishift-utils.ts View on Github external
});

    const extra = isHighlighted
      ? {
          highlightedIndexes: indexes.filter(ii => ii !== index),
          highlightedGroupEndIndex: undefined,
          highlightedGroupStartIndex: -1,
        }
      : { highlightedIndexes: indexes, highlightedGroupStartIndex: index };
    const changes = { ...defaultReturn, ...extra };

    return omitUnchangedState(changes, params);
  }

  if (shiftKeyPressed) {
    const indexes = uniqueArray(state.highlightedIndexes, true);
    const extra = isValidIndex(state.highlightedGroupStartIndex)
      ? {
          highlightedIndexes: indexes,
          highlightedGroupStartIndex: state.highlightedGroupStartIndex,
          highlightedGroupEndIndex: index,
        }
      : { highlightedIndexes: indexes, highlightedGroupStartIndex: index };

    const changes = { ...defaultReturn, ...extra };

    return omitUnchangedState(changes, params);
  }

  return omitUnchangedState(
    {
      ...defaultReturn,