You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

tiptap-parser

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiptap-parser

HTML parser to React component built on the top of html-react-parser with code syntax highlighting

0.0.7
npmnpm
Version published
Weekly downloads
122
-40.49%
Maintainers
1
Weekly downloads
 
Created
Source

tiptap-parser

tiptap-parser: HTML parser for Tiptap editor build on the of html-react-parser with code syntax highlighting.

Table of Contents

Use case

Tiptap editor is a text editor used mainly for blogging, and therefore in the back office.
The problem is that if it's just to display the content (for example in a Next.js website), it is overkill to install Tiptap or mui-tiptap editor (and the whole MUI library).
The purpose of this library is precisely to display the contents of mui-tiptap-editor which is an html saved as text. If you are using a dev oriented blog like Medium, this library is for you.

Demo

Try it yourself in this CodeSandbox live demo

Screenshot

Installation


npm  install  tiptap-parser

or


yarn  add  tiptap-parser

Get started

Simple usage

import TiptapParser from "tiptap-parser";

const html = `<h1>Hello world</h1>`;

function App() {
  return (
    <TiptapParser content={html} />
  );
}

Content with code

const html = `<><h1>Hello there</h1><pre><code>console.log("Log something here")</code></pre></>`;

<TiptapParser content={html} language="typescript" />

Customization

const html = `<p><h1>Hello there</h1></p>`;

<TiptapParser
  containerClassName="bg-gray-100"
  classNames={{
    codeClassName: 'p-6',
    h1ClassName: 'text-xl',
    aClassName: 'underline',
    pClassName: 'text-gray-400'
  }}
  content={html}
/>

Props

propstypeDefault valueDescription
contentstringemptyhtml string to be displayed
containerClassNamestringemptystyles of the container
classNamesClassNamePropsemptyclass names of each element withing the container
languagestringjavascriptlanguage of the code. see the list

classNames Props

propstypeDefault valueDescription
codeClassNamestringemptyclass name of code element
h1ClassNamestringemptyclass name of h1 element
h2ClassNamestringemptyclass name of h2 element
h3ClassNamestringemptyclass name of h3 element
h4ClassNamestringemptyclass name of h4 element
h5ClassNamestringemptyclass name of h5 element
h6ClassNamestringemptyclass name of h6 element
pClassNamestringemptyclass name of p element
ulClassNamestringemptyclass name of ul element
spanClassNamestringemptyclass name of span element
divClassNamestringemptyclass name of div element
aClassNamestringemptyclass name of a element
tableClassNamestringemptyclass name of table element
imageClassNamestringemptyclass name of image element
other propsHTMLReactParserOptionsemptyall html-react-parser props

Contributing

Get started here.

Keywords

tiptap

FAQs

Package last updated on 09 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts