GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.37k stars 4.05k forks source link

Enable the default RTE with a custom function #371

Closed edwardjiawei closed 7 years ago

edwardjiawei commented 7 years ago

Do my API call correctly, want to add a RTE with custom function to add a link/open new windows/open modal:

Command work for fontSize but the dropdown are not aligned and show the option value Command not work for insertHTML. Function not working (Intended/Not a Features)

grapes

http://grapesjs.com/demo.html

  editor.RichTextEditor.add('fontSize', {
    command: 'fontSize',
    options: [
      {name: 'Huge', value: '7'},
      {name: 'Normal', value: '5'},
      {value: '1'}
    ]
  });  

I think even command not working to add specific hardcoded HTML

    editor.RichTextEditor.add('insertHTML', {
    command: 'insertHTML',
    class: 'fa fa-link',
    title: 'test',
    args: '<a class="link" href="">${content}</a>',
  });  
 editor.Commands.add('tlb', {
    run:  function(editor, sender){
      editor.getSelected().view.enableEditing();
      //sethref for link etc
      alert('Hello world!');
    },
    stop:  function(editor, sender){
    },
  });
    editor.RichTextEditor.add('tlb', {
    command: 'tlb',
    class: 'fa fa-link',
    title: 'test'

  });  
artf commented 7 years ago

Hi @edwardjiawei, it doesn't work because the command: 'tlb' in RichTextEditor.add it's not GrapesJS's Command but the one from execCommand's API (eg. 'fontSize', 'insertHTML', etc.) so currently, you can't attach custom behaviors to RTE. I close it because I don't plan to support the current RTE anymore, instead, I'll replace it with another one which will support also custom actions (added to Roadmap)

edwardjiawei commented 7 years ago

Hopefully support some RTE with more permissive license like MIT or BSD. I guess some companies might even don't choose BSD. CKEditor integration are quite easy, but the license might not be good for some companies.

Thanks anyway.

artf commented 7 years ago

CKEditor is too much big for being the built-in solution (but you can find it as a plugin if you want to use it) I'll probably go with https://github.com/jaredreich/pell this is all its code https://github.com/jaredreich/pell/blob/master/src/pell.js and this is all I need

edwardjiawei commented 7 years ago

That really lightweight and permissive license.

You know as nowadays the open source world, most people like me always rely on RTE plugins like insertHTML, Emoji, Unicode, PlaceHolder/Token (Server Side Templateing) that will useful for hobby project and work. All that use case are mostly align with grapes.js use case, as most personal and professional project will evaluate how easy to integrate with RTE.

lock[bot] commented 5 years ago

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.