@tiptap/core
Advanced tools
Comparing version 2.2.0-rc.8 to 2.2.0
{ | ||
"name": "@tiptap/core", | ||
"description": "headless rich text editor", | ||
"version": "2.2.0-rc.8", | ||
"version": "2.2.0", | ||
"homepage": "https://tiptap.dev", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/pm": "^2.2.0-rc.8" | ||
"@tiptap/pm": "^2.2.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "peerDependencies": { |
@@ -29,3 +29,3 @@ import { Node as ProseMirrorNode } from '@tiptap/pm/model' | ||
doc.nodesBetween(from, to, (node, pos) => { | ||
if (!node || node.nodeSize === undefined) { | ||
if (!node || node?.nodeSize === undefined) { | ||
return | ||
@@ -32,0 +32,0 @@ } |
@@ -0,1 +1,17 @@ | ||
const removeWhitespaces = (node: HTMLElement) => { | ||
const children = node.childNodes | ||
for (let i = children.length - 1; i >= 0; i -= 1) { | ||
const child = children[i] | ||
if (child.nodeType === 3 && child.nodeValue && /^(\n\s\s|\n)$/.test(child.nodeValue)) { | ||
node.removeChild(child) | ||
} else if (child.nodeType === 1) { | ||
removeWhitespaces(child as HTMLElement) | ||
} | ||
} | ||
return node | ||
} | ||
export function elementFromString(value: string): HTMLElement { | ||
@@ -5,3 +21,5 @@ // add a wrapper to preserve leading and trailing whitespace | ||
return new window.DOMParser().parseFromString(wrappedValue, 'text/html').body | ||
const html = new window.DOMParser().parseFromString(wrappedValue, 'text/html').body | ||
return removeWhitespaces(html) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2029146
23784
0