You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@contentful/rich-text-plain-text-renderer

Package Overview
Dependencies
Maintainers
41
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contentful/rich-text-plain-text-renderer - npm Package Compare versions

Comparing version

to
10.0.0

12

dist/lib/__test__/index.test.js

@@ -9,3 +9,2 @@ "use strict";

nodeType: 'document',
nodeClass: 'block',
data: {},

@@ -19,3 +18,2 @@ content: [],

nodeType: 'document',
nodeClass: 'block',
data: {},

@@ -25,3 +23,2 @@ content: [

nodeType: rich_text_types_1.BLOCKS.PARAGRAPH,
nodeClass: 'block',
data: {},

@@ -56,3 +53,2 @@ content: [

nodeType: 'document',
nodeClass: 'block',
data: {},

@@ -62,3 +58,2 @@ content: [

nodeType: 'paragraph',
nodeClass: 'block',
data: {},

@@ -92,3 +87,2 @@ content: [

nodeType: 'hyperlink',
nodeClass: 'inline',
content: [

@@ -111,3 +105,2 @@ {

nodeType: 'unordered-list',
nodeClass: 'block',
data: {},

@@ -117,3 +110,2 @@ content: [

nodeType: 'list-item',
nodeClass: 'block',
data: {},

@@ -123,3 +115,2 @@ content: [

nodeType: 'paragraph',
nodeClass: 'block',
data: {},

@@ -135,3 +126,2 @@ content: [

nodeType: 'hyperlink',
nodeClass: 'inline',
content: [

@@ -156,3 +146,2 @@ {

nodeType: 'list-item',
nodeClass: 'block',
data: {},

@@ -162,3 +151,2 @@ content: [

nodeType: 'paragraph',
nodeClass: 'block',
data: {},

@@ -165,0 +153,0 @@ content: [

6

dist/lib/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rich_text_types_1 = require("@contentful/rich-text-types");
/**

@@ -74,3 +75,3 @@ * Returns the text value of a rich text document.

var nextNode = childNodeList[i + 1];
var nodeIsInBlockSequence = nextNode && !isText(nextNode) && nextNode.nodeClass === 'block';
var nodeIsInBlockSequence = nextNode && !isText(nextNode) && isBlock(nextNode);
var divisor = nodeIsInBlockSequence ? blockDivisor : '';

@@ -82,2 +83,5 @@ return textValue + nodeTextValue + divisor;

exports.documentToPlainTextString = documentToPlainTextString;
function isBlock(node) {
return Object.values(rich_text_types_1.BLOCKS).includes(node.nodeType);
}
function isText(node) {

@@ -84,0 +88,0 @@ return node.nodeType === 'text';

@@ -5,3 +5,107 @@ 'use strict';

function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x.default : x;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var richTextTypes_es5 = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, '__esModule', { value: true });
/**
* Map of all Contentful block types. Blocks contain inline or block nodes.
*/
var BLOCKS = {
DOCUMENT: 'document',
PARAGRAPH: 'paragraph',
HEADING_1: 'heading-1',
HEADING_2: 'heading-2',
HEADING_3: 'heading-3',
HEADING_4: 'heading-4',
HEADING_5: 'heading-5',
HEADING_6: 'heading-6',
OL_LIST: 'ordered-list',
UL_LIST: 'unordered-list',
LIST_ITEM: 'list-item',
HR: 'hr',
QUOTE: 'blockquote',
EMBEDDED_ENTRY: 'embedded-entry-block',
EMBEDDED_ASSET: 'embedded-asset-block',
};
/**
* Map of all Contentful inline types. Inline contain inline or text nodes.
*/
var inlines = {
HYPERLINK: 'hyperlink',
ENTRY_HYPERLINK: 'entry-hyperlink',
ASSET_HYPERLINK: 'asset-hyperlink',
EMBEDDED_ENTRY: 'embedded-entry-inline',
};
/**
* Map of all Contentful marks.
*/
var marks = {
BOLD: 'bold',
ITALIC: 'italic',
UNDERLINE: 'underline',
CODE: 'code',
};
var _a;
/**
* Array of all top level block types.
* Only these block types can be the direct children of the document.
*/
var TOP_LEVEL_BLOCKS = [
BLOCKS.PARAGRAPH,
BLOCKS.HEADING_1,
BLOCKS.HEADING_2,
BLOCKS.HEADING_3,
BLOCKS.HEADING_4,
BLOCKS.HEADING_5,
BLOCKS.HEADING_6,
BLOCKS.OL_LIST,
BLOCKS.UL_LIST,
BLOCKS.HR,
BLOCKS.QUOTE,
BLOCKS.EMBEDDED_ENTRY,
BLOCKS.EMBEDDED_ASSET,
];
/**
* Array of all void block types
*/
var VOID_BLOCKS = [BLOCKS.HR, BLOCKS.EMBEDDED_ENTRY, BLOCKS.EMBEDDED_ASSET];
/**
* Dictionary of all container block types, and the set block types they accept as children.
*/
var CONTAINERS = (_a = {},
_a[BLOCKS.OL_LIST] = [BLOCKS.LIST_ITEM],
_a[BLOCKS.UL_LIST] = [BLOCKS.LIST_ITEM],
_a[BLOCKS.LIST_ITEM] = TOP_LEVEL_BLOCKS.slice(),
_a[BLOCKS.QUOTE] = [BLOCKS.PARAGRAPH],
_a);
exports.BLOCKS = BLOCKS;
exports.INLINES = inlines;
exports.MARKS = marks;
exports.TOP_LEVEL_BLOCKS = TOP_LEVEL_BLOCKS;
exports.VOID_BLOCKS = VOID_BLOCKS;
exports.CONTAINERS = CONTAINERS;
});
unwrapExports(richTextTypes_es5);
var richTextTypes_es5_1 = richTextTypes_es5.BLOCKS;
var richTextTypes_es5_2 = richTextTypes_es5.INLINES;
var richTextTypes_es5_3 = richTextTypes_es5.MARKS;
var richTextTypes_es5_4 = richTextTypes_es5.TOP_LEVEL_BLOCKS;
var richTextTypes_es5_5 = richTextTypes_es5.VOID_BLOCKS;
var richTextTypes_es5_6 = richTextTypes_es5.CONTAINERS;
/**
* Returns the text value of a rich text document.

@@ -77,3 +181,3 @@ *

var nextNode = childNodeList[i + 1];
var nodeIsInBlockSequence = nextNode && !isText(nextNode) && nextNode.nodeClass === 'block';
var nodeIsInBlockSequence = nextNode && !isText(nextNode) && isBlock(nextNode);
var divisor = nodeIsInBlockSequence ? blockDivisor : '';

@@ -84,2 +188,5 @@ return textValue + nodeTextValue + divisor;

}
function isBlock(node) {
return Object.values(richTextTypes_es5_1).includes(node.nodeType);
}
function isText(node) {

@@ -86,0 +193,0 @@ return node.nodeType === 'text';

{
"name": "@contentful/rich-text-plain-text-renderer",
"version": "9.0.2",
"version": "10.0.0",
"main": "dist/rich-text-plain-text-renderer.es5.js",

@@ -26,3 +26,3 @@ "typings": "dist/types/rich-text-plain-text-renderer.d.ts",

"dependencies": {
"@contentful/rich-text-types": "^9.0.2"
"@contentful/rich-text-types": "^10.0.0"
},

@@ -41,3 +41,3 @@ "devDependencies": {

},
"gitHead": "e2b8b5509083bba1ea1e6839fd382c84019a76dc"
"gitHead": "4531fd40a4e459fda941272917d3e42bdacd9f00"
}

@@ -25,10 +25,7 @@ # rich-text-plain-text-renderer

nodeType: 'document',
nodeClass: 'document',
content: [
{
nodeClass: 'block',
nodeType: 'paragraph',
content: [
{
nodeClass: 'text',
nodeType: 'text',

@@ -39,3 +36,2 @@ value: 'Hello',

{
nodeClass: 'text',
nodeType: 'text',

@@ -42,0 +38,0 @@ value: ' world!',

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet