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

urdu-web-editor

v1.0.22

Published

Urdu Rich Text Editor for web based on lexical

Downloads

28

Readme

urdu-web-editor

Urdu Rich Text Editor for web based on lexical

NPM JavaScript Style Guide

Install

npm install --save urdu-web-editor

Usage

import React, { useState, useCallback, Component } from 'react'

import Editor from 'urdu-web-editor'

class Example extends Component {
  const [value, setValue] = useState(null);
  const onSave = useCallback((newContents) => {
    console.log('onSave:', newContents)
  });

  const onChange = useCallback((newContents) => {
    console.log('onChange:', newContents)
  });

  const uiConfiguration = {
    "richText" : true,
    "format": "raw",
    "language" : "en",
    "placeholder" : null,
    "toolbar" : {
      "showAlignment": true,
      "showBlockFormat": true,
      "showFontFormat": true,
      "showInsert": true,
      "showListFormat": true,
      "showUndoRedo": true,
      "showExtraFormat": true,
      "showInsertLink": true,
      "showSave": true,
    },
    "spellchecker" : {
      "enabled": false,
      "language" : "en",
      "punctuationCorrections": () => [],
      "autoCorrections": () => [],
      "wordList" : () => [],
    }
  };

  render() {
    return <Editor initialValue={value}
        onChange={onChange}
        onSave={onSave}
        configuration={uiConfiguration} />
  }
}

Properties

Value

It is the value that you want to set for the editor. Its value depends on the format. If the type of editor and format used.

  • If using plain text editor, it must be plain text.
  • If using rich text editor with raw format, provided value must be a valid lexical state json
  • If using rich text editor with markdown format, provided value must be a valid markdown

Pass null if initializing an empty editor

OnChange

Callback function called when any change in editor takes place, parameter passed in the callback function is the formatted value from editor. This value can be passed back into value property.

OnSave

This callback function is called when save button is clicked on the editor. This will only work if the showSave is set to true in the configuration object

Configuration

Configuration object to customize the functionality and ui of the editor. Its structure is as follows:

  {
    "richText" : false,
    "format": "raw",
    "language" : "en",
    "placeholder" : null,
    "toolbar" : {
      "fonts" : null,
      "defaultFont": null,
      "showAlignment": true,
      "showBlockFormat": true,
      "showFontFormat": true,
      "showInsert": true,
      "showListFormat": true,
      "showUndoRedo": true,
      "showExtraFormat": true,
      "showInsertLink": true,
      "showSave": false,
    },
    "spellchecker" : {
      "enabled": false,
      "language" : "en",
      "punctuationCorrections": () => [],
      "autoCorrections": () => [],
      "wordList" : () => [],
    }
  }
richText

Type : boolean

Default value : false

Set it to true to use rich text editor. Otherwise plain text editor is used.

format

Type : string

Default value : raw

Possible values : raw, markdown

Set the format of output from editor when richText is set to true. The value, onChange and onSave will use this property to import or export editor contents in the selected format.

language

Type : string

Default value : en

Possible values : en, ur

This is the two letter language code to use for user interface. Editor features and layout will be modified based on language.

placeholder

Type: string

Default value : null

Text to use when there is no value present. By default a generic message will be used while placeholder is not specified or is null.

toolbar

Type : object

Default value :

{
  "fonts" : null,
  "defaultFont": null,
  "showAlignment": true,
  "showBlockFormat": true,
  "showFontFormat": true,
  "showInsert": true,
  "showListFormat": true,
  "showUndoRedo": true,
  "showExtraFormat": true,
  "showInsertLink": true,
  "showSave": false,
}

| Property | type | Default Value | Description | | ----- | ----- | ----- | ---------------| | fonts | object | null | List of fonts to show. If null a standard list of fonts is shown. | | defaultFont | string | null | Font-face value of default font. If this property is null first font is selected as default font. | | showAlignment | bool | true | Show/hide text alignment controls | | showBlockFormat | bool | true | Show/hide text alignment controls | | showFontFormat | bool | true | Show/hide text alignment controls | | showInsert | bool | true | Show/hide text insert menu | | showListFormat | bool | true | Show/hide text list formatting controls | | showUndoRedo | bool | true | Show/hide text undo and redo controls | | showExtraFormat | bool | true | Show/hide extra formatting options of superscript, subscript and strike through | | showInsertLink | bool | true | Show/hide insert link button | | showSave | bool | false | Show/hide save button |

Default font list and value of font-face
[
  { "value": "Arial", "label": "Arial" },
  { "value": "Courier New", "label": "Courier New" },
  { "value": "Georgia", "label": "Georgia" },
  { "value": "Times New Roman", "label": "Times New Roman" },
  { "value": "Trebuchet MS", "label": "Trebuchet MS" },
  { "value": "Verdana", "label": "Verdana" },
]

spellchecker

Type : object

Default value :

{
  "enabled": false,
  "language : "en",
  "punctuationCorrections": (lang) => [],
  "autoCorrections": (lang) => [],
  "wordList" : (lang) => [],
}

| Property | type | Default Value | Description | | ----- | ----- | ----- | ---------------| | enabled | bool | false | Enable/disable language tools including spell checker | | language | string | en | Two character language code to use for language tools including spell checker. | | punctuationCorrections | function(language) | [] | Function to load punctuation correction list. See below for details. | | autoCorrections | function(language) | [] | Function to load automatic correction list. See below for details. | | wordList | function(language) | [] | Function to load word list for spell checking. It is a simple string array. |

Punctuation and auto correct function response structure
[{
  "incorrectText": "",
  "correctText": "",
  "completeWord": true
}]

Development

Install dependencies

npm install

Develop library

npm start

License

MIT © umerfaruk