Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ckEditor events in vue-ckeditor #83

Closed
oskarbet opened this issue Oct 23, 2018 · 5 comments
Closed

Use ckEditor events in vue-ckeditor #83

oskarbet opened this issue Oct 23, 2018 · 5 comments
Assignees

Comments

@oskarbet
Copy link

In js :

`$(document).ready(function() {  
    CKEDITOR.replace('myckeditor'); 
    CKEDITOR.on('dialogDefinition', function(ev) {  
            var dialogName = ev.data.name; 
            if (dialogName == 'image') {
               // custom uploader    
            }
    });  
 }); `

How I can add this event handler to VueCkeditor? In Vue component I have next:

<template>
    <vue-ckeditor v-model="page.body.ru" :config="ckEditorOptions" />
</template>

import VueCkeditor from 'vue-ckeditor2';
    export default {
        components: {
            VueCkeditor
        },
    data() {
            return {
                ckEditorOptions: {
                    toolbar: [
                        ['Bold', 'Image']
                    ],

                    extraPlugins: ['filebrowser', 'image2'],

                    filebrowserImageBrowseUrl: 'javascript:void(0)',
                },

                page: {
                   body: {
                        ru: '',
                        uk: ''
                   },
                },              
            }
        },

And I want to add custom file uploader when dialogName = 'image'

@dangvanthanh dangvanthanh self-assigned this Oct 23, 2018
dangvanthanh added a commit that referenced this issue Oct 24, 2018
@dangvanthanh
Copy link
Owner

dangvanthanh commented Oct 24, 2018

Hi @oskarbet

From v2.1.0 I added dialogDefinition events

<template>
  <div>
    <vue-ckeditor 
      v-model="page.body.ru" 
      :config="ckEditorOptions" 
      @dialogDefinition="onDialogDefinition($event)" />
  </div>
</template>

<script>
import VueCkeditor from 'vue-ckeditor2';

export default {
  components: { VueCkeditor },
  data() {
    return {
      ckEditorOptions: {
        toolbar: [
          ['Bold', 'Image']
        ],
        extraPlugins: ['filebrowser', 'image2'],
        filebrowserImageBrowseUrl: 'javascript:void(0)'
      },
      page: {
        body: {
          ru: '',
          uk: ''
        }
      }
    };
  },
  methods: {
    onDialogDefinition(evt) {
      if (evt.data && evt.data.name) {
        var dialogName = evt.data.name;

        if (dialogName === 'image') {
          // Custom loader
        }
      }
    }
  }
};
</script>

Besides you can use others Ckeditor events such as blur, focus, contentDom, fileUploadRequest, fileUploadResponse. You can see events support in vue-ckeditor2

@oskarbet
Copy link
Author

Don't work. DialogDefinition event didn't fired when I have open dialog window.
For example, if I use @blur="onDialogDefinition($event)" /> all work great. Then console.log(evt) return next: {name: "blur", sender: a, editor: a, data: undefined, listenerData: undefined, …}

@oskarbet
Copy link
Author

oskarbet commented Oct 24, 2018

Can you send example where event dialogDefinition was fired?

@dangvanthanh
Copy link
Owner

dangvanthanh commented Oct 24, 2018

Hi @oskarbet

This is my fault. I registered wrong for dialogDefinition. Please upgrade to v2.1.1 to fix it. You can see example when open devtools and see console log when open dialog in demo with classic. But current it show the first of call dialog. From second open dialog it doesn't show.

It reference from documents of Ckeditor about dialogDefinition

@oskarbet
Copy link
Author

Great! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants