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-paragraph

v1.0.1

Published

A prosemirror-paragraph node which is used to implement features such as text-alignment, text-direction and line-height

Downloads

7

Readme

prosemirror-paragraph

This package defines a prosemirror paragraph node which is used to implement features such as text-alignment, text-direction and line-height.

Live Demo

https://dhananjeyan286.github.io/prosemirror-paragraph/demo/src/index.html

Installation

npm i prosemirror-paragraph

Usage


import { EditorState } from "prosemirror-state"
import { EditorView } from "prosemirror-view"
import { Schema } from "prosemirror-model"
import { schema } from "prosemirror-schema-basic"
import { addListNodes } from "prosemirror-schema-list"
import { addParagraphNode, getPlugins } from "prosemirror-paragraph"

let config = ["textAlignment", "textDirection", "lineHeight"]

// config can also be passed like these
// let config = [
//    "textAlignment", // default value for alignment will be based on default text-direction value
//    {
//        name: "textDirection",
//        default: "ltr" // initially text-direction will be be set to "ltr", default value can also be "rtl"
//    },
//    {
//        name: "lineHeight",
//        default: "normal" // initially line-height will be set to "normal" which is ~1.2, default values can be anyone of these "1.0", "1.5", "2.0"
//    },
// ];

let nodes = addListNodes(schema.spec.nodes, "paragraph block*", "block")

let mySchema = new Schema({
    nodes: addParagraphNode(nodes, config), // to add the paragraph node along with your basic set of nodes
    marks: schema.spec.marks,
});

window.view = new EditorView(document.querySelector("#editor"), {
    state: EditorState.create({
        schema: mySchema,
        plugins: getPlugins({schema: mySchema, config: config}), // add prosemirror-paragraph related plugin along with the plugins added by prosemirror-example-setup package
    }),
});

APIs Exposed


import { getParagraphNode, addParagraphNode, getCommands, getEnterHandlingPlugin, getMenuBar, getMenuBarPlugin, , constructAndGetConfig  } from "prosemirror-paragraph"

getParagraphNode(config) // returns the paragraph node

addParagraphNode(nodes, config) // returns the nodes object after adding the paragraph node

getCommands(config) // returns an object consisting of keys named setLineHeight, setTextDirection and setTextAlignment
// all these keys consists of functions used to change the line-height, text-direction, text-alignment values in the editor

getEnterHandlingPlugin(schema) // returns a plugin to tell to the editor on what needs to be done if enter key is pressed
// it is generally used to carry forward the line-height, text-direction and text-alignment values applied to the previous paragraph
// Note : Push this plugin before pushing any shortcuts plugin so that any function that was bound to the enter key will be overriden by this plugin.

getMenuBar(config) // this returns the content for the menubar for text-alignment, line-height and text-direction, along with the content added by prosemirror-example-setup package

getMenubarPlugin(config) // this returns the plugin for the menubar for text-alignment, line-height and text-direction, along with the menubar added by prosemirror-example-setup package

constructAndGetConfig(config) // if config is a falsy value it returns the default config value, or else it formats the config that you have passed according to the needs of this package.

Authors

RM. Dhananjeyan

Credits

Joe B. Lewis - For knowledge sharing

Issues

Use Github Issues to file requests and bugs.

License

MIT License