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

@open-wysiwyg-editor/astro

v1.0.2

Published

Astro component for open-wysiwyg-editor: <RichTextEditor name value />, works with plain form posts. Accessible (WCAG 2.2 AA), RTL-first, CSP-safe.

Readme

@open-wysiwyg-editor/astro

npm version license

Live demo → · GitHub · npm

An Astro component for the Open WYSIWYG Editor: an accessible (WCAG 2.2 AA), RTL-first rich text editor that runs under a strict Content Security Policy. It renders an <owe-editor> form field, so it works with plain form posts and needs no UI framework or client island.

<RichTextEditor name="body" value="<p>Hello</p>" />

Install

npm install @open-wysiwyg-editor/astro

Requires Astro 4 or newer.

Usage

The component imports its own script and styles, so you don't add anything else.

---
import { RichTextEditor } from "@open-wysiwyg-editor/astro";
---

<form method="post" action="/api/save">
  <label for="body">Article</label>
  <RichTextEditor id="body" name="body" value="<p>Hello <strong>world</strong></p>" />
  <button>Save</button>
</form>

The editor is form-associated: the HTML is submitted under name with the surrounding <form>, and form.reset() restores the field.

Props

| Prop | Type | Notes | | --- | --- | --- | | name | string | Form field name | | value | string | Initial content as HTML | | placeholder | string | | | label | string | Accessible name. Or point a <label for> at the component's id | | readonly, disabled | boolean | | | language | string | UI language, for example "ar". Defaults to <html lang> | | dir | "ltr", "rtl" or "auto" | Base direction of the content | | toolbar | string | Toolbar items separated by spaces, for example "bold italic \| link", or "none" | | other | | Any HTML attribute (id, class, data-*…) is passed to the element |

language and toolbar are read when the editor is created. The rest follow later changes.

Arabic and a custom toolbar

<RichTextEditor
  name="body"
  language="ar"
  dir="rtl"
  label="المحتوى"
  toolbar="bold italic underline | link bulletList orderedList"
/>

Reading the value in a page script

The element fires input on every change and change when it loses focus after a change. element.value is the HTML, and element.editor is the editor instance once it has started.

<RichTextEditor id="body" name="body" />

<script>
  const field = document.querySelector<HTMLElement & { value: string }>("#body")!;
  field.addEventListener("input", () => console.log(field.value));
</script>

For the full editor API (getHTML(), commands, on()…), use field.editor. For extra createEditor options, set field.options = { … } before the element connects. See the HTML forms and options sections of the core docs.

Saving: form post and API route

src/pages/api/save.ts (needs an adapter, or a prerender-off route):

import type { APIRoute } from "astro";

export const prerender = false;

export const POST: APIRoute = async ({ request }) => {
  const form = await request.formData();
  const body = String(form.get("body") ?? "");
  // Sanitize again on the server before you store or render it for other users.
  return Response.json({ length: body.length });
};

In an Astro page (server output), read the same field with await Astro.request.formData() when Astro.request.method === "POST".

Styling

The component already imports open-wysiwyg-editor/style.css, and Astro bundles it with your page. Theme it with CSS variables; see Styling in the core docs. To show saved HTML elsewhere, import open-wysiwyg-editor/content.css.

SSR and static builds

The server (or the static build) renders only the <owe-editor> element, with the initial HTML in its value attribute. Astro escapes that attribute, so content from users can't run before the editor sanitizes it. The editor starts in the browser, and the field works with a plain form post in both static and server output.

Links

License

MIT © alhassan-ahmed