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

@guardian/prosemirror-editor

v0.2.0

Published

Providing implementations of ProseMirror for use the Guardian's tools.

Downloads

11

Readme

prosemirror-editor

View package on npm.

This project is intended to provide a re-usable ProseMirror editor for use across our tools. Up front, it aims to replace Scribe-based rich text editors with a React-based prosemirror editor in:

It is also designed to meet the features required by the rich text editor in media-atom-maker.

It aims to provide:

  • A RichTextEditor serialising to one-to-many <p> tags containing the markup below - supporting only the requirements of the above editors, at least until we have further use cases. Specifically, from the first three editors:
    • bold (strong) markup
    • italic (em) markup
    • links
    • unlinking
    • strikethrough
    • superscript and subscript
  • media-atom-maker adds some more requirements:
    • bullet-list
    • a 'flat' text editor used for trail text, serialising text as a single paragraph with tags providing line breaks.
    • an editor that can be 'copied into' from another editor, e.g. duplicating standfirst to trail text in media-atom-maker
  • A means of specifying a subset of the supported features per editor instance, via the config exports
  • A transformToLegacyMarkup method, for transforming the serialised html output by the library. Some of our tools expect <b> and <i> tags instead of the semantically preferred <em> and <strong> tags. Rather than serialised as <b> and <i> internally, within ProseMirror, we provide a transformer to replace <strong> and <em> to <b> and <i> after the editor updates text.

The interface of RichTextEditor currently expects:

{
  value: string; // Serialised html to initialise the editor with, i.e. a previous saved value for a rich text field
  onUpdate: (str: string) => void; // A function to call with updated text on update
  config: EditorConfig; // The config for the editor, specifying supported markup, and whether the editor is multi-paragraph or 'flat'
  label?: string; // A label for the editor
  shouldAcceptCopiedText: boolean; // Whether the editor should programmatic text replacmement from another rich text field
}

Things this repo doesn't have, that we will want to add in future PRs:

  • A means of testing changes from this package itself, for example a demo-app that includes the React editor component. Currently this package only builds a component to be used by other packages.

Currently, vanilla css styles are included in the built dist and need to be imported in the target package.

How to run

  • Publish this package locally using yarn yalc from the root of the project
  • Import into another project using yalc

Deploying

This package is deployed to npm when branches are deployed to main, provided the branch name conforms to conventional commits.

Most importantly, a PR name starting with:

  • feat!: with a commit message starting BREAKING CHANGE: will trigger a major version
  • feat: will release a major version
  • fix: will release a patch version

Deployment is managed by a GitHub Action defined in .github/workflows