@contentful/rich-text-types
Advanced tools
Comparing version 10.0.1 to 10.1.0
@@ -7,6 +7,7 @@ "use strict"; | ||
var faker_1 = __importDefault(require("faker")); | ||
var __1 = require(".."); | ||
describe('Document', function () { | ||
it('empty Document', function () { | ||
var document = { | ||
nodeType: 'document', | ||
nodeType: __1.BLOCKS.DOCUMENT, | ||
data: {}, | ||
@@ -18,3 +19,3 @@ content: [], | ||
var document = { | ||
nodeType: 'document', | ||
nodeType: __1.BLOCKS.DOCUMENT, | ||
data: {}, | ||
@@ -34,3 +35,3 @@ content: [ | ||
var block = { | ||
nodeType: 'paragraph', | ||
nodeType: __1.BLOCKS.PARAGRAPH, | ||
data: {}, | ||
@@ -42,3 +43,3 @@ content: [], | ||
var block = { | ||
nodeType: 'paragraph', | ||
nodeType: __1.BLOCKS.PARAGRAPH, | ||
data: {}, | ||
@@ -56,3 +57,3 @@ content: [ | ||
var block = { | ||
nodeType: 'paragraph', | ||
nodeType: __1.BLOCKS.PARAGRAPH, | ||
data: {}, | ||
@@ -73,3 +74,3 @@ content: [ | ||
var inline = { | ||
nodeType: 'hyperlink', | ||
nodeType: __1.INLINES.HYPERLINK, | ||
data: {}, | ||
@@ -81,3 +82,3 @@ content: [], | ||
var inline = { | ||
nodeType: 'hyperlink', | ||
nodeType: __1.INLINES.HYPERLINK, | ||
data: {}, | ||
@@ -84,0 +85,0 @@ content: [ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Map of all Contentful block types. Blocks contain inline or block nodes. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
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', | ||
}; | ||
var BLOCKS; | ||
(function (BLOCKS) { | ||
BLOCKS["DOCUMENT"] = "document"; | ||
BLOCKS["PARAGRAPH"] = "paragraph"; | ||
BLOCKS["HEADING_1"] = "heading-1"; | ||
BLOCKS["HEADING_2"] = "heading-2"; | ||
BLOCKS["HEADING_3"] = "heading-3"; | ||
BLOCKS["HEADING_4"] = "heading-4"; | ||
BLOCKS["HEADING_5"] = "heading-5"; | ||
BLOCKS["HEADING_6"] = "heading-6"; | ||
BLOCKS["OL_LIST"] = "ordered-list"; | ||
BLOCKS["UL_LIST"] = "unordered-list"; | ||
BLOCKS["LIST_ITEM"] = "list-item"; | ||
BLOCKS["HR"] = "hr"; | ||
BLOCKS["QUOTE"] = "blockquote"; | ||
BLOCKS["EMBEDDED_ENTRY"] = "embedded-entry-block"; | ||
BLOCKS["EMBEDDED_ASSET"] = "embedded-asset-block"; | ||
})(BLOCKS || (BLOCKS = {})); | ||
exports.default = BLOCKS; | ||
//# sourceMappingURL=blocks.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Map of all Contentful inline types. Inline contain inline or text nodes. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
HYPERLINK: 'hyperlink', | ||
ENTRY_HYPERLINK: 'entry-hyperlink', | ||
ASSET_HYPERLINK: 'asset-hyperlink', | ||
EMBEDDED_ENTRY: 'embedded-entry-inline', | ||
}; | ||
var INLINES; | ||
(function (INLINES) { | ||
INLINES["HYPERLINK"] = "hyperlink"; | ||
INLINES["ENTRY_HYPERLINK"] = "entry-hyperlink"; | ||
INLINES["ASSET_HYPERLINK"] = "asset-hyperlink"; | ||
INLINES["EMBEDDED_ENTRY"] = "embedded-entry-inline"; | ||
})(INLINES || (INLINES = {})); | ||
exports.default = INLINES; | ||
//# sourceMappingURL=inlines.js.map |
@@ -8,19 +8,21 @@ 'use strict'; | ||
*/ | ||
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', | ||
}; | ||
var BLOCKS; | ||
(function (BLOCKS) { | ||
BLOCKS["DOCUMENT"] = "document"; | ||
BLOCKS["PARAGRAPH"] = "paragraph"; | ||
BLOCKS["HEADING_1"] = "heading-1"; | ||
BLOCKS["HEADING_2"] = "heading-2"; | ||
BLOCKS["HEADING_3"] = "heading-3"; | ||
BLOCKS["HEADING_4"] = "heading-4"; | ||
BLOCKS["HEADING_5"] = "heading-5"; | ||
BLOCKS["HEADING_6"] = "heading-6"; | ||
BLOCKS["OL_LIST"] = "ordered-list"; | ||
BLOCKS["UL_LIST"] = "unordered-list"; | ||
BLOCKS["LIST_ITEM"] = "list-item"; | ||
BLOCKS["HR"] = "hr"; | ||
BLOCKS["QUOTE"] = "blockquote"; | ||
BLOCKS["EMBEDDED_ENTRY"] = "embedded-entry-block"; | ||
BLOCKS["EMBEDDED_ASSET"] = "embedded-asset-block"; | ||
})(BLOCKS || (BLOCKS = {})); | ||
var BLOCKS$1 = BLOCKS; | ||
@@ -30,8 +32,10 @@ /** | ||
*/ | ||
var INLINES = { | ||
HYPERLINK: 'hyperlink', | ||
ENTRY_HYPERLINK: 'entry-hyperlink', | ||
ASSET_HYPERLINK: 'asset-hyperlink', | ||
EMBEDDED_ENTRY: 'embedded-entry-inline', | ||
}; | ||
var INLINES; | ||
(function (INLINES) { | ||
INLINES["HYPERLINK"] = "hyperlink"; | ||
INLINES["ENTRY_HYPERLINK"] = "entry-hyperlink"; | ||
INLINES["ASSET_HYPERLINK"] = "asset-hyperlink"; | ||
INLINES["EMBEDDED_ENTRY"] = "embedded-entry-inline"; | ||
})(INLINES || (INLINES = {})); | ||
var INLINES$1 = INLINES; | ||
@@ -54,15 +58,15 @@ /** | ||
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, | ||
BLOCKS$1.PARAGRAPH, | ||
BLOCKS$1.HEADING_1, | ||
BLOCKS$1.HEADING_2, | ||
BLOCKS$1.HEADING_3, | ||
BLOCKS$1.HEADING_4, | ||
BLOCKS$1.HEADING_5, | ||
BLOCKS$1.HEADING_6, | ||
BLOCKS$1.OL_LIST, | ||
BLOCKS$1.UL_LIST, | ||
BLOCKS$1.HR, | ||
BLOCKS$1.QUOTE, | ||
BLOCKS$1.EMBEDDED_ENTRY, | ||
BLOCKS$1.EMBEDDED_ASSET, | ||
]; | ||
@@ -72,3 +76,3 @@ /** | ||
*/ | ||
var VOID_BLOCKS = [BLOCKS.HR, BLOCKS.EMBEDDED_ENTRY, BLOCKS.EMBEDDED_ASSET]; | ||
var VOID_BLOCKS = [BLOCKS$1.HR, BLOCKS$1.EMBEDDED_ENTRY, BLOCKS$1.EMBEDDED_ASSET]; | ||
/** | ||
@@ -78,6 +82,6 @@ * 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[BLOCKS$1.OL_LIST] = [BLOCKS$1.LIST_ITEM], | ||
_a[BLOCKS$1.UL_LIST] = [BLOCKS$1.LIST_ITEM], | ||
_a[BLOCKS$1.LIST_ITEM] = TOP_LEVEL_BLOCKS.slice(), | ||
_a[BLOCKS$1.QUOTE] = [BLOCKS$1.PARAGRAPH], | ||
_a); | ||
@@ -89,3 +93,3 @@ | ||
function isInline(node) { | ||
return Object.values(INLINES).includes(node.nodeType); | ||
return Object.values(INLINES$1).includes(node.nodeType); | ||
} | ||
@@ -96,3 +100,3 @@ /** | ||
function isBlock(node) { | ||
return Object.values(BLOCKS).includes(node.nodeType); | ||
return Object.values(BLOCKS$1).includes(node.nodeType); | ||
} | ||
@@ -113,4 +117,4 @@ /** | ||
exports.helpers = helpers; | ||
exports.BLOCKS = BLOCKS; | ||
exports.INLINES = INLINES; | ||
exports.BLOCKS = BLOCKS$1; | ||
exports.INLINES = INLINES$1; | ||
exports.MARKS = marks; | ||
@@ -117,0 +121,0 @@ exports.TOP_LEVEL_BLOCKS = TOP_LEVEL_BLOCKS; |
/** | ||
* Map of all Contentful block types. Blocks contain inline or block nodes. | ||
*/ | ||
declare const _default: { | ||
DOCUMENT: string; | ||
PARAGRAPH: string; | ||
HEADING_1: string; | ||
HEADING_2: string; | ||
HEADING_3: string; | ||
HEADING_4: string; | ||
HEADING_5: string; | ||
HEADING_6: string; | ||
OL_LIST: string; | ||
UL_LIST: string; | ||
LIST_ITEM: string; | ||
HR: string; | ||
QUOTE: string; | ||
EMBEDDED_ENTRY: string; | ||
EMBEDDED_ASSET: string; | ||
}; | ||
export default _default; | ||
declare enum 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" | ||
} | ||
export default BLOCKS; |
/** | ||
* Map of all Contentful inline types. Inline contain inline or text nodes. | ||
*/ | ||
declare const _default: { | ||
HYPERLINK: string; | ||
ENTRY_HYPERLINK: string; | ||
ASSET_HYPERLINK: string; | ||
EMBEDDED_ENTRY: string; | ||
}; | ||
export default _default; | ||
declare enum INLINES { | ||
HYPERLINK = "hyperlink", | ||
ENTRY_HYPERLINK = "entry-hyperlink", | ||
ASSET_HYPERLINK = "asset-hyperlink", | ||
EMBEDDED_ENTRY = "embedded-entry-inline" | ||
} | ||
export default INLINES; |
@@ -1,40 +0,68 @@ | ||
import { Block, Inline } from './types'; | ||
import { Block, Inline, Text, TopLevelBlock } from './types'; | ||
import BLOCKS from './blocks'; | ||
import INLINES from './inlines'; | ||
declare type EmptyNodeData = {}; | ||
export interface Heading1 extends Block { | ||
nodeType: 'heading-1'; | ||
nodeType: BLOCKS.HEADING_1; | ||
data: EmptyNodeData; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface Heading2 extends Block { | ||
nodeType: 'heading-2'; | ||
nodeType: BLOCKS.HEADING_2; | ||
data: EmptyNodeData; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface Heading3 extends Block { | ||
nodeType: 'heading-3'; | ||
nodeType: BLOCKS.HEADING_3; | ||
data: EmptyNodeData; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface Heading4 extends Block { | ||
nodeType: 'heading-4'; | ||
nodeType: BLOCKS.HEADING_4; | ||
data: EmptyNodeData; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface Heading5 extends Block { | ||
nodeType: 'heading-5'; | ||
nodeType: BLOCKS.HEADING_5; | ||
data: EmptyNodeData; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface Heading6 extends Block { | ||
nodeType: 'heading-6'; | ||
nodeType: BLOCKS.HEADING_6; | ||
data: EmptyNodeData; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface Paragraph extends Block { | ||
nodeType: 'paragraph'; | ||
nodeType: BLOCKS.PARAGRAPH; | ||
data: EmptyNodeData; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface Quote extends Block { | ||
nodeType: 'quote'; | ||
nodeType: BLOCKS.QUOTE; | ||
data: EmptyNodeData; | ||
content: Paragraph[]; | ||
} | ||
export interface Hr extends Block { | ||
nodeType: 'hr'; | ||
nodeType: BLOCKS.HR; | ||
/** | ||
* | ||
* @maxItems 0 | ||
*/ | ||
data: EmptyNodeData; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface OrderedList extends Block { | ||
nodeType: 'ordered-list'; | ||
nodeType: BLOCKS.OL_LIST; | ||
data: EmptyNodeData; | ||
content: ListItem[]; | ||
} | ||
export interface UnorderedList extends Block { | ||
nodeType: 'unordered-list'; | ||
nodeType: BLOCKS.UL_LIST; | ||
data: EmptyNodeData; | ||
content: ListItem[]; | ||
} | ||
export interface ListItem extends Block { | ||
nodeType: 'list-item'; | ||
nodeType: BLOCKS.LIST_ITEM; | ||
data: EmptyNodeData; | ||
content: TopLevelBlock[]; | ||
} | ||
@@ -49,21 +77,36 @@ export interface Link<T extends string = string> { | ||
export interface EntryLinkBlock extends Block { | ||
nodeType: 'embedded-entry-block'; | ||
nodeType: BLOCKS.EMBEDDED_ENTRY; | ||
data: { | ||
target: Link<'Entry'>; | ||
}; | ||
/** | ||
* | ||
* @maxItems 0 | ||
*/ | ||
content: Array<Inline | Text>; | ||
} | ||
export interface AssetLinkBlock extends Block { | ||
nodeType: 'embedded-asset-block'; | ||
nodeType: BLOCKS.EMBEDDED_ASSET; | ||
data: { | ||
target: Link<'Asset'>; | ||
}; | ||
/** | ||
* | ||
* @maxItems 0 | ||
*/ | ||
content: Array<Inline | Text>; | ||
} | ||
export interface EntryLinkInline extends Inline { | ||
nodeType: 'embedded-entry-inline'; | ||
nodeType: INLINES.EMBEDDED_ENTRY; | ||
data: { | ||
target: Link<'Entry'>; | ||
}; | ||
/** | ||
* | ||
* @maxItems 0 | ||
*/ | ||
content: Array<Text>; | ||
} | ||
export interface Hyperlink extends Inline { | ||
nodeType: 'hyperlink'; | ||
nodeType: INLINES.HYPERLINK; | ||
data: { | ||
@@ -73,5 +116,6 @@ uri: string; | ||
}; | ||
content: Array<Text>; | ||
} | ||
export interface AssetHyperlink extends Inline { | ||
nodeType: 'asset-hyperlink'; | ||
nodeType: INLINES.ASSET_HYPERLINK; | ||
data: { | ||
@@ -81,5 +125,6 @@ target: Link<'Asset'>; | ||
}; | ||
content: Array<Text>; | ||
} | ||
export interface EntryHyperlink extends Inline { | ||
nodeType: 'entry-hyperlink'; | ||
nodeType: INLINES.ENTRY_HYPERLINK; | ||
data: { | ||
@@ -89,2 +134,4 @@ target: Link<'Entry'>; | ||
}; | ||
content: Array<Text>; | ||
} | ||
export {}; |
@@ -0,1 +1,3 @@ | ||
import BLOCKS from './blocks'; | ||
export declare type TopLevelBlockEnum = 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; | ||
/** | ||
@@ -5,7 +7,7 @@ * Array of all top level block types. | ||
*/ | ||
export declare const TOP_LEVEL_BLOCKS: string[]; | ||
export declare const TOP_LEVEL_BLOCKS: TopLevelBlockEnum[]; | ||
/** | ||
* Array of all void block types | ||
*/ | ||
export declare const VOID_BLOCKS: string[]; | ||
export declare const VOID_BLOCKS: BLOCKS[]; | ||
/** | ||
@@ -15,3 +17,6 @@ * Dictionary of all container block types, and the set block types they accept as children. | ||
export declare const CONTAINERS: { | ||
[x: string]: string[]; | ||
[BLOCKS.OL_LIST]: BLOCKS[]; | ||
[BLOCKS.UL_LIST]: BLOCKS[]; | ||
[BLOCKS.LIST_ITEM]: BLOCKS[]; | ||
[BLOCKS.QUOTE]: BLOCKS[]; | ||
}; |
@@ -0,1 +1,7 @@ | ||
import BLOCKS from './blocks'; | ||
import INLINES from './inlines'; | ||
import { TopLevelBlockEnum } from './schemaConstraints'; | ||
/** | ||
* @additionalProperties true | ||
*/ | ||
export declare type NodeData = Record<string, any>; | ||
@@ -6,12 +12,17 @@ export interface Node { | ||
} | ||
export interface Document extends Node { | ||
nodeType: 'document'; | ||
content: Block[]; | ||
} | ||
export interface Block extends Node { | ||
nodeType: BLOCKS; | ||
content: Array<Block | Inline | Text>; | ||
} | ||
export interface Inline extends Node { | ||
nodeType: INLINES; | ||
content: Array<Inline | Text>; | ||
} | ||
export interface TopLevelBlock extends Block { | ||
nodeType: TopLevelBlockEnum; | ||
} | ||
export interface Document extends Node { | ||
nodeType: BLOCKS.DOCUMENT; | ||
content: TopLevelBlock[]; | ||
} | ||
export interface Text extends Node { | ||
@@ -18,0 +29,0 @@ nodeType: 'text'; |
{ | ||
"name": "@contentful/rich-text-types", | ||
"version": "10.0.1", | ||
"version": "10.1.0", | ||
"main": "dist/rich-text-types.es5.js", | ||
@@ -22,4 +22,5 @@ "typings": "dist/types/index.d.ts", | ||
"prebuild": "rimraf dist", | ||
"build": "tsc --module commonjs && rollup -c rollup.config.js", | ||
"start": "tsc && rollup -c rollup.config.js -w" | ||
"build": "npm run generate-json-schema && tsc --module commonjs && rollup -c rollup.config.js", | ||
"start": "tsc && rollup -c rollup.config.js -w", | ||
"generate-json-schema": "ts-node -O '{\"module\": \"commonjs\"}' ./tools/jsonSchemaGen" | ||
}, | ||
@@ -32,2 +33,3 @@ "devDependencies": { | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-copy": "^0.2.3", | ||
"rollup-plugin-json": "^3.1.0", | ||
@@ -38,5 +40,7 @@ "rollup-plugin-node-resolve": "^3.4.0", | ||
"ts-jest": "^23.10.4", | ||
"typescript": "^2.9.2" | ||
"ts-node": "^7.0.1", | ||
"typescript": "^2.9.2", | ||
"typescript-json-schema": "^0.33.0" | ||
}, | ||
"gitHead": "0c308468f7858c0c8e9391cdf95601e8dd75f9f9" | ||
"gitHead": "f76372fc2a5fec772e124e174d50d5b2b560710c" | ||
} |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
96172
58
3638
14
1
1