New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@udecode/plate-html-serializer

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@udecode/plate-html-serializer - npm Package Compare versions

Comparing version 2.0.0 to 3.1.3

10

CHANGELOG.md
# @udecode/plate-html-serializer
## 3.1.3
### Patch Changes
- [#998](https://github.com/udecode/plate/pull/998) [`c53532ba`](https://github.com/udecode/plate/commit/c53532baebd83fe79c53b300e97ecf6e713f7754) Thanks [@bensquire](https://github.com/bensquire)! - Adds the ability to not strip whitespace when converting to and from plate/html syntax
- Updated dependencies [[`f6c58134`](https://github.com/udecode/plate/commit/f6c581347cc5877b7afa0774ef1ad78ad227564e)]:
- @udecode/plate-common@3.1.3
- @udecode/plate-serializer@3.1.3
## 2.0.0

@@ -4,0 +14,0 @@

3

dist/deserializer/utils/deserializeHTMLToDocumentFragment.d.ts

@@ -5,6 +5,7 @@ import { PlatePlugin, SPEditor, TDescendant } from '@udecode/plate-core';

*/
export declare const deserializeHTMLToDocumentFragment: <T extends SPEditor = SPEditor>(editor: T, { plugins, element, }: {
export declare const deserializeHTMLToDocumentFragment: <T extends SPEditor = SPEditor>(editor: T, { plugins, element, stripWhitespace, }: {
plugins: PlatePlugin<T>[];
element: HTMLElement | string;
stripWhitespace?: boolean | undefined;
}) => TDescendant[];
//# sourceMappingURL=deserializeHTMLToDocumentFragment.d.ts.map

@@ -11,5 +11,10 @@ import { isElement, getPlatePluginWithOverrides } from '@udecode/plate-core';

*/
const htmlStringToDOMNode = rawHtml => {
const htmlStringToDOMNode = (rawHtml, stripWhitespace = true) => {
const node = document.createElement('body');
node.innerHTML = rawHtml.replace(/(\r\n|\n|\r|\t)/gm, '');
node.innerHTML = rawHtml;
if (stripWhitespace) {
node.innerHTML = node.innerHTML.replace(/(\r\n|\n|\r|\t)/gm, '');
}
return node;

@@ -197,6 +202,7 @@ };

plugins,
element
element,
stripWhitespace = true
}) => {
if (typeof element === 'string') {
element = htmlStringToDOMNode(element);
element = htmlStringToDOMNode(element, stripWhitespace);
}

@@ -363,3 +369,4 @@

stripDataAttributes = true,
preserveClassNames
preserveClassNames,
stripWhitespace = true
}) => {

@@ -390,3 +397,4 @@ let result = nodes.map(node => {

nodes: node.children,
preserveClassNames
preserveClassNames,
stripWhitespace
})),

@@ -402,4 +410,8 @@ attributes: {

}).join('');
result = trimWhitespace(decodeURIComponent(result));
result = decodeURIComponent(result);
if (stripWhitespace) {
result = trimWhitespace(result);
}
if (stripDataAttributes) {

@@ -406,0 +418,0 @@ result = stripSlateDataAttributes(result);

@@ -15,5 +15,10 @@ 'use strict';

*/
const htmlStringToDOMNode = rawHtml => {
const htmlStringToDOMNode = (rawHtml, stripWhitespace = true) => {
const node = document.createElement('body');
node.innerHTML = rawHtml.replace(/(\r\n|\n|\r|\t)/gm, '');
node.innerHTML = rawHtml;
if (stripWhitespace) {
node.innerHTML = node.innerHTML.replace(/(\r\n|\n|\r|\t)/gm, '');
}
return node;

@@ -201,6 +206,7 @@ };

plugins,
element
element,
stripWhitespace = true
}) => {
if (typeof element === 'string') {
element = htmlStringToDOMNode(element);
element = htmlStringToDOMNode(element, stripWhitespace);
}

@@ -367,3 +373,4 @@

stripDataAttributes = true,
preserveClassNames
preserveClassNames,
stripWhitespace = true
}) => {

@@ -394,3 +401,4 @@ let result = nodes.map(node => {

nodes: node.children,
preserveClassNames
preserveClassNames,
stripWhitespace
})),

@@ -406,4 +414,8 @@ attributes: {

}).join('');
result = trimWhitespace(decodeURIComponent(result));
result = decodeURIComponent(result);
if (stripWhitespace) {
result = trimWhitespace(result);
}
if (stripDataAttributes) {

@@ -410,0 +422,0 @@ result = stripSlateDataAttributes(result);

@@ -5,3 +5,3 @@ import { PlatePlugin, SlateProps, SPEditor, TDescendant } from '@udecode/plate-core';

*/
export declare const serializeHTMLFromNodes: (editor: SPEditor, { plugins, nodes, slateProps, stripDataAttributes, preserveClassNames, }: {
export declare const serializeHTMLFromNodes: (editor: SPEditor, { plugins, nodes, slateProps, stripDataAttributes, preserveClassNames, stripWhitespace, }: {
/**

@@ -27,3 +27,8 @@ * Plugins with renderElement or renderLeaf.

slateProps?: Partial<SlateProps> | undefined;
/**
* Whether stripping whitespaces from serialized HTML
* @default true
*/
stripWhitespace?: boolean | undefined;
}) => string;
//# sourceMappingURL=serializeHTMLFromNodes.d.ts.map
/**
* Convert HTML string into HTML element.
*/
export declare const htmlStringToDOMNode: (rawHtml: string) => HTMLBodyElement;
export declare const htmlStringToDOMNode: (rawHtml: string, stripWhitespace?: boolean) => HTMLBodyElement;
//# sourceMappingURL=htmlStringToDOMNode.d.ts.map
{
"name": "@udecode/plate-html-serializer",
"version": "2.0.0",
"version": "3.1.3",
"description": "HTML serializer plugin for Plate",

@@ -37,5 +37,5 @@ "keywords": [

"dependencies": {
"@udecode/plate-common": "2.0.0",
"@udecode/plate-common": "3.1.3",
"@udecode/plate-core": "1.0.0",
"@udecode/plate-serializer": "2.0.0"
"@udecode/plate-serializer": "3.1.3"
},

@@ -42,0 +42,0 @@ "peerDependencies": {

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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc