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

@creaditor/text-api

v1.0.8

Published

text-api is a simple text editor API built for Developers.

Downloads

2

Readme

TextAPI

TextAPI.js is A completely customizable for building rich text editors in the browser.

Keep the following in mind

  • TextAPI.js is an abstraction, please know that there is no UI.
  • Undo/Redo will come in the future

DEMO

try me

API Overview

Install

npm i @creaditor/text-api --save

Include the module in your application

import TextAPI from "@creaditor/text-api";

TextAPI provides two working modes

| Mode | Description | | ------ | -------------------------------------------------------------------- | | Toggle | Style elements with on/off functionality, like bold,underline,italic | | | | Extend | Only extends the currect style, font-size, color, backgorund |

Basic Usage

Toggle

import TextAPI from '@creaditor/text-api';
const textAPI = new TextAPI("editor-id");
1cont MODES = textAPI.MODES;

const underline =()=> textAPI.execCmd('text-decoration', 'underline', Modes.Toggle);
const bold =()=> textAPI.execCmd('font-weight', 'bold', MODES.Toggle);

Extend

import TextAPI from '@creaditor/text-api';
const textAPI = new TextAPI("editor-id");
cont MODES = textAPI.MODES;

const changeColor =(color)=> textAPI.execCmd('color', color, MODES.Extend);
const changeSize =(size)=> textAPI.execCmd('font-size', size, MODES.Extend);

With Options

The textAlign, padding, margin, line-height and more property sets the horizontal alignment of text in a block level element. It must be used on a block level element (p, div, etc.)

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");
const MODES = textAPI.MODES;

const changeAlign = (align) =>
  textAPI.execCmd("text-align", align, MODES.Extend, {
    target: "block",
  });

Inspector

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");

textAPI.on("inspect", (collectedStyles) => {
  // do something with the styles..
});

Format Block

Adds an HTML block-level element around the line containing the current selection.

Tags

| Tag Name | | -------- | | H1 | | H2 | | H3 | | H4 | | H5 | | H6 | | P | | PRE | | ADDRESS |

How to use

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");

const toggleClass = (tagName) => textAPI.formatBlock(tagName);

Style with Tags (toggle mode)

| Tag Name | | -------- | | B | | STRONG | | MARK | | EM | | I | | S | | STRIKE | | DEL | | U | | SUB | | SUP | | SMALL | | SUB |

How to use

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");

textAPI.toggleWith("strong");

Css Class API

The Css Class API lets you create a Css class with your pre-made rules. You can pass this class to a TextAPI object and use it as a markup just like underline or bold.

How to use

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");

const toggleClass = (name) => textAPI.toggleClass(name);

Links

How to use

import TextAPI from '@creaditor/text-api';
const textAPI = new TextAPI("editor-id");

const createLink = () => textAPI.link({
href:'textAPI.com',
protocol:'https'
target:'_blank'
});

Links Inspector

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");

textAPI.on("inspectLink", (props) => {
  // {href,protocl,target,element}
});

Save Function

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");

const contentAsJson = textAPI.save();

Load Function

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");

textAPI.load(contentAsJson);

Destroy

Will remove all TextAPI functionality.

import TextAPI from "@creaditor/text-api";
const textAPI = new TextAPI("editor-id");

textAPI.destroy();

text-api