Skip to content

Make image block inside custom action #336

Answered by duhaime
duhaime asked this question in Q&A
Discussion options

You must be logged in to vote

Aha, one can literally just chain commands seriatim:

export const CustomCommand = createCmdKey();
const myPlugin = () => async (ctx) => {
  await ctx.wait(CommandsReady);
  const commandManager = ctx.get(commandsCtx);
  const schema = ctx.get(schemaCtx);

  commandManager.create(CustomCommand, () => {
    return () => {
      const url = "https://via.placeholder.com/450x300"
      ctx.get(commandsCtx).call(milkdownCommands.InsertHardbreak)
      ctx.get(commandsCtx).call(milkdownCommands.InsertImage, url)
      ctx.get(commandsCtx).call(milkdownCommands.InsertHardbreak)
    }
  });
};

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
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
1 participant