Typix LogoTypix
Extensions

Code Block + Prettier

Format code blocks on demand with Prettier

Adds a "Format" action to code blocks that runs Prettier on the content. Requires Code Block to be installed.

Install

pnpm add @typix-editor/extension-code-block-prettier

Live demo

Config

OptionTypeDefaultDescription
printOptionsPrettier.Options{}Forwarded directly to Prettier.

Supported printOptions include tabWidth, semi, singleQuote, trailingComma, printWidth, etc. See Prettier docs.

Helper

import { canFormatWithPrettier } from "@typix-editor/extension-code-block-prettier";

if (canFormatWithPrettier("typescript")) {
  // Prettier can handle this language
}

On this page