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

jodit-vue

v3.1.0

Published

Vue wrapper for Jodit Editor

Downloads

6,417

Readme

How to use

Use version 2.* for Vue 2

Use version 3.* for Vue 3

Install Jodit Vue:

npm install jodit-vue --save
// or with Yarn
yarn add jodit-vue

Import and use it

Since this component is just a wrapper, you need to include the css of the Jodit Editor on your app for it to work properly, if you're using vue-cli to create your app, or another build system you can import it directly or add a link tag with the css file provided by the Jodit Editor package.

import 'jodit/build/jodit.min.css'
import Vue from 'vue'
import JoditVue from 'jodit-vue'

Vue.use(JoditVue)

Instead of using Vue.use(JoditVue) you can use the component locally

<template>
    <div id="app">
        <jodit-editor v-model="content" />
    </div>
</template>

<script>
import 'jodit/build/jodit.min.css'
import { JoditEditor } from 'jodit-vue'

export default {
    name: 'app',

    components: { JoditEditor },

    data () {
        return {
            content: '<h1>Hello Jodit Vue</h1>'
        }
    }
}
</script>

You can check and test it on Codesanbox too.

Using without a build system

If you don't use a build system on your app, you can also use Jodit Vue without problems, check and test it on this JsFiddle.

Component Properties

If you pass only the v-model for the component, it will load all the editor features, if you want to customize it, you can do it with its properties that are listed below, but all of them are not required, just if you want to customize your editor that you will need them:

| Property | Type | Default Value | Description | | :--------------: | :-----: | :-----------: | :-------------------------------------------------------------------------------------------------------------------: | | buttons | Array | null | The buttons that you want to show on toolbar, if this is not provided, all the buttons will be shown | | extraButtons | Array | null | If you need to create and display custom buttons you can pass an array with your custom buttons to this property | | config | Object | {} | The config object that has all the other configurations for the editor | | plugins | Array | [] | If you need to create custom plugins you can pass array of plugins to this property |

Buttons property

When providing the buttons to show on the editor you will need to provide an array with the buttons that you want to show. The button names can be found here. You can also pass a | to put a divider between the buttons.

<template>
    <div id="app">
        <jodit-editor v-model="content" :buttons="buttons" />
    </div>
</template>

<script>
import 'jodit/build/jodit.min.css'
import { JoditEditor } from 'jodit-vue'

export default {
    name: 'app',

    components: { JoditEditor },

    data () {
        return {
            content: '<h1>Hello Jodit Vue</h1>',
            buttons: ['source', 'image', '|', 'bold', 'underline', 'italic']
        }
    }
}
</script>

Extra Buttons property

If you need to create custom buttons to the editor, you can create them and provide the component with an array

<template>
    <div id="app">
        <jodit-editor v-model="content" :buttons="buttons" :extra-buttons="customButtons" />
    </div>
</template>

<script>
import 'jodit/build/jodit.min.css'
import { JoditEditor } from 'jodit-vue'

export default {
    name: 'app',

    components: { JoditEditor },

    data () {
        return {
            content: '<h1>Hello Jodit Vue</h1>',
            buttons: ['source', 'image', '|', 'bold', 'underline', 'italic'],
            customButtons: [
                {
                    name: 'insertDate',
                    iconURL: 'http://xdsoft.net/jodit/logo.png',
                    exec: function (editor) {
                        editor.selection.insertHTML((new Date).toDateString());
                    }
                }
            ]
        }
    }
}
</script>

To create custom buttons, check the Jodit Editor Docs

Config property

This config allows you to pass all the other configurations found here to customize your editor

Plugins property

Plugins property allows you to pass array of plugin objects with name and callback which will be initialized when Jodit is initialized. Plugins are initialized globally and it will added to all instances of Jodit editor. For example:

<template>
    <div id="app">
        <jodit-editor v-model="content" :plugins="plugins" />
    </div>
</template>

<script>
import 'jodit/build/jodit.min.css'
import { JoditEditor } from 'jodit-vue'

export default {
    name: 'app',

    components: { JoditEditor },

    data () {
        return {
            content: '<h1>Hello Jodit Vue</h1>',
            plugins: [
              {
                name: 'example',
                callback: function (editor) {
                  editor.events.on('afterInit', function () {
                    console.warn('Example plugin has beed initialized, check Jodit documentation for more details.')
                  })
                }
              }
            ]
        }
    }
}
</script>

To add plugins Jodit Vue uses Jodit.plugins.add API. Check Jodit documentation and examples how to implement plugins.

Credits ✨