grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Modify grapes.min.js to allow video types on AssetManager

Open ivanezeigbo opened this issue 8 years ago • 6 comments

Please, I would like to modify my grapes.min.js because I would like to add the video type to my assetManager. For some reason, the am.addType() messes up my page and does not work as well. I am not sure why, but I am curious about where to make the changes on my grapes.min.js to include video types. Please help.

ivanezeigbo avatar Jun 13 '18 10:06 ivanezeigbo

I think it will be much easier to understand what is wrong with am.addType. Please provide a live demo of your case.

ps. As you've created an issue I removed your comment in #802 because the content is the same but left like this it was just creating confusion

artf avatar Jun 13 '18 22:06 artf

@artf Never mind. I found out I was just mixing up the versions used. Thank you! I actually used another way around. I added activeOnRender:1 to video and removed the default src in the blocks-basic.js. This allowed me to choose my own src by just including the link to the video. However, I am unable to reopen the AssetsManager on dblclick. Please do you know how I can also make that possible for videos?

ivanezeigbo avatar Jun 17 '18 17:06 ivanezeigbo

This is how I was able to trigger the asset manager on dbl click. See the events property below.

export default (editor, config = {}) => {
  const comps = editor.DomComponents;
  
  //const defaultType = domc.getType('default');
  var defaultType = comps.getType('video');
  const defaultModel = defaultType.model;
  const defaultView = defaultType.view;
  // ...

  
  comps.addType('video', {
      view: defaultType.view.extend({
      init(){
        // The 'active' is triggered by the 'activeOnRender' you've used inside your block
       this.listenTo(this.model, 'active', this.doStuff);
     },
      events: {
        dblclick: function(){
          console.log('dbl click');
          this.doStuff();
        }
      },
      doStuff(){
          this.opts.config.em.get('Editor').runCommand('open-assets', { target: this.model, types:['video'], accept: 'video/*'})
      }
    }),
  });
}

WkRPcoN avatar Jun 18 '18 00:06 WkRPcoN

Thanks!

ivanezeigbo avatar Jun 18 '18 09:06 ivanezeigbo

@artf ,i am new to grapesjs problem in allowing of video id/link/src on the video component and can easily drop the video component over canvas ..

ShubhamProgrammer avatar Aug 09 '18 07:08 ShubhamProgrammer

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Sep 17 '19 08:09 lock[bot]