{"_id":"@charamza/slate-serializers","_rev":"2-1d1d652ab3e509217aa0c2e897c722f6","name":"@charamza/slate-serializers","dist-tags":{"latest":"0.4.4"},"versions":{"0.4.0":{"name":"@charamza/slate-serializers","version":"0.4.0","description":"Serialize Slate JSON objects to HTML and vice versa. Define rules to modify the end result.","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","format":"prettier --write \"{src,__tests__}/**/*.ts\"","lint":"tslint -p tsconfig.json","release":"standard-version","prepare":"npm run build","prepublishOnly":"npm test && npm run lint","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/thompsonsj/slate-serializers.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/thompsonsj/slate-serializers/issues"},"homepage":"https://github.com/thompsonsj/slate-serializers#readme","devDependencies":{"@commitlint/cli":"^17.6.3","@commitlint/config-conventional":"^17.6.3","@types/html-escaper":"^3.0.0","@types/jest":"^29.5.1","@types/react":">=16","@types/react-test-renderer":"^18.0.0","commitizen":"^4.3.0","husky":"^8.0.3","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jsdom":"^21.1.1","postcss":"^8.4.24","postcss-js":"^4.0.1","prettier":"^2.8.8","react-test-renderer":"^18.2.0","ts-jest":"^29.1.0","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^5.0.4"},"commitlint":{"extends":["@commitlint/config-conventional"]},"dependencies":{"@testing-library/react":"^14.0.0","css-select":"^5.1.0","dom-serializer":"^2.0.0","domhandler":"^5.0.3","domutils":"^3.1.0","html-entities":"^2.3.3","htmlparser2":"~7.2.0","nanoid":"^4.0.2","slate":"^0.94.1","slate-hyperscript":"^0.77.0"},"peerDependencies":{"@types/react":">=16","react":">=16","react-dom":">=16"},"gitHead":"eec4b3380ad131f107b890681ead602a3196ab78","_id":"@charamza/slate-serializers@0.4.0","_nodeVersion":"16.15.1","_npmVersion":"9.4.0","dist":{"integrity":"sha512-UhkjEX/gZdw/pHg0rWcC3h0qE59Xyd0pvAhzuPwPzOk4N2E5v5Tigoh6QkucwTjLitR0mbrqxHvSwhPj/h/5Ag==","shasum":"965a8b1de04393ab3994df8919bf9418e4677f17","tarball":"https://registry.npmjs.org/@charamza/slate-serializers/-/slate-serializers-0.4.0.tgz","fileCount":50,"unpackedSize":51162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD3BPrT7UDG8SdRA52m60ws6oMV7yhPyJC7QNejn4WZRQIgEIUrkP23PqK1e1cuWX+dMx7UKeHWa5QBl4NW0XXAAAU="}]},"_npmUser":{"name":"charamza","email":"jenda60@gmail.com"},"directories":{},"maintainers":[{"name":"charamza","email":"jenda60@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/slate-serializers_0.4.0_1687800774328_0.2098043694839451"},"_hasShrinkwrap":false},"0.4.1":{"name":"@charamza/slate-serializers","version":"0.4.1","description":"Serialize Slate JSON objects to HTML and vice versa. Define rules to modify the end result.","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","format":"prettier --write \"{src,__tests__}/**/*.ts\"","lint":"tslint -p tsconfig.json","release":"standard-version","prepare":"npm run build","prepublishOnly":"npm test && npm run lint","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/thompsonsj/slate-serializers.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/thompsonsj/slate-serializers/issues"},"homepage":"https://github.com/thompsonsj/slate-serializers#readme","devDependencies":{"@commitlint/cli":"^17.6.3","@commitlint/config-conventional":"^17.6.3","@types/html-escaper":"^3.0.0","@types/jest":"^29.5.1","@types/react":">=16","@types/react-test-renderer":"^18.0.0","commitizen":"^4.3.0","husky":"^8.0.3","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jsdom":"^21.1.1","postcss":"^8.4.24","postcss-js":"^4.0.1","prettier":"^2.8.8","react-test-renderer":"^18.2.0","ts-jest":"^29.1.0","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^5.0.4"},"commitlint":{"extends":["@commitlint/config-conventional"]},"dependencies":{"@testing-library/react":"^14.0.0","css-select":"^5.1.0","dom-serializer":"^2.0.0","domhandler":"^5.0.3","domutils":"^3.1.0","html-entities":"^2.3.3","htmlparser2":"~7.2.0","nanoid":"^4.0.2","slate":"^0.94.1","slate-hyperscript":"^0.77.0"},"peerDependencies":{"@types/react":">=16","react":">=16","react-dom":">=16"},"gitHead":"86fce220f5b2166ade5b1fe993f174a9378412bf","_id":"@charamza/slate-serializers@0.4.1","_nodeVersion":"16.15.1","_npmVersion":"9.4.0","dist":{"integrity":"sha512-Zga+13xqYWCAgNMXJezVta5GcAMSLLMnW2yMAxEroDDyeFWqpx7KdWrMjUN9TtGJuxFm5T91sFP00KbcQdg3hw==","shasum":"b3d22810b7e03f387fdda63a2fe356d6afb36f0b","tarball":"https://registry.npmjs.org/@charamza/slate-serializers/-/slate-serializers-0.4.1.tgz","fileCount":50,"unpackedSize":51162,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAe+viz0WpBJSr1znz12Sx89EZVPIFhrMB/WAQNvYLodAiEArJ2wkCSKNxvlUJxo71E727oBD/Q03Dg1X+AZfzoEadQ="}]},"_npmUser":{"name":"charamza","email":"jenda60@gmail.com"},"directories":{},"maintainers":[{"name":"charamza","email":"jenda60@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/slate-serializers_0.4.1_1687801051738_0.908110205068468"},"_hasShrinkwrap":false},"0.4.4":{"name":"@charamza/slate-serializers","version":"0.4.4","description":"Serialize Slate JSON objects to HTML and vice versa. Define rules to modify the end result.","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"build":"tsc","format":"prettier --write \"{src,__tests__}/**/*.ts\"","lint":"tslint -p tsconfig.json","release":"standard-version","prepare":"npm run build","prepublishOnly":"npm test && npm run lint","test":"jest"},"repository":{"type":"git","url":"git+https://github.com/thompsonsj/slate-serializers.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/thompsonsj/slate-serializers/issues"},"homepage":"https://github.com/thompsonsj/slate-serializers#readme","devDependencies":{"@commitlint/cli":"^17.6.3","@commitlint/config-conventional":"^17.6.3","@types/html-escaper":"^3.0.0","@types/jest":"^29.5.1","@types/react":">=16","@types/react-test-renderer":"^18.0.0","commitizen":"^4.3.0","husky":"^8.0.3","jest":"^29.5.0","jest-environment-jsdom":"^29.5.0","jsdom":"^21.1.1","postcss":"^8.4.24","postcss-js":"^4.0.1","prettier":"^2.8.8","react-test-renderer":"^18.2.0","ts-jest":"^29.1.0","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^5.0.4"},"commitlint":{"extends":["@commitlint/config-conventional"]},"dependencies":{"@testing-library/react":"^14.0.0","css-select":"^5.1.0","dom-serializer":"^2.0.0","domhandler":"^5.0.3","domutils":"^3.1.0","html-entities":"^2.3.3","htmlparser2":"~7.2.0","nanoid":"^4.0.2","slate":"^0.94.1","slate-hyperscript":"^0.77.0"},"peerDependencies":{"@types/react":">=16","react":">=16","react-dom":">=16"},"gitHead":"f87be0ce62839dd8a7c86d21d674f173a9fb761b","_id":"@charamza/slate-serializers@0.4.4","_nodeVersion":"16.15.1","_npmVersion":"9.4.0","dist":{"integrity":"sha512-Ow94bkzZEk4UVk5lNfAesFVvlwpqBCDpz/nYzcnrW+yg3GYGMNdgnKmt61xkLs1KHd8oYnn+hT84yK/IILOE3A==","shasum":"701ab3cdb386ec8187993a2adf6844605a7cd13d","tarball":"https://registry.npmjs.org/@charamza/slate-serializers/-/slate-serializers-0.4.4.tgz","fileCount":50,"unpackedSize":51247,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDWkTGvJvR7YJcznc9YMJ6HuOXvPQrBvlP795GP6BGmzwIgV6Fe3lnw3czCQPviRklQWak6D1OCLl7CsXF8yzybXgc="}]},"_npmUser":{"name":"charamza","email":"jenda60@gmail.com"},"directories":{},"maintainers":[{"name":"charamza","email":"jenda60@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/slate-serializers_0.4.4_1687801217141_0.9297320609438158"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-26T17:32:54.268Z","0.4.0":"2023-06-26T17:32:54.522Z","modified":"2023-06-26T17:40:17.427Z","0.4.1":"2023-06-26T17:37:31.965Z","0.4.4":"2023-06-26T17:40:17.311Z"},"maintainers":[{"name":"charamza","email":"jenda60@gmail.com"}],"description":"Serialize Slate JSON objects to HTML and vice versa. Define rules to modify the end result.","homepage":"https://github.com/thompsonsj/slate-serializers#readme","repository":{"type":"git","url":"git+https://github.com/thompsonsj/slate-serializers.git"},"bugs":{"url":"https://github.com/thompsonsj/slate-serializers/issues"},"license":"ISC","readme":"# slate-serializers\n\nA collection of serializers to convert [Slate](https://www.npmjs.com/package/slate) JSON objects to various formats and vice versa. Designed to work in both Node.js and browser environments.\n\nSerializers included so far:\n\n- [`slateToHtml`](#slatetohtml)\n- [`htmlToSlate`](#htmltoslate)\n- [`slateToDom`](#slatetodom)\n\nView the demo at [https://thompsonsj.github.io/slate-serializers-demo](https://thompsonsj.github.io/slate-serializers-demo).\n\n## Setup\n\n### Compatibility\n\nSerializers are only compatible with Slate >=0.50.0. Earlier versions used a different data model.\n\nNote that compatibility has only been tested with Slate v0.72.8. These serializers are still in active development/testing.\n\n### Install\n\n```bash\nyarn add slate-serializers\n# or\nnpm install slate-serializers\n```\n\n### Configuration\n\nEach serializer uses a default configuration, which may not transform your data effectively.\n\nOne of the principles of Slate is its [**schema-less core**](https://docs.slatejs.org/#principles).\n\nCheck configuration objects in [src/config/](src/config/). Extend the default configuration or write your own in order to apply your schema/transformation rules.\n\n## Serializers\n\n### slateToHtml\n\n```ts\nimport { slateToHtml } from 'slate-serializers'\n\nconst slate = [\n  {\n    children: [\n      {\n        text: 'Heading 1',\n      },\n    ],\n    type: 'h1',\n  },\n  {\n    children: [\n      {\n        text: 'Paragraph 1',\n      },\n    ],\n    type: 'p',\n  },\n]\n\nconst serializedToHtml = slateToHtml(slate)\n// output\n// <h1>Heading 1</h1><p>Paragraph 1</p>\n```\n\n#### Configuration\n\nBy default, `slateToHtml` incorporates transformation rules based on the example in [Deserializing | Serializing | Slate](https://docs.slatejs.org/concepts/10-serializing#deserializing).\n\nIf you are using [Payload CMS](https://payloadcms.com/), import the Payload configuration file and pass it as a parameter to the serializer.\n\n```ts\nimport { slateToHtml, payloadSlateToDomConfig } from 'slate-serializers'\n\nconst slate = [\n  {\n    children: [\n      {\n        text: 'Heading 1',\n      },\n    ],\n    type: 'h1',\n  },\n]\n\nconst serializedToHtml = slateToHtml(slate, payloadSlateToDomConfig)\n```\n\nYou can create your own configuration file that implements your schema. See [src/config/slateToDom/payload.ts](src/config/slateToDom/payload.ts) for an example of how to extend the default configuration or copy [src/config/slateToDom/default.ts](src/config/slateToDom/default.ts) and rewrite it as appropriate.\n\n### htmlToSlate\n\n```ts\nimport { htmlToSlate } from 'slate-serializers'\n\nconst html = `<h1>Heading 1</h1><p>Paragraph 1</p>`\n\nconst serializedToSlate = htmlToSlate(html)\n// output\n/*\n[\n  {\n    children: [\n      {\n        text: 'Heading 1',\n      },\n    ],\n    type: 'h1',\n  },\n  {\n    children: [\n      {\n        text: 'Paragraph 1',\n      },\n    ],\n    type: 'p',\n  },\n]\n/*\n```\n\n#### Configuration\n\nBy default, `htmlToSlate` incorporates transformation rules based on the example in [HTML | Serializing | Slate](https://docs.slatejs.org/concepts/10-serializing#html).\n\nIf you are using [Payload CMS](https://payloadcms.com/), import the Payload configuration file and pass it as a parameter to the serializer.\n\n```ts\nimport { htmlToSlate, payloadHtmlToSlateConfig } from 'slate-serializers'\n\nconst html = `<h1>Heading 1</h1><p>Paragraph 1</p>`\n\nconst serializedToSlate = htmlToSlate(html, payloadHtmlToSlateConfig)\n```\n\nYou can create your own configuration file that implements your schema. See [src/config/htmlToSlate/payload.ts](src/config/htmlToSlate/payload.ts) for an example of how to extend the default configuration or copy [src/config/htmlToSlate/default.ts](src/config/htmlToSlate/default.ts) and rewrite it as appropriate.\n\nFor a breakdown of configuration options, see [docs/config/htmlToSlate.md](docs/config/htmlToSlate.md).\n\n#### Whitespace\n\n`htmlToSlate` processes whitespace in a similar way to browsers. It minifies whitespace while trying to preserve meaning. For details, see [docs/engineering.md#whitespace](docs/engineering.md#whitespace).\n\n### slateToDom\n\n`slateToHtml` is a simple wrapper that runs [`dom-serializer`](https://www.npmjs.com/package/dom-serializer) on the output from `slateToDom`.\n\n`slateToDom` is made available in case you wish to work with the DOM output yourself or run `dom-serializer` using any of the available options.\n\nIt accepts the same configuration object as [slateToHtml](#slatetohtml).\n\n### Commits\n\nTLDR: contributors can format commit messages in any way, maintainers should use conventional commits. \n\nThis repository uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).\n\nConventional commits are not enforced. General guidance:\n\n- Commit messages can be formatted in any way on a pull request.\n- Conventional commit messages are preferred on pull request squash and merge.\n\nRun `npx cz` instead of `git commit` to lint commit messages using [@commitlint/cli](https://www.npmjs.com/package/@commitlint/cli). \n","readmeFilename":"README.md"}