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

grapesjs-tailwind-typeahead

v1.5.5

Published

Grapesjs Tailwind Typeahead Plugin

Downloads

241

Readme

GrapesJS Tailwind Typeahead plugin

Edit your pages using Tailwind CSS classes. Typeahead is included to assist with finding the correct syntax. Validate your choice by using the enter key or choose directly from the suggestions using the cursor keys.

Theme settings and Tailwind CSS directives can be modified from the toolbar and are stored in the GrapesJS configuration

Fonts can be imported using the TW directives and declared for use in the Theme configuration

For working with different screen size, change to the device and start the typeahead suggestions with the modifier ( e.g sm:text-fuchsia-400 )

This plugin will generation most selectors (6000+) but not the base, component and utilities directives classes yet

DEMO

Find a live demo here GrapesJS Tailwind CSS Typeahead Demo

HTML

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<link href="https://unpkg.com/grapesjs-tailwind-typeahead/dist/grapesjs-tailwind-typeahead.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/grapesjs-tailwind-typeahead"></script>


<div id="gjs"></div>

JS

// sample theme configuration
const config = {
  content: [],
  theme: {
    extend: {
      colors: {
        greyjoy: "#9FBEAF",
        pacific: "#00ADC6",
        dune: "#FCD385",
        apache: "#BC9D45",
        "viridian-green": "#668980",
        azalea: "#E196AA",
        logan: "#9190AC",
        acid: "#F0FF93",
        "aqua-green": "#9FD9B4",
        "coton-candy": "#FAD6DE",
        igloo: "#B5D0EE",
      },
      width: {
        fhd: "1920px",
      },
      height: {
        fhd: "1080px",
      },
    }
  }
}

const directives = 
  `@tailwind base;
  @tailwind components;
  @tailwind utilities;`

const escapeName = (name) => `${name}`.trim().replace(/([^a-z0-9\[\]\w-:/]+)/gi, '-')

const editor = grapesjs.init({
    height: '100%',
    container: '#gjs',
    showOffsets: true,
    fromElement: true,
    noticeOnUnload: false,
    storageManager: false,
    deviceManager: { // standard Tailwind CSS breakpoint
      default: '',
      devices: [
        {
          id: 'desktop',
          name: 'desktop',
          width: '',
        },
        {
          id: 'sm',
          name: 'sm: 640px',
          width: '640px',
          widthMedia: '640px',
          maxWidth: '768px',
        },
        {
          id: 'md',
          name: 'md: 768px',
          width: '768px',
          widthMedia: '768px',
        },
        {
          id: 'lg',
          name: 'lg: 1024px',
          width: '1024px',
          widthMedia: '1024px',
        },
        {
          id: 'xl',
          name: 'xl: 1280px',
          width: '1280px',
          widthMedia: '1280px',
        },
        {
          id: '2xl',
          name: '2xl: 1536px',
          width: '1536px',
          widthMedia: '1536px',
        },
      ],
    },
    styleManager: {
      custom: true,
    },
    selectorManager: {
      escapeName, // suports custom (bracketed) Tailwind instructions 
      componentFirst: true, // allow a per component modification of classes
    },
    plugins: ['grapesjs-tailwind-typeahead'],
    pluginsOpts: {
      'grapesjs-tailwind-typeahead': { /* options */ }
    }
  });

CSS

body, html {
  margin: 0;
  height: 100%;
}

Summary

  • Plugin name: grapesjs-tailwind-typeahead

Options

| Option | Description | Default | |-|-|- | twCssPlayCdn | Tailwind CSS Play CDN | https://cdn.tailwindcss.com" | | twCssTheme | Tailwind CSS configuration | {} | | twCssDirectives | Tailwind CSS directives | @tailwind base; @tailwind components; @tailwind utilities; | | twCssRemoveWrapper | Remove the wrapper (usually body) from html output | true | | twCssRemoveId | Remove element id from html output | true | | twCssDark | Prepend Tailwind CSS classes with 'dark:' | true | | twCssLimit | Number of suggestions to show | 12 | | codeMirrorTheme |Code Editor theme | hopscotch |

When setting twCssRemoveId to true, the HTML Output will be stripped of the IDs, except for those beginning with the GrapesJS Prefix.

All inline styles will be removed.

Download

  • CDN
    • https://unpkg.com/grapesjs-tailwind-typeahead
  • NPM
    • npm i grapesjs-tailwind-typeahead
  • GIT
    • git clone https://github.com/touchflows/grapesjs-tailwind-typeahead.git

Usage

Directly in the browser

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/grapesjs"></script>
<script src="path/to/grapesjs-tailwind-typeahead.min.js"></script>

<div id="gjs"></div>

<script type="text/javascript">
  var editor = grapesjs.init({
      container: '#gjs',
      // ...
      plugins: ['grapesjs-tailwind-typeahead'],
      pluginsOpts: {
        'grapesjs-tailwind-typeahead': { /* options */ }
      }
  });
</script>

Modern javascript

import grapesjs from 'grapesjs';
import plugin from 'grapesjs-tailwind-typeahead';
import 'grapesjs/dist/css/grapes.min.css';
import 'grapesjs-tailwind-typeahead/dist/grapesjs-tailwind-typeahead.min.css';


const editor = grapesjs.init({
  container : '#gjs',
  // ...
  plugins: [plugin],
  pluginsOpts: {
    [plugin]: { /* options */ }
  }
  // or
  plugins: [
    editor => plugin(editor, { /* options */ }),
  ],
});

Development

Clone the repository

$ git clone https://github.com/TouchFlows/grapesjs-tailwind-typeahead.git
$ cd grapesjs-tailwind-typeahead

Install dependencies

$ npm i

Start the dev server

$ npm run dev

Build the source

$ npm run build

License

MIT