@slate-serializers/dom
Advanced tools
Comparing version 2.2.1 to 2.2.2
{ | ||
"name": "@slate-serializers/dom", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Serialize Slate JSON objects to the DOM. Can be used with `htmlparser2` and associated utilities to modify the DOM and generate HTML. Used by other serializers in this monorepo.", | ||
@@ -16,3 +16,4 @@ "type": "commonjs", | ||
}, | ||
"main": "./src/index.js" | ||
"main": "./src/index.js", | ||
"types": "./src/index.d.ts" | ||
} |
@@ -6,2 +6,3 @@ "use strict"; | ||
const default_1 = require("./default"); | ||
const utilities_1 = require("../utilities"); | ||
/** | ||
@@ -12,3 +13,12 @@ * Configuration for Payload CMS | ||
*/ | ||
exports.config = Object.assign(Object.assign({}, default_1.config), { elementTransforms: Object.assign(Object.assign({}, default_1.config.elementTransforms), { link: ({ node, children = [] }) => { | ||
exports.config = Object.assign(Object.assign({}, default_1.config), { elementAttributeTransform: ({ node }) => { | ||
if (node.align || node.textAlign) { | ||
return { | ||
style: (0, utilities_1.styleToString)({ | ||
['text-align']: node.align || node.textAlign, | ||
}) | ||
}; | ||
} | ||
return; | ||
}, elementTransforms: Object.assign(Object.assign({}, default_1.config.elementTransforms), { link: ({ node, children = [] }) => { | ||
const attrs = {}; | ||
@@ -15,0 +25,0 @@ if (node.linkType) { |
@@ -97,3 +97,3 @@ "use strict"; | ||
if (!element && config.defaultTag && !node.type) { | ||
element = transformElement(new domhandler_1.Element(config.defaultTag, {}, children)); | ||
element = transformElement(new domhandler_1.Element(config.defaultTag, attribs, children)); | ||
} | ||
@@ -100,0 +100,0 @@ if (element) { |
24453
598