@contentful/rich-text-plain-text-renderer
Advanced tools
Comparing version 9.0.2 to 10.0.0
@@ -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: [ |
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31798
451
47
1
+ Added@contentful/rich-text-types@10.3.0(transitive)
- Removed@contentful/rich-text-types@9.0.2(transitive)