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 🙏

© 2026 – Pkg Stats / Ryan Hefner

quill-katex

v1.0.0

Published

KaTeX plugin for Quill.js editor with TypeScript support

Downloads

43

Readme

Quill KaTeX Module

Um módulo para o editor Quill.js que permite inserir e renderizar fórmulas matemáticas usando KaTeX. Este módulo é totalmente compatível com TypeScript e JavaScript.

npm version License: MIT

Características

  • Suporte completo para fórmulas matemáticas usando KaTeX
  • Fórmulas em bloco (display mode) e inline
  • Botões na toolbar para inserção de fórmulas
  • Totalmente tipado com TypeScript
  • Compatível com React, Vue, Angular e JavaScript puro
  • Funciona com Next.js (incluindo App Router)
  • Suporte para SSR (Server-Side Rendering)

Instalação

npm install quill-katex katex --save

Ou usando yarn:

yarn add quill-katex katex

Nota: Este módulo requer quill e katex como peer dependencies. Certifique-se de instalá-los se ainda não estiverem instalados no seu projeto.

Uso

Com TypeScript/JavaScript (ES Modules)

import Quill from 'quill';
import { registerKatex } from 'quill-katex';

// Importe os estilos necessários
import 'quill/dist/quill.snow.css'; // ou outro tema que você esteja usando
import 'katex/dist/katex.min.css';

// Registre o módulo
registerKatex(Quill);

// Inicialize o Quill com o módulo KaTeX
const quill = new Quill('#editor', {
  modules: {
    toolbar: {
      container: [
        ['bold', 'italic', 'underline'],
        ['katex', 'katex-inline'] // Adiciona botões para fórmulas KaTeX
      ],
    },
    katex: {
      toolbar: true // Habilita os handlers da toolbar
    }
  },
  theme: 'snow'
});

Com React

import React, { useEffect, useRef } from 'react';
import Quill from 'quill';
import { registerKatex } from 'quill-katex';
import 'quill/dist/quill.snow.css';
import 'katex/dist/katex.min.css';

const QuillEditor: React.FC = () => {
  const editorRef = useRef<HTMLDivElement>(null);
  const quillRef = useRef<any>(null);
  
  useEffect(() => {
    if (editorRef.current && !quillRef.current) {
      // Registra o plugin
      registerKatex(Quill);
      
      // Inicializa o editor
      quillRef.current = new Quill(editorRef.current, {
        modules: {
          toolbar: {
            container: [
              ['bold', 'italic', 'underline'],
              ['katex', 'katex-inline']
            ],
          },
          katex: {
            toolbar: true
          }
        },
        theme: 'snow',
        placeholder: 'Escreva seu conteúdo aqui...'
      });
    }
    
    return () => {
      // Cleanup
    };
  }, []);
  
  return <div ref={editorRef} style={{ height: '300px' }} />;
};

export default QuillEditor;

Com Next.js (App Router)

'use client';

import React, { useEffect, useRef } from 'react';
import dynamic from 'next/dynamic';

// Componente cliente para o editor
const QuillEditor = () => {
  const editorRef = useRef<HTMLDivElement>(null);
  const quillRef = useRef<any>(null);
  
  useEffect(() => {
    const loadQuill = async () => {
      if (editorRef.current && !quillRef.current) {
        // Import dinâmico para evitar problemas de SSR
        const Quill = (await import('quill')).default;
        const { registerKatex } = await import('quill-katex');
        
        // Importa os estilos
        await import('quill/dist/quill.snow.css');
        await import('katex/dist/katex.min.css');
        
        // Registra o plugin
        registerKatex(Quill);
        
        // Inicializa o editor
        quillRef.current = new Quill(editorRef.current, {
          modules: {
            toolbar: {
              container: [
                ['bold', 'italic', 'underline'],
                ['katex', 'katex-inline']
              ],
            },
            katex: {
              toolbar: true
            }
          },
          theme: 'snow',
          placeholder: 'Escreva seu conteúdo aqui...'
        });
      }
    };
    
    loadQuill();
  }, []);
  
  return <div ref={editorRef} className="h-64 bg-white" />;
};

export default QuillEditor;

Importação via CDN (HTML)

<!-- Adicione os estilos do Quill e KaTeX -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/quill.snow.css" rel="stylesheet">

<!-- Elemento do editor -->
<div id="editor" style="height: 300px;"></div>

<!-- Scripts necessários -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/quill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js"></script>

<script>
  // O módulo se registra automaticamente quando detecta o Quill global
  
  // Inicialize o Quill com o módulo KaTeX
  var quill = new Quill('#editor', {
    modules: {
      toolbar: {
        container: [
          ['bold', 'italic', 'underline'],
          ['katex', 'katex-inline']
        ],
      },
      katex: {
        toolbar: true
      }
    },
    theme: 'snow',
    placeholder: 'Escreva seu conteúdo aqui...'
  });
</script>

Personalização

Você pode personalizar o comportamento do plugin através das opções:

const quill = new Quill('#editor', {
  modules: {
    katex: {
      toolbar: true, // Habilita os botões na toolbar
      // Outras opções podem ser adicionadas aqui
    }
  }
});

Estilos

Para garantir que as fórmulas sejam exibidas corretamente, importe os estilos do KaTeX:

import 'katex/dist/katex.min.css';

Ou via HTML:

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" rel="stylesheet">

API

registerKatex(Quill)

Registra o plugin no Quill.

Classes e Componentes Exportados

import { registerKatex, KatexBlot, KatexInlineBlot, KatexModule } from 'quill-katex';
  • registerKatex: Função para registrar o plugin no Quill
  • KatexBlot: Classe para renderização de fórmulas em bloco
  • KatexInlineBlot: Classe para renderização de fórmulas inline
  • KatexModule: Módulo para adicionar funcionalidades ao editor

Formatos

  • katex: Para fórmulas em bloco (display mode)
  • katex-inline: Para fórmulas inline

Exemplos

O pacote inclui exemplos de integração com:

  • HTML puro via CDN
  • React com Vite
  • Next.js

Você pode encontrar esses exemplos na pasta examples/ do repositório.

Compatibilidade

  • Quill.js: v1.3.0 ou superior
  • KaTeX: v0.13.0 ou superior
  • Navegadores modernos (Chrome, Firefox, Safari, Edge)
  • TypeScript: v4.0 ou superior

Contribuindo

Contribuições são bem-vindas! Por favor, sinta-se à vontade para enviar pull requests ou abrir issues.

Licença

MIT