Skip to content

How to create custom commands #331

Answered by duhaime
duhaime asked this question in Q&A
Jan 31, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

After exploring this a bit, I've learned there are at least three ways to run commands. The first set of commands are exported by prosemirror-commands:

import * as prosemirrorCommands from "prosemirror-commands";

The next set of commands are exported by @milkdown/preset-commonmark:

import { commands as milkdownCommands } from "@milkdown/preset-commonmark";

The final set of commands are completely custom and let one use prosemirror's state and dispatch interfaces to create a custom command.

There are examples of all three commands below:

import React, { useState } from "react";

import {
  Editor,
  rootCtx,
  commandsCtx,
  defaultValueCtx,
  schemaCtx,
  createCmd,
  createCmdKey,
  Co…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Saul-Mirone
Comment options

@duhaime
Comment options

Answer selected by duhaime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants