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)
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)
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)
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.
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
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1088
add new custom default class for map
can you please let me know how to add custom class in parent div of map iframe. when I try to add custom class in move function of 'grapesj...
Issue #1622
Default selected font issue for custom font in the Typography.
There is one font issue when i click on any element it not show the current font of the element, i added custom code for add my custom font...
Issue #1669
[Question] Custom link modal doesn't update the current text but add another text with link
Hello Artur, I'm trying to have a custom modal when clicked link button in RTE. but it doesn't convert selected text to link but what it do...
Issue #1834
[BUG]: background image for wrapper doesn't work if custom styling properties are selected
When editor is initialized with custom styling props defined for wrapper, background image is not set to wrapper. It is set correctly if ed...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.