Giter Site home page Giter Site logo

bernesto / grapesjs-icons Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bgrand-ch/grapesjs-icons

0.0 0.0 0.0 1.37 MB

GrapesJS icons plugin with Iconify

License: BSD 3-Clause "New" or "Revised" License

JavaScript 1.81% TypeScript 96.04% HTML 2.15%

grapesjs-icons's Introduction

GrapesJS icons plugin with Iconify

grapesjs-icons plugin is not an official Iconify plugin and is not maintained by the Iconify team. This plugin uses the Iconify API. This API is the biggest expense of the Iconify team. If you use grapesjs-icons plugin, please donate to Iconify to guarantee free use of the API.

Demo

GrapesJS icons plugin demo

Installation

npm install grapesjs-icons
pnpm add grapesjs-icons
yarn add grapesjs-icons

Usage

JavaScript

import grapesjs from 'grapesjs'
import grapesjsIcons from 'grapesjs-icons'

const options = {
  // see https://icon-sets.iconify.design/
  collections: [
    'ri', // Remix Icon by Remix Design
    'mdi', // Material Design Icons by Pictogrammers
    'uim', // Unicons Monochrome by Iconscout
    'streamline-emojis' // Streamline Emojis by Streamline
  ]
}
const editor = grapesjs.init({
  // ...
  plugins: [
    grapesjsIcons
  ],
  pluginOpts: {
    [grapesjsIcons]: options
  }
  // ...
})

TypeScript

import grapesjs, { usePlugin } from 'grapesjs'
import grapesjsIcons from 'grapesjs-icons'

import type { PluginOptions } from 'grapesjs-icons'

const options: PluginOptions = {
  // see https://icon-sets.iconify.design/
  collections: [
    'ri', // Remix Icon by Remix Design,
    'mdi', // Material Design Icons by Pictogrammers
    'uim', // Unicons Monochrome by Iconscout
    'streamline-emojis' // Streamline Emojis by Streamline
  ]
}
const editor = grapesjs.init({
  // ...
  plugins: [
    usePlugin(grapesjsIcons, options)
  ]
  // ...
})

How do I find and use an Iconify collection?

  1. Search for an icon collection on the Iconify website.
  2. Click on a collection (a.k.a "set" on Iconify website) or an icon.
  3. Copy the shortcut name of the collection in the URL. Examples:
    • Remix collection: https://icon-sets.iconify.design/ri/ -> Copy ri
    • Remix icon: https://icon-sets.iconify.design/ri/add-fill/ -> Copy ri
  4. Paste the shortcut name of the collection in the collections option of the plugin.

Command

click insertion mode is not yet implemented. The idea is to open the icons modal from anywhere using the open-icons-modal command, choose an icon and drop it by clicking somewhere in the GrapesJS canvas. Do you want contribute?

editor.runCommand('open-icons-modal')

Options

{
  // required, list of collection shortcut names
  collections: string[],

  // optional
  modal: {
    title: string,
    collectionText: string,
    categoryText: string,
    searchText: string
  },
  component: {
    type: string,
    name: string
  },
  block: {
    category: string
  }
}

Question? Idea?

If you have a question about how grapesjs-icons works or an idea to improve it, the Discussions tab in GitHub is the place to be.

However, if you get an error, you should open an issue.

License

Distributed under the BSD 3-Clause License. See LICENSE for more information.

Contact

Benjamin Grand @bgrand_ch

grapesjs-icons's People

Contributors

bgrand-ch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.