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

keystone-react-editor

v1.2.0

Published

## Brief Background 👋 I recently embarked on a journey to integrate the document editor from [Keystone](https://github.com/keystonejs/keystone) into a client-only project. However, I hit a roadblock as the editor was tightly coupled with the Keystone co

Downloads

243

Readme

⚛️⚡ Keystone React Editor

Brief Background

👋 I recently embarked on a journey to integrate the document editor from Keystone into a client-only project. However, I hit a roadblock as the editor was tightly coupled with the Keystone context and carried significant server-side dependencies.

After a thorough investigation into the source code, I identified that the culprit was the relationship feature (tags and mentions), which heavily relied on server-side functionality. Determined to make the document editor more versatile, I decided to take matters into my own hands.

To make the document editor more adaptable to client-only projects, I meticulously extracted its source code from the Keystone repository. I stripped off every trace and dependencies of the relationship feature (with hope to add a client compactible alternative implementation later).

GETTING STARTED

You can view a live storybook demo here

Installation

yarn

yarn add keystone-react-editor

npm

npm install keystone-react-editor

import { useRef } from "react";
import {
  DocumentEditor,
  defaultDocumentFeatures,
  initialEditorValue,
} from "keystone-react-editor";

function App() {
 const value = useRef(initialEditorValue)
  return (
    <DocumentEditor
      initialValue={value.current}
      componentBlocks={{}}
      documentFeatures={defaultDocumentFeatures}
      onChange={(value) => {
        value.current = value;
        console.log(value);
      }}
    />
  );
}

documentFeatures is basically the layout specification, should match what was specified in the cms document field config.

The Document Editor uses slate under the hood, which is an uncontrolled component, we are using ref so as to maintain the initialValue across rerenders, as the document editor tends to remount for every rerender (using a state, leads to some weird behaviour, editor always remounting while being typed on).

Contribution

  1. Clone your repo
  2. Install dependencies with pnpm i (first run corepack enable to enable pnpm)
  3. Run pnpm prepare command to setup Husky pre-commit hooks.

Main Scripts

Always prepending pnpm:

  • dev: Bootstrap the Storybook preview with Hot Reload.
  • build: Builds the static storybook project.
  • build:lib: Builds the component library into the dist folder.
  • lint:fix: Applies linting based on the rules defined in .eslintrc.js.
  • format:prettier: Formats files using the prettier rules defined in .prettierrc.
  • test: Runs testing using watch mode.
  • test:cov: Runs testing displaying a coverage report.

NOTE

ALL TEST ARE CURRENTLY EXCLUDED FROM TYPESCRIPT, STILL TRYING TO GET THEM WORKING

License

MIT