Issue #371Opened October 4, 2017by edwardjiawei0 reactions

Enable the default RTE with a custom function

Question

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'
 
  });  

Answers (3)

artfOctober 4, 20170 reactions

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)

edwardjiaweiOctober 4, 20170 reactions

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.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.