Skip to main content

Content Applications

Abstract#

While Content Builder, Content Extractor and Content Modifier APIs are very flexible, yet they also too generic.

The content-application is a collection of more specific APIs which aim to reduce boilerplate for consumer.

getText#

Extracts textual content of Headers & Paragraphs from a given content

Example#

This is an example content, with header 3

and header 4

import { getText } from 'ricos-content/libs/content-application';
const text = getText(content); // input content
console.log(text);
Output#

["This is an example content, with header 3 ", "and header 4"]


getPluginData#

Extracts data of a plugin from a given content.

Example#

import { getPluginData } from 'ricos-content/libs/content-application';
import { content } from 'somewhere';
const pluginData = getPluginData(content, 'IMAGE');
console.log(pluginData);
Output#
[
{
image: { ... },
altText: 'alt1',
caption: 'Cool image',
// ...
},
{
image: { ... },
altText: 'alt2',
caption: 'Cool image 2',
// ...
},
];

getMedia#

Extracts all media data from a given content

Example#

For this given content:

This is a content example with video & image



import { getMedia } from 'ricos-content/libs/content-application';
const media = getMedia(content); //content = given input example
console.log(pluginData);
Output#
[
{
src: {
url: 'https://youtu.be/oCBpJkG6ngE',
},
},
{
src: {
id: '8bb438_4af301c080294224b6b5e15cd38a035f.jpg'
}
width: 1920,
height: 1280
}
];