remark-slate
Advanced tools
Comparing version 0.10.3 to 1.0.0
{ | ||
"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 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
94660
0
17
1042
1
342
8
2
1
- Removeddeepmerge@^4.2.2
- Removeddeepmerge@4.3.1(transitive)