Coder Social home page Coder Social logo

vue-mce's Introduction

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.

Logo

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

vue-mce's People

Contributors

eazymov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-mce's Issues

TinyMce was not found

index.jx

import Vue from 'vue'
import Axios from 'axios'
import vClickOutside from 'v-click-outside'
import Toast from "vue-toastification";
import VueMce from 'vue-mce';



// Import the CSS or use your own!
import "vue-toastification/dist/index.css";
import 'floating-vue/dist/style.css'

import Inputmask from 'inputmask'
const VueInputMask = {
  install: function(Vue, options) {
      Vue.directive('mask', {
          bind: function(el, binding) {
              Inputmask(binding.value).mask(el);
          }
      });
  }
}

Vue.use(vClickOutside)
Vue.use(VueInputMask)
Vue.use(Toast)
Vue.component('mce', VueMce );

Vue.prototype.$http = Axios;

component

 <vue-mce  v-model="form.description" />
...
import { component } from 'vue-mce';
...
 components: {
...
        'vue-mce': component,
    },



inline: true

If i add

const config = {
inline: true,

The inline doesn't render.

how to

how to attach files by uploading from local pc ?

Vue beginner not sure how to setup the component

How I would like to use it:

import VueMce from 'vue-mce';
Vue.component('mce', VueMce );

and then just use it like:

<vue-mce :config="config" v-model="myValue" />

But I am not sure here if I can do that.
If not I guess I have make a "mce.vue" component but I am not sure how to do that.

Add custom formats

How can I add custom format option to vue-mce?
In TinyMCE I can add custom format in config for example like this
style_formats: [ { title: 'Custom', inline: 'span', styles: { display: 'inline-block', border: '1px solid #2276d2', 'border- radius': '5px', padding: '2px 5px', margin: '0 2px', color: '#2276d2' } } ]
How can I do this in vue-mce? It says that i can pass any TinyMCE config, but this isn't working.

dependencies are now locked to specific versions

during the 1.5.1 release of vue-mce it appears that all the dependencies got locked to specific patch versions. checking your packages.json file it appears that instead of "vue": "^2.5.3" is now "vue": "2.5.3" this means that even though we are using vue 2.5.21 we still get the warning: npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
when running npm install vue-mce

This seems to be the case with all the dependencies in package.json

TinyMce

your plugin say's TinyMce is not defined

image

I've imported all to need tinymce

import VueMce from 'vue-mce';
Vue.use(VueMce);

in app.vue
<vue-mce :config="tinyVueMceConf"/>

tinyVueMceConf: {
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',
}

Component not rendering

Hello!

I can see that the component is loaded and have recieved my config, using the vue devtools for Chrome.
But for some reason it just doesn't render.

import Vue from 'vue';
import VueMce from 'vue-mce';
 
Vue.use(VueMce);

<vue-mce name="content" :initial-value="card.content" :config="mceconfig" v-model="card.content" />

I'm using TypeScript and Webpack... And I'm really new to both of them, maybe there is some kind of standard configuration I have to do?

Unexpected token: punc (() from UglifyJs

Hello,
When I try to build my app with NPM RUN BUILD command, the response from terminal is:
ERROR in static/js/vendor.fd125947db1218b759b7.js from UglifyJs Unexpected token: punc (() [./node_modules/vue-mce/dist/vue-mce.common.js:1,823][static/js/vendor.fd125947db1218b759b7.js:62883,800]

If I run it with NPM RUN DEV, it works perfectly. I have try to create a new project with VUE CLI, so I use the last version of webpack, vue, etc. , but I get this error when I try to build my project.

Can u help me ?
Giovanni

remove() and init()

I am adding tinymce to the DOM dynamically.
How can I remove all initiated tinymce and re init again every time I add new tinymce?

handleInit (editor) {
editor.remove(); // this works
editor.init(); // this doesn't work
}

/js/themes/modern/theme.js not found

import VueMce from 'vue-mce';
Vue.use(VueMce);

And I am using in my html like:

<vue-mce :config="mceConfig" v-model="content"/>

But I get an error that theme.js could not be found...

How to add button toolbar

Hello Admin!
sorry.... I can not speak English very well...

how to add custom buttons? like image upload, ...,

Multiple instances

Hi, is possible manage multiple instances in same component?

Thank you.

Error: TinyMce was not found

Hi Dear,
I add the component to my site like this:

import Editor from '@tinymce/tinymce-vue'
Vue.use(Editor);

import VueMce from 'vue-mce';
Vue.use(VueMce);

but I get this error:
Error: TinyMce was not found
please help me.

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.