How to use the @remirror/core-helpers.keys 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 / multishift / src / multishift-utils.ts View on Github external
export const callChangeHandlers = (
  handlers: MultishiftChangeHandlerProps,
  { changes, state, prevState }: MultishiftStateChangeset,
) => {
  const changedKeys = keys(changes);
  const { onStateChange } = handlers;

  changedKeys.forEach(key => {
    changeHandlerMap[key](handlers, { changes, state, prevState });
  });

  if (changedKeys.length && onStateChange) {
    onStateChange(changes, state);
  }
};
github ifiokjr / remirror / @remirror / core-utils / src / prosemirror-utils.ts View on Github external
export const schemaToJSON = (
  schema: EditorSchema,
): SchemaJSON => {
  const nodes = keys(schema.nodes).reduce((acc, key) => {
    const { spec } = schema.nodes[key];
    return { ...acc, [key]: spec };
  }, Object.create(null));

  const marks = keys(schema.marks).reduce((acc, key) => {
    const { spec } = schema.marks[key];
    return { ...acc, [key]: spec };
  }, Object.create(null));

  return {
    nodes,
    marks,
  };
};
github ifiokjr / remirror / @remirror / react-node-view / src / react-node-view.tsx View on Github external
if (isString(domSpec) || isDOMNode(domSpec)) {
        return;
      }

      const attrs = domSpec[1];

      if (isPlainObject(attrs)) {
        keys(attrs).forEach(attr => {
          element.setAttribute(attr, String(attrs[attr]));
        });

        return;
      }
    }

    keys(node.attrs).forEach(attr => {
      element.setAttribute(attr, node.attrs[attr]);
    });
  }
github ifiokjr / remirror / packages / jest-prosemirror / src / jest-prosemirror-serializer.ts View on Github external
print: val => {
    if (isEditorState(val)) {
      return `Prosemirror doc: ${JSON.stringify(
        val.doc.toJSON(),
        null,
        2,
      )}\nProsemirror selection: ${JSON.stringify(val.selection, null, 2)}`;
    }

    if (isEditorSchema(val)) {
      const nodes = keys(val.nodes).reduce((acc, key) => {
        const { spec } = val.nodes[key];
        return { ...acc, [key]: spec };
      }, {});
      const marks = keys(val.marks).reduce((acc, key) => {
        const { spec } = val.marks[key];
        return { ...acc, [key]: spec };
      }, {});

      return `Prosemirror schema: ${JSON.stringify(
        {
          nodes,
          marks,
        },
        null,
        2,
      )}`;
    }

    return `Prosemirror node: ${JSON.stringify(val, null, 2)}`;
  },
github ifiokjr / remirror / @remirror / react-node-view / src / react-node-view.tsx View on Github external
public setDomAttrs(node: ProsemirrorNode, element: HTMLElement) {
    const { toDOM } = this.node.type.spec;
    if (toDOM) {
      const domSpec = toDOM(node);

      if (isString(domSpec) || isDOMNode(domSpec)) {
        return;
      }

      const attrs = domSpec[1];

      if (isPlainObject(attrs)) {
        keys(attrs).forEach(attr => {
          element.setAttribute(attr, String(attrs[attr]));
        });

        return;
      }
    }

    keys(node.attrs).forEach(attr => {
      element.setAttribute(attr, node.attrs[attr]);
    });
  }
github ifiokjr / remirror / packages / multishift / src / multishift-utils.ts View on Github external
export const bindActionCreators = <
  GAction,
  GCreatorMap extends ActionCreatorsMapObject,
  GDispatch extends Dispatch
>(
  actionCreators: GCreatorMap,
  dispatch: GDispatch,
): ActionCreatorMapToDispatch => {
  const boundActionCreators: ActionCreatorMapToDispatch = Object.create(null);
  const creatorKeys = keys(actionCreators);

  for (const key of creatorKeys) {
    const actionCreator = actionCreators[key];
    boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
  }

  return boundActionCreators;
};
github ifiokjr / remirror / packages / jest-prosemirror / src / jest-prosemirror-serializer.ts View on Github external
print: val => {
    if (isEditorState(val)) {
      return `Prosemirror doc: ${JSON.stringify(
        val.doc.toJSON(),
        null,
        2,
      )}\nProsemirror selection: ${JSON.stringify(val.selection, null, 2)}`;
    }

    if (isEditorSchema(val)) {
      const nodes = keys(val.nodes).reduce((acc, key) => {
        const { spec } = val.nodes[key];
        return { ...acc, [key]: spec };
      }, {});
      const marks = keys(val.marks).reduce((acc, key) => {
        const { spec } = val.marks[key];
        return { ...acc, [key]: spec };
      }, {});

      return `Prosemirror schema: ${JSON.stringify(
        {
          nodes,
          marks,
        },
        null,
        2,
      )}`;