Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rexxars/sanity-plugin-markdown
Moved to new organization, this is now read-only. Markdown input component and schema type for Sanity
https://github.com/rexxars/sanity-plugin-markdown
Last synced: 13 days ago
JSON representation
Moved to new organization, this is now read-only. Markdown input component and schema type for Sanity
- Host: GitHub
- URL: https://github.com/rexxars/sanity-plugin-markdown
- Owner: rexxars
- License: mit
- Archived: true
- Created: 2018-10-10T21:02:33.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-05T19:42:36.000Z (over 3 years ago)
- Last Synced: 2024-07-31T20:27:53.093Z (3 months ago)
- Language: JavaScript
- Homepage: https://github.com/sanity-io/sanity-plugin-markdown
- Size: 127 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-sanity - `sanity-plugin-markdown` - Adds a new `type: 'markdown'` field type. (Plugins)
README
# ⚠️ Moved to new organization
Go to https://github.com/sanity-io/sanity-plugin-markdown for the new version!
# sanity-plugin-markdown
Markdown input component and schema type for [Sanity](https://www.sanity.io/)
[![npm version](https://img.shields.io/npm/v/sanity-plugin-markdown.svg?style=flat-square)](http://browsenpm.org/package/sanity-plugin-markdown)
## Installing
In your Sanity studio folder, run:
```
sanity install markdown
```## Features
- Auto-growing input area
- Preview mode
- Keyboard shortcuts for formatting## Basic usage
**TL;DR:** Just use `type: 'markdown'` on a field in your schema!
**Long version:** In your schema definitions (think `schemas/blogPost.js`):
```js
export default {
name: 'blogPost',
title: 'Blog Post',
type: 'document',
fields: [
// ... other fields ...
{
name: 'body',
title: 'Body',
type: 'markdown',
options: {
minRows: 20
}
}
]
}
```## Options
- `editorClassName` - _string_ The class name to use for the editor.
- `minRows` - _number_ Minimum number of rows to show for the text area input (default: `10`)
- `autoGrow` - _boolean_ Whether or not to automatically grow the text area on input (default: `true`)
- `usePreview` - _boolean_ Whether or not to use the preview functionality (default: `true`)
- `previewOptions` - _object_ Object of props passed to [react-markdown](https://github.com/rexxars/react-markdown) for rendering (default: `{skipHtml: true}`)
- `renderPreview` - _function_ React component used to render Markdown preview (default: [react-markdown](https://github.com/rexxars/react-markdown))
- **Looking to render full-blown HTML?** You may import `sanity-plugin-markdown/html-preview` for a renderer that parses HTML. **Be careful**, input is not filtered.## Default option values
See options table. Can be retrieved programatically from the `defaultOptions` property on the input:
```js
import MarkdownInput from 'sanity-plugin-markdown'console.log(defaultOptions)
```## Keyboard shortcuts
Based on GitHub + Google Docs keyboard shortcuts.
Mac:
| Key | Action |
| -------------------------------------------- | ------------------------- |
| ⌘ + ⇧ + P | Toggle write/preview mode |
| ⌘ + B | Toggle bold |
| ⌘ + I | Toggle italic |
| ⌘ + K | Toggle link |
| ⌘ + ⇧ + 7 | Toggle ordered list |
| ⌘ + ⇧ + 8 | Toggle unordered list |
| ⌘ + ⇧ + 7 | Toggle ordered list |
| ⌘ + ⌥ + 1-5 | Toggle heading |Window/Linux:
| Key | Action |
| ---------------------------------------------- | ------------------------- |
| ⌃ + ⇧ + P | Toggle write/preview mode |
| ⌃ + B | Toggle bold |
| ⌃ + I | Toggle italic |
| ⌃ + K | Toggle link |
| ⌃ + ⇧ + 7 | Toggle ordered list |
| ⌃ + ⇧ + 8 | Toggle unordered list |
| ⌃ + ⇧ + 7 | Toggle ordered list |
| ⌃ + Alt + 1-5 | Toggle heading |## License
MIT © [Espen Hovlandsdal](https://espen.codes/)