@tiptap/core
Advanced tools
Comparing version 2.1.15 to 2.1.16
{ | ||
"name": "@tiptap/core", | ||
"description": "headless rich text editor", | ||
"version": "2.1.15", | ||
"version": "2.1.16", | ||
"homepage": "https://tiptap.dev", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/pm": "^2.1.15" | ||
"@tiptap/pm": "^2.1.16" | ||
}, | ||
@@ -38,0 +38,0 @@ "peerDependencies": { |
@@ -43,3 +43,2 @@ import { | ||
if (typeof content === 'string') { | ||
content = content.split('\n').map(part => part.trim()).join('') // we need to remove new lines since the parser will add breaks | ||
const parser = DOMParser.fromSchema(schema) | ||
@@ -46,0 +45,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 && !/\S/.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,7 @@ // 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 | ||
removeWhitespaces(html) | ||
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
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
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
1959919
23012