@madebywild/sanity-richtext-field
v3.1.1
Published
> [!IMPORTANT] > This package is primarily intended for internal use.
Readme
[!IMPORTANT] This package is primarily intended for internal use.
@madebywild/sanity-richtext-field
Rich text field plugin with configurable blocks, marks, and presets.
Install
pnpm add @madebywild/sanity-richtext-fieldConfigure Plugin
import { defineConfig, defineField } from "sanity";
import { wildSanityRichtextFieldPlugin } from "@madebywild/sanity-richtext-field";
import { createBlock } from "@madebywild/sanity-richtext-field/utils";
import { createBlock as quoteBlock } from "@madebywild/sanity-richtext-field/blocks/quote-block";
import { createAnnotations, createDecorators, createLists, createSpans, createStyles } from "@madebywild/sanity-richtext-field/parts";
const customBlock = defineField({
name: "customBlock",
type: "object",
title: "Custom Block",
fields: [defineField({ name: "title", type: "string" })],
});
export default defineConfig({
plugins: [
wildSanityRichtextFieldPlugin({
spellCheck: true,
blocks: [createBlock(customBlock), quoteBlock()],
spans: [...createSpans()],
styles: [...createStyles()],
lists: [...createLists()],
decorators: [...createDecorators()],
annotations: [...createAnnotations()],
}),
],
});Use in Schema
import { defineField } from "sanity";
defineField({
name: "body",
type: "wild.richtext",
options: {
size: "lg", // "sm" | "lg" | custom height string (e.g. "480px")
preset: "full", // "basic" | "full"
initiallyActive: false,
allowedKinds: ["styles", "lists", "decorators", "annotations", "spans", "blocks"],
disallowedKinds: ["annotations"],
allowedParts: ["wild.richtext.decorator.strong", "wild.richtext.annotation.link"],
disallowedParts: ["wild.richtext.decorator.underline"],
},
});