RichContentViewer - AngeliqueMarachev/tech_writing GitHub Wiki

RichContentViewer

The Rich Content Viewer is an element that displays rich content created using the Rich Content Editor in the CMS (Content Management System).

Introduction

The Rich Content Viewer provides access to a rich content field in a collection, managed in the Rich Content Editor.

Rich content can include various media types, such as text, images, videos, and other content embeds. and should not be confused with the Rich Text Box which is limited to text formatting.

Wix Blog demonstrates the implementation of rich content.

content

Sets or gets the element's content.

Description

The content property is an object used to set and get the content of the Rich Content Viewer element.

The object can be referenced in 2 ways:

  • In a rich content field of a collection.
  • In other Wix apps that utilize rich content, such as Wix Blog. Assigning null to this property resets the content to undefined.
Type: Object | null
      READ & WRITE

Get rich content from a field and set it to a variable

import wixData from 'wix-data';

$w.onReady(function () {
  wixData.query('MyCollection').find().then(results => {
      const data = results.items[0].richcontent;
      $w('#richContentViewer').content = data;
  });
});

Reset the Rich Content Viewer's content to undefined

$w("#myRichContentViewerElement").content = null;