slate-serializers
Advanced tools
Comparing version 0.0.33 to 0.1.0
import { ChildNode, Element } from 'domhandler'; | ||
interface MarkTagTransform { | ||
[key: string]: ({ node, attribs, }: { | ||
node?: any; | ||
attribs?: { | ||
[key: string]: string; | ||
}; | ||
}) => Element; | ||
} | ||
interface ElementTagTransform { | ||
@@ -21,2 +29,6 @@ [key: string]: ({ node, attribs, children, }: { | ||
}; | ||
markStyleMap?: { | ||
[key: string]: string; | ||
}; | ||
markTransforms?: MarkTagTransform; | ||
elementTransforms: ElementTagTransform; | ||
@@ -23,0 +35,0 @@ defaultTag?: string; |
@@ -39,3 +39,12 @@ "use strict"; | ||
if (node[key]) { | ||
markElements.push(...config.markMap[key]); | ||
const elements = config.markMap[key] | ||
.map((tagName) => { | ||
var _a; | ||
// more complex transforms | ||
if ((_a = config.markTransforms) === null || _a === void 0 ? void 0 : _a[tagName]) { | ||
return config.markTransforms[tagName]({ node, attribs: {} }); | ||
} | ||
return new domhandler_1.Element(tagName, {}, []); | ||
}); | ||
markElements.push(...elements); | ||
} | ||
@@ -42,0 +51,0 @@ }); |
@@ -9,4 +9,4 @@ import { Element, Text } from 'domhandler'; | ||
*/ | ||
export declare const nestedMarkElementsString: (els: string[], text: string) => string; | ||
export declare const nestedMarkElements: (els: string[], element: Element | Text) => Element | Text; | ||
export declare const nestedMarkElementsString: (els: Element[], text: string) => string; | ||
export declare const nestedMarkElements: (els: Element[], element: Element | Text) => Element | Text; | ||
/** | ||
@@ -13,0 +13,0 @@ * Extract css value from style attribute |
@@ -24,3 +24,6 @@ "use strict"; | ||
const el1 = els.pop(); | ||
element = new domhandler_1.Element(el1, {}, [element]); | ||
if (el1) { | ||
el1.children = [element]; | ||
element = el1; | ||
} | ||
if (!els || els.length === 0) { | ||
@@ -30,3 +33,6 @@ return element; | ||
const el2 = els.pop(); | ||
element = new domhandler_1.Element(el2, {}, [element]); | ||
if (el2) { | ||
el2.children = [element]; | ||
element = el2; | ||
} | ||
if (!els || els.length === 0) { | ||
@@ -36,3 +42,6 @@ return element; | ||
const el3 = els.pop(); | ||
element = new domhandler_1.Element(el3, {}, [element]); | ||
if (el3) { | ||
el3.children = [element]; | ||
element = el3; | ||
} | ||
if (!els || els.length === 0) { | ||
@@ -42,3 +51,6 @@ return element; | ||
const el4 = els.pop(); | ||
element = new domhandler_1.Element(el4, {}, [element]); | ||
if (el4) { | ||
el4.children = [element]; | ||
element = el4; | ||
} | ||
if (!els || els.length === 0) { | ||
@@ -48,3 +60,6 @@ return element; | ||
const el5 = els.pop(); | ||
element = new domhandler_1.Element(el5, {}, [element]); | ||
if (el5) { | ||
el5.children = [element]; | ||
element = el5; | ||
} | ||
if (!els || els.length === 0) { | ||
@@ -51,0 +66,0 @@ return element; |
{ | ||
"name": "slate-serializers", | ||
"version": "0.0.33", | ||
"version": "0.1.0", | ||
"description": "Serialize Slate JSON objects to HTML and vice versa. Define rules to modify the end result.", | ||
@@ -35,7 +35,6 @@ "main": "lib/index.js", | ||
"commitizen": "^4.3.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"husky": "^8.0.3", | ||
"jest": "^29.5.0", | ||
"postcss-js": "^4.0.1", | ||
"prettier": "^2.8.8", | ||
"standard-version": "^9.5.0", | ||
"ts-jest": "^29.1.0", | ||
@@ -46,7 +45,2 @@ "tslint": "^6.1.3", | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
}, | ||
"commitlint": { | ||
@@ -64,2 +58,3 @@ "extends": [ | ||
"htmlparser2": "~7.2.0", | ||
"postcss": "^8.4.24", | ||
"slate": "^0.94.1", | ||
@@ -66,0 +61,0 @@ "slate-hyperscript": "^0.77.0" |
45209
13
1079
9
+ Addedpostcss@^8.4.24
+ Addednanoid@3.3.8(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpostcss@8.5.1(transitive)
+ Addedsource-map-js@1.2.1(transitive)