question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: add more built-in rich text formats

See original GitHub issue

This is a feature request question. When browse the draftail examples page, I could see many formats not included in wagtail 2.1 version (under “All built-in formats” section).

Code: Code
Underline: Underline
Strikethrough: Strikethrough
Mark: Mark
Quotation: Quotation
Small: Small
Sample: Sample
Insert: Insert
Delete: Delete
Keyboard: Keyboard
Superscript: Superscript
Subscript: Subscript
Blockquote

Is there a plan to integrate latest version for draftail into wagtail?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
gasmancommented, Jun 19, 2018

👍 for adding all the above to Wagtail but disabled by default. (We don’t want to encourage use of underline because that style should be reserved for links, and superscript/subscript are probably also ‘niche’ enough that it makes sense for them to be opt-in.)

2reactions
thibaudcolascommented, Jun 19, 2018

Actually, looking at the code again I forgot that the “built-in Draftail formats” go beyond styles. They also come with pre-defined labels and descriptions in english, and some also have keyboard shortcuts.

Here are the ones that come with keyboard shortcuts:

https://github.com/springload/draftail/blob/1a582d2c1e9a803e31b99453500e3b5c6c9f0bf0/lib/api/constants.js#L237-L271

KEYBOARD_SHORTCUTS[BLOCK_TYPE.UNSTYLED] = '⌫';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_ONE] = '#';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_TWO] = '##';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_THREE] = '###';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_FOUR] = '####';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_FIVE] = '#####';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_SIX] = '######';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.UNORDERED_LIST_ITEM] = '-';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.ORDERED_LIST_ITEM] = '1.';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.BLOCKQUOTE] = '>';
KEYBOARD_SHORTCUTS[BLOCK_TYPE.CODE] = '```';


KEYBOARD_SHORTCUTS[INLINE_STYLE.BOLD] = { other: 'Ctrl + B', macOS: '⌘ + B' };
KEYBOARD_SHORTCUTS[INLINE_STYLE.ITALIC] = { other: 'Ctrl + I', macOS: '⌘ + I' };
KEYBOARD_SHORTCUTS[INLINE_STYLE.UNDERLINE] = {
    other: 'Ctrl + U',
    macOS: '⌘ + U',
};
KEYBOARD_SHORTCUTS[INLINE_STYLE.STRIKETHROUGH] = {
    other: 'Ctrl + ⇧ + X',
    macOS: '⌘ + ⇧ + X',
};
KEYBOARD_SHORTCUTS[INLINE_STYLE.SUPERSCRIPT] = {
    other: 'Ctrl + .',
    macOS: '⌘ + .',
};
KEYBOARD_SHORTCUTS[INLINE_STYLE.SUBSCRIPT] = {
    other: 'Ctrl + ,',
    macOS: '⌘ + ,',
};


KEYBOARD_SHORTCUTS[ENTITY_TYPE.LINK] = { other: 'Ctrl + K', macOS: '⌘ + K' };


KEYBOARD_SHORTCUTS[BR_TYPE] = '⇧ + ↵';
KEYBOARD_SHORTCUTS[ENTITY_TYPE.HORIZONTAL_RULE] = '- - -';

This is not customisable in any way, you have to use the exact identifier (e.g. SUBSCRIPT string, uppercase, or code-block string, lowercase) to get this, so I think it’s a good argument to have those built-in – so people using these benefit from the keyboard shortcut, and there is less risk of defining a feature that does what these do without using the ““right”” identifier.

– and if anyone wonders why these get special treatment, it’s because they are available in traditional word processors (Word, Google Docs) or in Markdown and use those shortcuts there.


Here is the full list of what I think should be supported, with the feature name first then the Draft.js type, then the HTML tag.

Inline styles

  • code, CODE, <code>
  • superscript, SUPERSCRIPT, <sup>
  • subscript, SUBSCRIPT, <sub>
  • strikethrough, STRIKETHROUGH, <s>
  • underline, UNDERLINE, <u>

Blocks

  • blockquote, blockquote, <blockquote>
  • code-block, code-block, <pre> or <pre><code>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Extend rich text editor component - Feature Requests
It would be great to have the ability to extend the rich text editor to include additional formatting options.
Read more >
More Rich Text Formatting Options? - Prismic People
The team is aware of the requests for more built-in rich text formatting options and plan to integrate them once we overhaul the...
Read more >
Adding Rich Text - Yext Hitchhikers
Add the rich text formatter to the field that uses rich text. Either disable truncation or update the card to handle RTF truncation,...
Read more >
add Rich Text / HTML content & images to a guide - Help Center
Learn more about the different features of the rich text editor below. Styles; Paragraph formats; Fonts; Text colors; Bold, italic, and strikethrough formatting...
Read more >
Feature request: Rich text formatting and inline images in the ...
We are transitioning to the web form, away from email for ticket creation purposes. Both internal and external stakeholders miss the ability ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found