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

@prisma/text-editors

v0.0.22

Published

![tests](https://github.com/prisma/text-editors/actions/workflows/ci.yml/badge.svg) ![npm-version](https://badgen.net/npm/v/@prisma/text-editors)

Downloads

128

Readme

@prisma/text-editors

tests npm-version

This package exports a bunch of batteries-included code editors for Typescript, JSON, SQL & Prisma Schemas. The goal is to be a zero-configuration component that is quick to load and that you just dump into your codebase so it "just works".

Demo

A demo of the editors is here. Note that these editors were built for the Prisma Data Platform's Query Console, so head over there to see them in action in a real app.

Installation

npm i @prisma/text-editors

yarn add @prisma/text-editors

Usage

The editors are currently only exported as a React component, but support for other frameworks should be trivial to implement, since all of editor functionality is written in vanilla JS.

Usage with React:

import React, { useState } from "react";
import { Editor } from "@prisma/text-editors";

// ..snip

const [code, setCode] = useState("");

return <Editor lang="ts" value={code} onChange={setCode} />;

This gives you an editor that includes Typescript syntax highlighting, typechecking, auto-complete & quickinfo on token hover.

Editor props

  • lang (required): Controls what language the editor's value will be. This enables or disables certain feature, depending on the language. Currently supported languages are: Typescript (ts), JSON (json), SQL (sql) and Prisma Schema Language (prisma)

  • value (required): The text / code that will be shown in the editor. In general, it is recommended to pass in a controlled React prop here and update its value whenever the editor calls onChange. Changing this value directly will cause the editor to recreate its own internal state from scratch, which can be expensive.

  • readonly: Controls if the editor will allow changes to the value

  • theme: Controls the editor theme, Currently supported themes are light & dark

  • style: Any CSS properties passed here will be spread on to the editor container

  • classNames: Any class names pass here will be applied to the editor container

  • types (only valid when lang=ts): Key value pairs of additional Typescript types that will be injected into the editor lazily. The key must be the "location" of this types (common values are /node_modules/your-package/index.d.ts), and the value must be the actual types (such as export type MyType = string). These can be useful to fake custom imports in the editor, and affect auto-complete (among other things custom types let you do in VSCode, for example)


Contributing

Please read through the Wiki to learn more about how this package works, and how to contribute.