mobiledoc-vdom-renderer
Advanced tools
Comparing version 1.0.1 to 1.1.0
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
@@ -12,2 +23,9 @@ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
var MarkersRenderer_1 = require("../MarkersRenderer"); | ||
var attributesArrayToAttributes = function (attributesArray) { | ||
return attributesArray.reduce(function (accumulator, value, index) { | ||
var _a; | ||
return index % 2 !== 0 | ||
? __assign(__assign({}, accumulator), (_a = {}, _a[attributesArray[index - 1]] = value, _a)) : accumulator; | ||
}, {}); | ||
}; | ||
exports.default = (function (_a) { | ||
@@ -18,6 +36,6 @@ var createElement = _a.createElement, getAtomComponent = _a.getAtomComponent, getMarkupComponent = _a.getMarkupComponent; | ||
return function (_a) { | ||
var tagName = _a[1], markers = _a[2]; | ||
var tagName = _a[1], markers = _a[2], attributes = _a[3]; | ||
return createElement.apply(void 0, __spreadArrays([getMarkupComponent(tagName) || | ||
utils_1.throwError("Unhandled element: the markup section `'" + tagName + "'` has no corresponding handler."), | ||
{}], MarkersRenderer_1.default({ createElement: createElement, getAtomComponent: getAtomComponent, getMarkupComponent: getMarkupComponent })({ | ||
attributesArrayToAttributes(attributes || [])], MarkersRenderer_1.default({ createElement: createElement, getAtomComponent: getAtomComponent, getMarkupComponent: getMarkupComponent })({ | ||
markups: markups, | ||
@@ -24,0 +42,0 @@ atoms: atoms |
@@ -12,3 +12,3 @@ import { CreateElement, ElementTypeGetter } from '../../types'; | ||
} | ||
declare const _default: ({ createElement, getAtomComponent, getMarkupComponent }: Options) => ({ markups, atoms }: Context) => ([, tagName, markers]: MarkupSection) => any; | ||
declare const _default: ({ createElement, getAtomComponent, getMarkupComponent }: Options) => ({ markups, atoms }: Context) => ([, tagName, markers, attributes]: MarkupSection) => any; | ||
export default _default; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
@@ -12,2 +23,9 @@ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
var MarkersRenderer_1 = require("../MarkersRenderer"); | ||
var attributesArrayToAttributes = function (attributesArray) { | ||
return attributesArray.reduce(function (accumulator, value, index) { | ||
var _a; | ||
return index % 2 !== 0 | ||
? __assign(__assign({}, accumulator), (_a = {}, _a[attributesArray[index - 1]] = value, _a)) : accumulator; | ||
}, {}); | ||
}; | ||
exports.default = (function (_a) { | ||
@@ -18,6 +36,6 @@ var createElement = _a.createElement, getAtomComponent = _a.getAtomComponent, getMarkupComponent = _a.getMarkupComponent; | ||
return function (_a) { | ||
var tagName = _a[1], markers = _a[2]; | ||
var tagName = _a[1], markers = _a[2], attributes = _a[3]; | ||
return createElement.apply(void 0, __spreadArrays([getMarkupComponent(tagName) || | ||
utils_1.throwError("Unhandled element: the markup section `'" + tagName + "'` has no corresponding handler."), | ||
{}], MarkersRenderer_1.default({ createElement: createElement, getAtomComponent: getAtomComponent, getMarkupComponent: getMarkupComponent })({ | ||
attributesArrayToAttributes(attributes || [])], MarkersRenderer_1.default({ createElement: createElement, getAtomComponent: getAtomComponent, getMarkupComponent: getMarkupComponent })({ | ||
markups: markups, | ||
@@ -24,0 +42,0 @@ atoms: atoms |
@@ -65,3 +65,8 @@ export declare enum MarkerTypeIdentifier { | ||
2: Marker[]; | ||
3?: Attributes; | ||
} | ||
export interface Attributes extends Array<any> { | ||
0: 'data-md-text-align'; | ||
1: 'left' | 'right' | 'center'; | ||
} | ||
export declare enum ImageSectionTagName { | ||
@@ -68,0 +73,0 @@ img = "img" |
{ | ||
"name": "mobiledoc-vdom-renderer", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Render Mobiledoc as VDOM, for React or React-like `createElement` calls", | ||
@@ -5,0 +5,0 @@ "author": "Donald Tetto <donald@tetto.org>", |
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
83743
1677
1