Rich editor configuration per field
See original GitHub issueThere is some things that could be added to rich text:
- add support for different configurations
- needs a way to unregister some plugins globally (there is only hooks for enabling a hallojs plugin)
- make default whitelister configurable, for example disable “a” tag globally.
Example of rich text editor configuration for a field
# Simple TextArea, where we nee just a few options on editor
class SimpleDbWhitelister(WagtailDbWhitelister):
element_rules = {
'[document]': allow_without_attributes,
'a': attribute_rule({'href': check_url}),
'p': allow_without_attributes,
'b': allow_without_attributes,
'i': allow_without_attributes,
'u': allow_without_attributes,
}
class SimpleRichTexArea(WagtailRichTextArea):
hallo_plugins = {
'halloheadings': {
'formatBlocks': []
},
'halloformat': {
'formattings': {
"bold": True,
"italic": True,
},
},
'hallolists': {
"lists": {
"ordered": False,
"unordered": False
}
},
'hallowagtaillink': {},
'hallorequireparagraphs': {},
'hallocleanhtml': {
'format': False,
'removeTags': ['span', 'div', 'table', 'strong'],
'allowedTags': ['a', 'p', 'i', 'b', 'u'],
'removeAttrs': ['class', 'style', 'id'],
'allowedAttributes': [
["a", ['href', 'target', 'data-id', 'data-linktype']]
]
}
}
def render_js_init(self, id_, name, value):
return "makeRichTextEditable({0}, {1});".format(
json.dumps(id_),
json.dumps(self.hallo_plugins)
)
def value_from_datadict(self, data, files, name):
original_value = super(SimpleRichTexArea, self).value_from_datadict(data, files, name)
if original_value is None:
return None
return SimpleDbWhitelister.clean(original_value)
Some changes on page-editor.js
function makeRichTextEditable(id, plugins) {
var instanceHalloPlugins = plugins || halloPlugins;
....
}
Globally disable a hallo plugin on editor
function unRegisterHalloPlugin(name) {
if (!$.inArray(name, disabledHalloPlugins)) {
disabledHalloPlugins.push(name);
}
if ($.inArray(name, halloPlugins)) {
delete halloPlugins[name];
}
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Configuring the Rich Text Editor - HubSpot Developers
The Rich Text Editor inside of custom modules now provides the ability for developers to remove components from the configuration toolbar.
Read more >Rich text editor configuration - Xperience 13 Documentation
Assign editor configurations to rich text fields For fields that use the Rich text editor form component, you can set custom configurations via ......
Read more >Configure the Rich Text Editor | Adobe Experience Manager
The Rich Text Editor (RTE) provides authors with a wide range of functionality for editing their text content. Icons, selection boxes, toolbar, ...
Read more >Rich Text Editor Document: Configuration Reference
Name Default Description
toolbarMobile mobile The toolbar set on mobile devices.
timeoutAddToUndo 900 When uses types fast, wait 900ms to add undo item.
insertRowTag Default row...
Read more >Configure Rich Text Editor settings - ThoughtFarmer Helpdesk
You can reorder the tools as desired. Add "/" to start a new row in the toolbar. Remember to surround the entire config...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Now implemented in #3736.
(To correct myself above: #2697 only addresses this in a very basic way - you’d need to set up a configuration in
WAGTAILADMIN_RICH_TEXT_EDITORS
for each combination of features - and only for editors that recognise configuration options passed there, which hallo.js didn’t until I implemented that in #3736)I believe #2697 (now in master) should address this. Haven’t had chance to try it out myself, and it still needs docs, but if anyone’s up for trying it out and reporting back, that would be much appreciated!