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

virgil-editor

v1.0.2

Published

A WYSIWYG editor built with DraftJS

Downloads

7

Readme

Virgil - WYSIWYG Editor

Documentation and Demo

Virgil is an online editor designed to give your content creation a more seamless flow. Focusing more on a distraction-free environment, Virgil aims to give you all of the features of a WYSIWYG editor in a minimalist package. We have extended DraftJS to support images and video content, as well as URL insertion, markdown, serialized output, and much more. Similarly to the Roman Poet, Virgil, we sought to make it easier for authors to create meaning in their works.

Installation

You can install Virgil into your React or NextJS project by doing the following:

npm install virgil-editor --save
yarn add virgil-editor

Usage

If your building a ReactJS project, importing the component in the traditional way or asynchronous is fine. For example:

import Virgil from 'virgil-editor'

If you're building a NextJS project, then you will have to import Virgil asynchronous with SSR disabled

import dynamic from 'next/dynamic'
const Virgil = dynamic(() => import('./components/editor'), { ssr: false })

Render

You can render the Virgil editor using the code below. With Virgil, you need to set an editor object as a ref. Although it's not required, you can also set a content prop, if you are loading in contentBlock data. We also recommend setting the startFocus prop to true as well, which will set the editor to focus as soon as it loads into view.

import React, { useState } from 'react'
import Virgil from 'virgil-editor'

const App = () => {
  const [ initial ] = useState({"blocks":[],"entityMap":{}})
  const [ editor, setEditor ] = useState({})

  return (
    <Virgil content={initial} onRef={ref => setEditor(ref)} startFocus={true} />
  )
}

To set your initial data into Virgil Editor, you can add a Serialized Content Object to the Virgil content prop.

Retrieve Data

To retrieve data from Virgil, you can make use of the Editor's built-in functions and its ref variable.

editor.getSerializedOutput() // Outputs blocks array and entity map 

Uploading Images

Virgil allows you to asynchronously upload images as you add them to your content. In order to use this feature, you must pass an image upload function to Virgil using the "imageUpload" prop. Your image upload function should have a callback that returns the url of your newly uploaded image.

Virgil outputs an object to be passed to your function as a parameter. The object contains a key of "image" and a value of your base64 encoded image.

Here is an example of an upload function using Firebase and its implementation with Virgil.

const uploadToServer = async(imageData) => {
  await axios({
    method: 'POST',
    url: https://Your-upload-url?token=idTokens,
    headers: { 'Content-Type': 'application/json' }
    data: imageData
  })
  .then(response => response.data)
  .then(json => {
    return json.url
  })  
  .catch(error => {
    console.log(error)
  })
}

return (
  <Virgil onRef={ref => setEditor(ref)} imageUpload={uploadToServer} />
)

Markdown

Virgil has support for some basic Markdown features (which are live-rendered in the editor). See the documentation for more details.

Technologies

  • ReactJS
  • DraftJS
  • Proxima-UI

License

MIT