datocms-html-to-structured-text
Advanced tools
Comparing version 2.1.8 to 2.1.9
@@ -55,3 +55,3 @@ "use strict"; | ||
// visitChildren() is for visiting all the children of a node | ||
exports.default = (function visitChildren(createNode, parentNode, context) { | ||
function visitChildren(createNode, parentNode, context) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -92,3 +92,4 @@ var nodes, values, index, result; | ||
}); | ||
}); | ||
} | ||
exports.default = visitChildren; | ||
//# sourceMappingURL=visit-children.js.map |
@@ -1,2 +0,2 @@ | ||
import { CreateNodeFunction, HastRootNode } from './types'; | ||
import { Handler, HastRootNode } from './types'; | ||
import visitNode from './visit-node'; | ||
@@ -8,3 +8,3 @@ import visitChildren from './visit-children'; | ||
newlines: boolean; | ||
handlers: Record<string, CreateNodeFunction>; | ||
handlers: Record<string, Handler>; | ||
preprocess: (hast: HastRootNode) => void; | ||
@@ -11,0 +11,0 @@ allowedBlocks: Array<BlockquoteType | CodeType | HeadingType | LinkType | ListType>; |
@@ -19,5 +19,5 @@ import { Node, Root, NodeType, Mark } from 'datocms-structured-text-utils'; | ||
/** A reference to the current handlers - merged default + user handlers. */ | ||
handlers: Record<string, Handler<unknown>>; | ||
handlers: Record<string, Handler>; | ||
/** A reference to the default handlers record (map). */ | ||
defaultHandlers: Record<string, Handler<unknown>>; | ||
defaultHandlers: Record<string, Handler>; | ||
/** true if the content can include newlines, and false if not (such as in headings). */ | ||
@@ -39,3 +39,3 @@ wrapText: boolean; | ||
} | ||
export declare type Handler<HastNodeType> = (createNodeFunction: CreateNodeFunction, node: HastNodeType, context: Context) => Promise<Node | Array<Node> | void> | Array<Promise<Node | Array<Node> | void>>; | ||
export declare type Handler<Node extends HastNode = HastNode> = (createNodeFunction: CreateNodeFunction, node: Node, context: Context) => Promise<Node | Array<Node> | void> | Array<Promise<Node | Array<Node> | void>>; | ||
export interface HastProperties { | ||
@@ -42,0 +42,0 @@ className?: string[]; |
@@ -1,3 +0,2 @@ | ||
import { Handler, HastElementNode } from './types'; | ||
declare const _default: Handler<HastElementNode>; | ||
export default _default; | ||
import { Node, HastElementNode, CreateNodeFunction, Context } from './types'; | ||
export default function visitChildren(createNode: CreateNodeFunction, parentNode: HastElementNode, context: Context): Promise<Node | Array<Node> | void>; |
@@ -50,3 +50,3 @@ var __assign = (this && this.__assign) || function () { | ||
// visitChildren() is for visiting all the children of a node | ||
export default (function visitChildren(createNode, parentNode, context) { | ||
export default function visitChildren(createNode, parentNode, context) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -87,3 +87,3 @@ var nodes, values, index, result; | ||
}); | ||
}); | ||
} | ||
//# sourceMappingURL=visit-children.js.map |
@@ -1,2 +0,2 @@ | ||
import { CreateNodeFunction, HastRootNode } from './types'; | ||
import { Handler, HastRootNode } from './types'; | ||
import visitNode from './visit-node'; | ||
@@ -8,3 +8,3 @@ import visitChildren from './visit-children'; | ||
newlines: boolean; | ||
handlers: Record<string, CreateNodeFunction>; | ||
handlers: Record<string, Handler>; | ||
preprocess: (hast: HastRootNode) => void; | ||
@@ -11,0 +11,0 @@ allowedBlocks: Array<BlockquoteType | CodeType | HeadingType | LinkType | ListType>; |
@@ -19,5 +19,5 @@ import { Node, Root, NodeType, Mark } from 'datocms-structured-text-utils'; | ||
/** A reference to the current handlers - merged default + user handlers. */ | ||
handlers: Record<string, Handler<unknown>>; | ||
handlers: Record<string, Handler>; | ||
/** A reference to the default handlers record (map). */ | ||
defaultHandlers: Record<string, Handler<unknown>>; | ||
defaultHandlers: Record<string, Handler>; | ||
/** true if the content can include newlines, and false if not (such as in headings). */ | ||
@@ -39,3 +39,3 @@ wrapText: boolean; | ||
} | ||
export declare type Handler<HastNodeType> = (createNodeFunction: CreateNodeFunction, node: HastNodeType, context: Context) => Promise<Node | Array<Node> | void> | Array<Promise<Node | Array<Node> | void>>; | ||
export declare type Handler<Node extends HastNode = HastNode> = (createNodeFunction: CreateNodeFunction, node: Node, context: Context) => Promise<Node | Array<Node> | void> | Array<Promise<Node | Array<Node> | void>>; | ||
export interface HastProperties { | ||
@@ -42,0 +42,0 @@ className?: string[]; |
@@ -1,3 +0,2 @@ | ||
import { Handler, HastElementNode } from './types'; | ||
declare const _default: Handler<HastElementNode>; | ||
export default _default; | ||
import { Node, HastElementNode, CreateNodeFunction, Context } from './types'; | ||
export default function visitChildren(createNode: CreateNodeFunction, parentNode: HastElementNode, context: Context): Promise<Node | Array<Node> | void>; |
{ | ||
"name": "datocms-html-to-structured-text", | ||
"version": "2.1.8", | ||
"version": "2.1.9", | ||
"description": "Convert HTML (or a `hast` syntax tree) to a valid DatoCMS Structured Text `dast` document", | ||
@@ -52,3 +52,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "53a4fa953a340536439af51bfc6f2c8dca1483c7" | ||
"gitHead": "bf161a8827b98b653ef78c35d3d77138a365d99b" | ||
} |
@@ -7,3 +7,3 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import { CreateNodeFunction, HastRootNode } from './types'; | ||
import { CreateNodeFunction, Handler, HastRootNode } from './types'; | ||
import visitNode from './visit-node'; | ||
@@ -28,3 +28,3 @@ import visitChildren from './visit-children'; | ||
newlines: boolean; | ||
handlers: Record<string, CreateNodeFunction>; | ||
handlers: Record<string, Handler>; | ||
preprocess: (hast: HastRootNode) => void; | ||
@@ -31,0 +31,0 @@ allowedBlocks: Array< |
@@ -26,5 +26,5 @@ import { Node, Root, NodeType, Mark } from 'datocms-structured-text-utils'; | ||
/** A reference to the current handlers - merged default + user handlers. */ | ||
handlers: Record<string, Handler<unknown>>; | ||
handlers: Record<string, Handler>; | ||
/** A reference to the default handlers record (map). */ | ||
defaultHandlers: Record<string, Handler<unknown>>; | ||
defaultHandlers: Record<string, Handler>; | ||
/** true if the content can include newlines, and false if not (such as in headings). */ | ||
@@ -47,5 +47,5 @@ wrapText: boolean; | ||
export type Handler<HastNodeType> = ( | ||
export type Handler<Node extends HastNode = HastNode> = ( | ||
createNodeFunction: CreateNodeFunction, | ||
node: HastNodeType, | ||
node: Node, | ||
context: Context, | ||
@@ -52,0 +52,0 @@ ) => |
@@ -1,6 +0,16 @@ | ||
import { Handler, Node, HastNode, HastElementNode } from './types'; | ||
import { | ||
Node, | ||
HastNode, | ||
HastElementNode, | ||
CreateNodeFunction, | ||
Context, | ||
} from './types'; | ||
import visitNode from './visit-node'; | ||
// visitChildren() is for visiting all the children of a node | ||
export default (async function visitChildren(createNode, parentNode, context) { | ||
export default async function visitChildren( | ||
createNode: CreateNodeFunction, | ||
parentNode: HastElementNode, | ||
context: Context, | ||
): Promise<Node | Array<Node> | void> { | ||
const nodes: HastNode[] = Array.isArray(parentNode.children) | ||
@@ -37,2 +47,2 @@ ? parentNode.children | ||
return values; | ||
} as Handler<HastElementNode>); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
195888
3287