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 🙏

© 2024 – Pkg Stats / Ryan Hefner

prosemirror-plugin-outline

v0.2.2

Published

A ProseMirror plugin to inspect the document tree while editing.

Downloads

8

Readme

prosemirror-plugin-outline

A keyboard-accessible web component for displaying the structure of a ProseMirror document as a tree. It allows selection of a node from outside of the document.

Table of Contents

Installation

npm i prosemirror-plugin-outline

Usage

Import the outlinePlugin() function with all of your other ProseMirror code:

import { EditorState } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
import { outlinePlugin } from "prosemirror-plugin-outline";

const schema = new Schema(
  // SchemaSpec goes here
);

new EditorView(document.querySelector("#editor"), {
  state: EditorState.create({
    schema: schema,
    plugins: [
      // load other plugins
      outlinePlugin({
        // see function documentation for configuration
      }),
    ],
  }),
});

Styling

An example stylesheet that uses shadow parts to provide hover, focus, and active styles with system colors can be imported for bundler use via prosemirror-plugin-outline/styles/outline.css.

Documentation

This module exports a function, view, and plugin key for attaching an outline to a ProseMirror editor. Type declarations for the exported items are generated from JSDoc annotations in the code.

A quick reference is below; refer to the documentation comments in the code and its corresponding type declarations for a more thorough breakdown.

Exports

OutlineView

The class for creating and updating the outline.

outlinePlugin()

A function that returns a plugin you can pass to the editor state. You may optionally pass an object with the following properties:

  • element: Where the outline should be adjacently inserted
  • where: The InsertPosition indicating where to insert the element relative to the element key
  • toggle(isVisible): A function that runs when the visible property of the plugin's state changes; it receives a boolean value indicating whether or not the outline should be visible
  • state: An object representing the initial state of the outline plugin
    • visible: A boolean value indicating whether or not the outline is visible

outlinePluginKey

The key of the plugin created by outlinePlugin().

ProseMirrorOutline

The class for the custom element that contains the outline. The custom element uses shadow DOM, and it exposes elements for styling via the part attribute. It is built to be keyboard accessible according to the WAI-ARIA treegrid pattern.

styles/outline.css

An example of how one could style the outline's shadow DOM via the ::part() pseudo-element. It provides hover, focus, and active styles.