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.

Preview issue with rich-text-widgets in pieces modal

See original GitHub issue

Expected behavior:

  1. Applying styles (bold, italic, custom) to content in a rich-text-widgets editor show in preview

Actual behavior:

  1. No matter what styles are applied, content appears plain text thereby making it hard for users to see what the end result will be (See screenshot below). Note that if I include the rich-text-widgets on a page, then bold and italic and link previews will work but custom styles and bulletedlist don’t.

Pieces screenshot: image

Pages screenshot: image

Relevant code: In the piece definition (/lib/modules/articles/index.js), I have the following field definition:

{ name: 'content', label: 'Content', type: 'singleton', widgetType: 'apostrophe-rich-text', options: { toolbar: [ 'Bold', 'Italic', 'Styles', 'BulletedList', 'Link', 'Unlink' ], styles: [ { name: 'Heading 1', element: 'h1' }, { name: 'Heading 2', element: 'h2' }, { name: 'Heading 3', element: 'h3' }, ] } }

/lib/modules/apostrophe-rich-text-widgets/index.js

module.exports = { // The standard list copied from the module, plus sup and sub sanitizeHtml: { allowedTags: [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div', 'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre', 'sup', 'sub' ], allowedAttributes: { a: [ 'href', 'name', 'target' ], // We don't currently allow img itself by default, but this // would make sense if we did img: [ 'src' ] }, // Lots of these won't come up by default because we don't allow them selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont', 'input', 'link', 'meta' ], // URL schemes we permit allowedSchemes: [ 'http', 'https', 'ftp', 'mailto' ], allowedSchemesByTag: {} } };

/lib/modules/apostrophe-pages/views/pages/articlepage.html

` {% extends “layout.html” %}

{% block main %}

<div class="main-content"> {{ apos.singleton(data.page, 'textBlock', 'apostrophe-rich-text', { toolbar: [ 'Bold', 'Italic', 'Styles', 'BulletedList', 'Link', 'Unlink' ], styles: [ { name: 'Heading 1', element: 'h1' }, { name: 'Heading 2', element: 'h2' }, { name: 'Heading 3', element: 'h3' } ] }) }} </div> {% endblock %} `

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
houmarkcommented, Aug 16, 2018

Alright, I’ll get a PR in soon for at least the most common styles isolated to the dialog modal rich text editor.

0reactions
shauravgcommented, Aug 23, 2018

Hey @houmark sorry for the delay in response. I tried it out and it works!

Quick question however. If I put the rich-text-widget.less file under my project root/lib/modules/apostrophe-rich-text-widgets/public/css/components/ , it has no effect. Is there a appropriate way to introduce custom styles without overriding the file under node_modules?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apostrophe cms - rich text preview not working in admin view
Apostrophe's admin modal CSS is reset, so rich text areas in the modal do not reflect project level styles. This is in an...
Read more >
Areas and widgets | Apostrophe 3 Documentation
A widget is a section of structured content, such as a block of rich text, an image slideshow, or a grid of featured...
Read more >
RichText class - widgets library - Flutter - Dart API docs
The RichText widget displays text that uses multiple different styles. The text to display is described using a tree of TextSpan objects, each...
Read more >
Page edit view incorrectly reporting dirty rich text #4978 - GitHub
Issue Summary When editing a page that contains Draftail rich text (either as a RichTextField or as a RichTextBlock in a StreamField), ...
Read more >
Rich Text Editor Widget (CX & EX) - Qualtrics
About Rich Text Editor Widgets ... The rich text editor widget allows you to display static text in your dashboard. ... Was this...
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