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

vue-mce

v1.5.3

Published

VueJS component for TinyMCE

Downloads

2,726

Readme

vue-mce

npm License Build Status PRs Welcome

VueJS component for TinyMCE

Installation

Direct <script /> include:

Include VueMce after vue and tinymce. VueMce will be registered as a global component.

<script src="link/to/tinymce"></script>
<script src="link/to/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-mce@latest/dist/vue-mce.web.js"></script>

NPM

npm install vue-mce --save

Yarn

yarn add vue-mce

When used with a module system, you must explicitly install VueMce via Vue.use():

import Vue from 'vue';
import VueMce from 'vue-mce';

Vue.use(VueMce);

It is possible to import only component to have possibility register it locally:

import { component } from 'vue-mce';

const MyComponent = {
  components: {
    'vue-mce': component,
  },
};

You don't need to do this when using global script tags.

Live example

Usage

Props

By default VueMce requires no props, you can simply do this:

<whatever>
  <vue-mce />
</whatever>

Name

html name attribute. Useful for non-ajax form submitting

Config

You can pass to VueMce component any valid tinymce config that you want to use:

<template>
  <vue-mce :config="config" />
</template>
new Vue({
  data: () => ({
    config: {
      theme: 'modern',
      fontsize_formats: "8px 10px 12px 14px 16px 18px 20px 22px 24px 26px 39px 34px 38px 42px 48px",
      plugins: 'print preview fullpage powerpaste searchreplace autolink',
      toolbar1: 'formatselect fontsizeselect | bold italic strikethrough forecolor backcolor link',
    },
  }),
});

Make sure that you don't pass to config selector field because it have priority over the target field which VueMce uses to mount component

Value

You can pass the value prop to VueMce component:

<template>
  <vue-mce :value="myValue" />
</template>
new Vue({
  data: () => ({
    myValue: 'Hello World!',
  }),
});

v-model

You can use the v-model directive to create two-way data-binding.

<template>
  <vue-mce v-model="myValue" />
</template>

ref

To set editor content, you can simply set ref to this component and call this.$refs['YOUR_REF'].setContent(yourContent)

<template>
  <vue-mce ref="editor" />
</template>
new Vue({

  methods: {
    getData () {
      API.get()
        .then((res) => {
          this.$refs['YOUR_REF'].setContent(res.content);
        });
    },
  },
  
  created () {
    this.getData();
  },
});

Events

VueMce provides 5 types of events: init, error, input, change, destroy

<template>
  <vue-mce
    @init="handleInit"
    @error="handleError"
    @input="handleInput"
    @change="handleChange"
    @destroy="handleDestroy"
  />
</template>
new Vue({

  methods: {
    handleInit (editor) {
      /* This handler fires when tinymce editor is successfully initialized.
         Receives tinymce editor instance as argument
      
         You can save the editor instance to variable and
         call editor.setContent(yourContent) any time you want */
    },
    
    handleError (err) {
      /* Fires when an error occurred. Receives error object */
    },
    
    handleInput (value) {
      /* Fires whenever editor content changes. Receives generated HTML */
    },
    
    handleChange (value) {
      /* Fires only when editor emits focusout event. Receives generated HTML */
    },
    
    handleDestroy (editor) {
      /* Fires before VueMce component destroys. Receives tinymce editor instance */
    },
  },
});

Questions

If you have any troubles, questions or proposals you can create the issue

License

MIT

Copyright (c) 2017 - present, Eduard Troshin