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

remark-slate

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-slate - npm Package Compare versions

Comparing version 0.10.3 to 1.0.0

dist/deserialize.d.ts

43

package.json
{
"name": "remark-slate",
"version": "0.10.3",
"version": "1.0.0",
"description": "remark plugin to compile Markdown to a slate compatible object",
"license": "MIT",
"main": "index.js",
"module": "dist/remark-slate-ts.esm.js",
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx build"
},
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"keywords": [

@@ -25,21 +34,27 @@ "remark",

"files": [
"./index.js"
"dist",
"src"
],
"dependencies": {
"deepmerge": "^4.2.2"
},
"dependencies": {},
"devDependencies": {
"eslint-plugin-prettier": "^3.1.3",
"husky": "^4.2.5",
"jest": "^25.2.4",
"prettier": "^2.0.0",
"remark": "^11.0.0"
"remark": "^11.0.0",
"tsdx": "^0.13.2",
"tslib": "^2.0.0",
"typescript": "^3.9.3"
},
"scripts": {
"jest": "jest",
"test": "jest"
"prettier": {
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
}
}
# remark-slate
> Transform the contents of a slate 0.50+ editor into markdown and back again.
[![Downloads][downloads-badge]][downloads]

@@ -8,6 +10,37 @@ [![Size][size-badge]][size]

This package is meant to be used with [remark-parse](https://github.com/remarkjs/remark/tree/master/packages/remark-parse)
## Usage
### Serializing from slate object to markdown:
`remark-slate` exports an opinionated `serialize` function that is meant to be invoked with a `slate 0.50+` state object and will transform the object into a markdown document.
```js
import { serialize } from 'remark-slate';
export default ({ onChange }) => {
const [value, setValue] = useState(initialValue);
React.useEffect(() => {
// serialize slate state to a markdown string
onChange(value.map((v) => serialize(v)).join());
}, [onChange, value]);
return (
<Slate editor={editor} value={value} onChange={(value) => setValue(value)}>
<Editable
renderElement={renderElement}
renderLeaf={renderLeaf}
placeholder="Enter some rich text…"
...
/>
...
</Slate>
);
};
```
### Deserializing from markdown to slate object:
When deserializing, this package is meant to be used with [remark-parse](https://github.com/remarkjs/remark/tree/master/packages/remark-parse)
Say we have the following file, `example.md`:

@@ -260,2 +293,22 @@

## Local Development
Below is a list of commands you will probably find useful.
### `npm start` or `yarn start`
Runs the project in development/watch mode. The project will be rebuilt upon changes.
Your library will be rebuilt if you make edits.
### `npm run build` or `yarn build`
Bundles the package to the `dist` folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
### `npm test` or `yarn test`
Runs the test watcher (Jest) in an interactive mode.
By default, runs tests related to files changed since the last commit.
## License (MIT)

@@ -262,0 +315,0 @@

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