npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@standhigher/shopify-rich-text-server

v1.0.0

Published

Server utilities for validating Tiptap JSON, sanitizing rich text HTML, and rendering Shopify-safe output.

Readme

@standhigher/shopify-rich-text-server

npm version npm downloads CI License: MIT Storybook

Server utilities for validating Tiptap JSON, sanitizing rich text HTML, and rendering Shopify-safe output.

Links

Installation

pnpm add @standhigher/shopify-rich-text-server

Basic Usage

import {
  RICH_TEXT_VALIDATION_LIMITS,
  RichTextValidationError,
  processRichText
} from "@standhigher/shopify-rich-text-server";

export async function renderDescription(input: unknown) {
  const result = processRichText(input, { channel: "shopify-html" });

  if (!result.ok) {
    console.error(result.error.code, result.error.path);
    throw new RichTextValidationError(result.error.code, result.error.message, result.error.path);
  }

  return {
    html: result.html,
    plainText: result.plainText,
    warnings: result.warnings,
    schemaVersion: result.schemaVersion
  };
}

// `validateRichTextDocument(input, limits)` supports per-request limits.
// `RICH_TEXT_VALIDATION_LIMITS` contains the defaults.

processRichText() is the recommended publishing and cache-generation entry point. It validates the persisted envelope, migrates to CURRENT_RICH_TEXT_SCHEMA_VERSION, validates the current schema, serializes, applies the channel adapter, sanitizes, and returns a structured ProcessResult.

renderShopifyHtml() remains available as a compatibility API when callers only need the HTML string and do not need warnings.

Standard HTML import (0.6.x)

import { importStandardHtml } from "@standhigher/shopify-rich-text-server";

const imported = importStandardHtml("<h2>Title</h2><p>Hello <strong>world</strong></p>");

if (imported.ok) {
  await saveRichTextDocument(imported.document);
}

The importer supports constrained standard HTML: paragraphs, H1-H4 headings, lists, links, images, blockquotes, bold, italic, and underline. It sanitizes before and after conversion and returns warnings when unsupported or unsafe HTML is removed.

Word HTML, Google Docs HTML, complex inline styles, forms, iframes, scripts, and arbitrary custom tags are not part of the stable import contract.

Schema migration (0.6.x)

validateRichTextDocument() and processRichText() migrate documents from published schema versions to CURRENT_RICH_TEXT_SCHEMA_VERSION before final schema validation. Migration failure is recoverable: callers should keep the original stored document, report the structured error, and avoid overwriting cached HTML or persisted JSON.

Shopify resource rendering (experimental)

Shopify Resource rendering is opt-in and experimental in 1.0. Resource fields must remain limited to stable GIDs and display-safe snapshots.

Product, Collection, and Variant references are validated by their stable Shopify GID. The server persists only resourceType, id, and optional title, handle, and image snapshot fields. Internal API responses, tokens, permissions, and provider-specific fields are rejected.

By default, a resource renders as sanitized title text. A server-side business adapter may provide a URL builder:

const html = renderShopifyHtml(document, {
  resourceUrlBuilder: (resource) =>
    resource.handle ? `/${resource.resourceType}s/${resource.handle}` : undefined
});

The builder runs on the server and accepts only absolute http(s) or single-slash relative URLs. Unsafe URLs fall back to text. Resource images are subject to the same http/https URL policy and final HTML allowlist sanitization.

Shopify rich_text_field JSON import/export is not a stable 0.5.x API. Use Tiptap JSON as the source document until the planned compatibility matrix and downgrade tests are complete.

Extension contracts

Server registration is separate from client registration. A custom node must be registered with the server before validation or rendering; otherwise validation rejects it as an unknown node.

import { Node } from "@tiptap/core";
import {
  createServerExtensionRegistry,
  richTextJsonToHtml,
  validateRichTextDocument,
  type ServerExtension
} from "@standhigher/shopify-rich-text-server";

const calloutExtension: ServerExtension = {
  id: "callout",
  version: "1.0.0",
  nodes: ["callout"],
  server: {
    extensions: [Node.create({ name: "callout", group: "block", content: "inline*" })],
    serializers: {
      callout: (node) => `<p>${node.content?.map((child) => child.text ?? "").join("") ?? ""}</p>`
    }
  }
};

const registry = createServerExtensionRegistry([calloutExtension]);
const document = validateRichTextDocument(input, {}, registry);
const html = richTextJsonToHtml(document.content, [calloutExtension]);

Keep the client and server contracts in the same application module or registry factory. The server registry controls the node and mark allowlist, and custom serializer output must still pass through the channel adapter and sanitizer before publishing.

Feature Overview

  • Validate the persisted rich text document envelope.
  • Migrate published schema versions to the current schema.
  • Process documents through the recommended processRichText() pipeline.
  • Import constrained standard HTML into Tiptap JSON.
  • Report channel warnings through a callable capability matrix.
  • Render Tiptap JSON to HTML.
  • Extract plain text for indexing or previews.
  • Sanitize HTML with an allowlist.
  • Remove editor-only metadata before writing HTML to Shopify.

Compatibility

| Package | Supported | | --- | --- | | Node.js | >=22.0.0 | | pnpm | 10.15.x | | Tiptap | ^3.0.0 | | TypeScript | ^5.8.2 |

Package Quality

The published package includes dist, TypeScript declarations, README, and MIT license only.

Maintenance

This package is maintained by Standhigher for Shopify App rich text workflows. Please report bugs and feature requests on GitHub Issues.

Local Development

pnpm install
pnpm -r typecheck
pnpm test
pnpm build

Release Preparation

npm run lint
npm run test
npm run typecheck
npm run build
npm run build-storybook
pnpm pack:dry-run