datocms-html-to-structured-text
Advanced tools
Comparing version 1.2.1 to 1.2.3-alpha.0
@@ -118,3 +118,3 @@ "use strict"; | ||
? options.allowedMarks | ||
: datocms_structured_text_utils_1.allowedMarks, | ||
: datocms_structured_text_utils_1.defaultMarks, | ||
global: __assign({ baseUrl: null, baseUrlFound: false }, (options.shared || {})), | ||
@@ -121,0 +121,0 @@ })]; |
@@ -57,3 +57,3 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import documentToHast from 'hast-util-from-dom'; | ||
import { allowedMarks, } from 'datocms-structured-text-utils'; | ||
import { defaultMarks, } from 'datocms-structured-text-utils'; | ||
export function htmlToStructuredText(html, options) { | ||
@@ -109,3 +109,3 @@ if (options === void 0) { options = {}; } | ||
? options.allowedMarks | ||
: allowedMarks, | ||
: defaultMarks, | ||
global: __assign({ baseUrl: null, baseUrlFound: false }, (options.shared || {})), | ||
@@ -112,0 +112,0 @@ })]; |
{ | ||
"name": "datocms-html-to-structured-text", | ||
"version": "1.2.1", | ||
"version": "1.2.3-alpha.0", | ||
"description": "Convert HTML (or a `hast` syntax tree) to a valid DatoCMS Structured Text `dast` document", | ||
@@ -36,3 +36,3 @@ "keywords": [ | ||
"dependencies": { | ||
"datocms-structured-text-utils": "^1.2.0", | ||
"datocms-structured-text-utils": "^1.2.3-alpha.0", | ||
"extend": "^3.0.2", | ||
@@ -52,3 +52,3 @@ "hast-util-from-dom": "^3.0.0", | ||
}, | ||
"gitHead": "f7a6bacaf5a517018a039c45a8dac35377ec6e13" | ||
"gitHead": "a300eb72a078d572ec8e8bc4e53ff7d96dfe0529" | ||
} |
@@ -216,3 +216,3 @@ # `datocms-html-to-structured-text` | ||
```js | ||
import { findAll } from 'unist-utils-core'; | ||
import { visit } from 'unist-utils-core'; | ||
@@ -315,2 +315,4 @@ const html = ` | ||
```js | ||
import { visit, CONTINUE } from 'unist-utils-core'; | ||
const html = ` | ||
@@ -323,11 +325,11 @@ <ul> | ||
`; | ||
const dast = await htmlToStructuredText(html, { | ||
preprocess: (tree) => { | ||
findAll(tree, (node, index, parent) => { | ||
if (node.tagName === 'img') { | ||
// Add the image to the root's children. | ||
visit(tree, (node, index, parents) => { | ||
if (node.tagName === 'img' && parents.length > 1) { | ||
const parent = parents[parents.length - 1]; | ||
tree.children.push(node); | ||
// remove the image from the parent's children array. | ||
parent.children.splice(index, 1); | ||
return; | ||
return [CONTINUE, index]; | ||
} | ||
@@ -340,5 +342,3 @@ }); | ||
const item = '123'; | ||
return createNode('block', { | ||
item, | ||
}); | ||
return createNode('block', { item }); | ||
}, | ||
@@ -345,0 +345,0 @@ }, |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
168337
1
+ Addeddatocms-structured-text-utils@1.2.3-alpha.3(transitive)
- Removeddatocms-structured-text-utils@1.2.0(transitive)