1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-28 17:39:57 +02:00

Merged upstream/master

This commit is contained in:
Sunny Hirai
2018-01-11 09:55:07 -08:00
5 changed files with 73 additions and 10 deletions

View File

@@ -14,7 +14,7 @@
<a href="#principles"><strong>Principles</strong></a> ·
<a href="http://slatejs.org"><strong>Demo</strong></a> ·
<a href="#examples"><strong>Examples</strong></a> ·
<a href="#plugins"><strong>Plugins</strong></a> ·
<a href="./docs/general/plugins.md"><strong>Plugins</strong></a> ·
<a href="http://docs.slatejs.org"><strong>Documentation</strong></a> ·
<a href="./Contributing.md"><strong>Contributing!</strong></a>
</p>
@@ -26,7 +26,7 @@
<p align="center">
<a href="https://www.npmjs.com/package/slate">
<img src="https://img.shields.io/npm/dt/localeval.svg?maxAge=2592000">
<img src="https://img.shields.io/npm/dt/localeval.svg?maxAge=3600">
</a>
<a href="https://unpkg.com/slate/dist/slate.min.js">
<img src="http://img.badgesize.io/https://unpkg.com/slate/dist/slate.min.js?compression=gzip&amp;label=slate">
@@ -41,13 +41,13 @@
<img src="https://slate-slack.herokuapp.com/badge.svg">
<a/>
<a href="./packages/slate/package.json">
<img src="https://img.shields.io/npm/v/slate.svg?maxAge=2592000&label=slate&colorB=007ec6">
<img src="https://img.shields.io/npm/v/slate.svg?maxAge=3600&label=slate&colorB=007ec6">
</a>
<a href="./packages/slate-react/package.json">
<img src="https://img.shields.io/npm/v/slate-react.svg?maxAge=2592000&label=slate-react&colorB=007ec6">
<img src="https://img.shields.io/npm/v/slate-react.svg?maxAge=3600&label=slate-react&colorB=007ec6">
</a>
<a href="./License.md">
<img src="https://img.shields.io/npm/l/slate.svg?maxAge=2592000">
<img src="https://img.shields.io/npm/l/slate.svg?maxAge=3600">
</a>
</p>
<br/>
@@ -153,7 +153,7 @@ Slate encourages you to write small, reusable modules. Check out the public ones
- [`slate-prism`](https://github.com/GitbookIO/slate-prism) highlights code blocks with [Prism.js](http://prismjs.com/)!
- [`slate-soft-break`](https://github.com/ianstormtaylor/slate-soft-break) adds a soft break when `enter` is pressed.
- [`slate-drop-or-paste-images`](https://github.com/ianstormtaylor/slate-drop-or-paste-images) lets users drop or paste images to insert them!
- [**See all the plugins...**](https://yarnpkg.com/en/packages?q=slate)
- [**See all the plugins...**](./docs/general/plugins.md)
<br/>

View File

@@ -93,7 +93,7 @@ Slate encourages you to write small, reusable modules. Check out the public ones
- [`slate-prism`](https://github.com/GitbookIO/slate-prism) highlights code blocks with [Prism.js](http://prismjs.com/)!
- [`slate-soft-break`](https://github.com/ianstormtaylor/slate-soft-break) adds a soft break when `enter` is pressed.
- [`slate-drop-or-paste-images`](https://github.com/ianstormtaylor/slate-drop-or-paste-images) lets users drop or paste images to insert them!
- [**View all plugins on `npm`...**](https://www.npmjs.com/browse/keyword/slate)
- [**View all plugins...**](https://github.com/ianstormtaylor/slate/blob/master/docs/general/plugins.md)
## Documentation

View File

@@ -24,6 +24,7 @@
## General
- [Plugins](./general/plugins.md)
- [Resources](./general/resources.md)
- [Contributing](../Contributing.md)
- [Changelog](../Changelog.md)

58
docs/general/plugins.md Normal file
View File

@@ -0,0 +1,58 @@
# Plugins
Here's a list of Slate plugins, organized by category, so that they're easier to find than searching NPM or Yarn.
### Behavior
Plugins that add specific behaviors to your editor.
|**Plugin**|**Description**|**Downloads**|
|---|---|---|
|[`slate-auto-replace`](https://yarnpkg.com/en/package/slate-auto-replace)|Automatically transform certain input as a user types.|![](https://img.shields.io/npm/dm/slate-auto-replace.svg?maxAge=3600&label=⬇)|
|[`slate-collapse-on-escape`](https://yarnpkg.com/en/package/slate-collapse-on-escape)|Collapse the selection when users hit <kbd>esc</kbd>.|![](https://img.shields.io/npm/dm/slate-collapse-on-escape.svg?maxAge=3600&label=⬇)|
|[`slate-drop-or-paste-images`](https://yarnpkg.com/en/package/slate-drop-or-paste-images)|Allows users to insert images by drag-dropping or copy-pasting.|![](https://img.shields.io/npm/dm/slate-drop-or-paste-images.svg?maxAge=3600&label=⬇)|
|[`slate-edit-blockquote`](https://yarnpkg.com/en/package/slate-edit-blockquote)|Adds blockquote editing behaviors to an editor.|![](https://img.shields.io/npm/dm/slate-edit-blockquote.svg?maxAge=3600&label=⬇)|
|[`slate-edit-code`](https://yarnpkg.com/en/package/slate-edit-code)|Adds code block editing behaviors to an editor.|![](https://img.shields.io/npm/dm/slate-edit-code.svg?maxAge=3600&label=⬇)|
|[`slate-edit-footnote`](https://yarnpkg.com/en/package/slate-edit-footnote)|Adds footnote editing behaviors to an editor.|![](https://img.shields.io/npm/dm/slate-edit-footnote.svg?maxAge=3600&label=⬇)|
|[`slate-edit-list`](https://yarnpkg.com/en/package/slate-edit-list)|Adds list editing behaviors to an editor.|![](https://img.shields.io/npm/dm/slate-edit-list.svg?maxAge=3600&label=⬇)|
|[`slate-edit-table`](https://yarnpkg.com/en/package/slate-edit-table)|Adds common table editing behaviors to an editor.|![](https://img.shields.io/npm/dm/slate-edit-table.svg?maxAge=3600&label=⬇)|
|[`slate-mentions`](https://yarnpkg.com/en/package/slate-mentions)|Adds mentions like Facebook's to an editor.|![](https://img.shields.io/npm/dm/slate-mentions.svg?maxAge=3600&label=⬇)|
|[`slate-no-empty`](https://yarnpkg.com/en/package/slate-no-empty)|Prevents documents from being empty.|![](https://img.shields.io/npm/dm/slate-no-empty.svg?maxAge=3600&label=⬇)|
|[`slate-paste-linkify`](https://yarnpkg.com/en/package/slate-paste-linkify)|Automatically linkify URLs when they are pasted.|![](https://img.shields.io/npm/dm/slate-paste-linkify.svg?maxAge=3600&label=⬇)|
|[`slate-soft-break`](https://yarnpkg.com/en/package/slate-soft-break)|Adds soft breaks when users hit <kbd>enter</kbd>.|![](https://img.shields.io/npm/dm/slate-soft-break.svg?maxAge=3600&label=⬇)|
|[`slate-sticky-inlines`](https://yarnpkg.com/en/package/slate-sticky-inlines)|Changes the inline node behavior to allow editing at the edges.|![](https://img.shields.io/npm/dm/slate-sticky-inlines.svg?maxAge=3600&label=⬇)|
|[`slate-suggestions`](https://yarnpkg.com/en/package/slate-suggestions)|Displays inline auto-completed suggestions.|![](https://img.shields.io/npm/dm/slate-suggestions.svg?maxAge=3600&label=⬇)|
|[`slate-trailing-block`](https://yarnpkg.com/en/package/slate-trailing-block)|Ensure that documents end in a specific kind of block.|![](https://img.shields.io/npm/dm/slate-trailing-block.svg?maxAge=3600&label=⬇)|
### Components
Components for building Slate editors.
|**Plugin**|**Description**|**Downloads**|
|---|---|---|
|[`slate-editor-icons`](https://yarnpkg.com/en/package/slate-editor-icons)|A set of icons for using in toolbars, etc.|![](https://img.shields.io/npm/dm/slate-editor-icons.svg?maxAge=3600&label=⬇)|
### Serializers
Serializers for handling Slate data.
|**Plugin**|**Description**|**Downloads**|
|---|---|---|
|[`slate-base64-serializer`](https://yarnpkg.com/en/package/slate-base64-serializer)|A base64 string serializer for Slate documents.|![](https://img.shields.io/npm/dm/slate-base64-serializer.svg?maxAge=3600&label=⬇)|
|[`slate-html-serializer`](https://yarnpkg.com/en/package/slate-html-serializer)|An HTML serializer for Slate documents.|![](https://img.shields.io/npm/dm/slate-html-serializer.svg?maxAge=3600&label=⬇)|
|[`slate-plain-serializer`](https://yarnpkg.com/en/package/slate-plain-serializer)|A plain text serializer for Slate documents.|![](https://img.shields.io/npm/dm/slate-plain-serializer.svg?maxAge=3600&label=⬇)|
### Utils
Useful utilities when working with Slate documents and components.
|**Plugin**|**Description**|**Downloads**|
|---|---|---|
|[`slate-hyperprint`](https://yarnpkg.com/en/package/slate-hyperprint)|Prints Slate documents in their `slate-hyperscript` format.|![](https://img.shields.io/npm/dm/slate-hyperprint.svg?maxAge=3600&label=⬇)|
|[`slate-hyperscript`](https://yarnpkg.com/en/package/slate-hyperscript)|Allows you to express Slate documents in JSX.|![](https://img.shields.io/npm/dm/slate-hyperscript.svg?maxAge=3600&label=⬇)|
|[`slate-prop-types`](https://yarnpkg.com/en/package/slate-prop-types)|A set of prop types to use in your Slate components.|![](https://img.shields.io/npm/dm/slate-prop-types.svg?maxAge=3600&label=⬇)|

View File

@@ -6,6 +6,7 @@ import React from 'react'
import getWindow from 'get-window'
import { Block, Inline, Text } from 'slate'
import { IS_IOS } from '../constants/environment'
import EVENT_HANDLERS from '../constants/event-handlers'
import HOTKEYS from '../constants/hotkeys'
import Content from '../components/content'
@@ -362,17 +363,20 @@ function AfterPlugin() {
const { value } = change
if (HOTKEYS.SPLIT_BLOCK(event)) {
// COMPAT: In iOS, some of these hotkeys are handled in the
// `onNativeBeforeInput` handler of the `<Content>` component in order to
// preserve native autocorrect behavior, so they shouldn't be handled here.
if (HOTKEYS.SPLIT_BLOCK(event) && !IS_IOS) {
return value.isInVoid
? change.collapseToStartOfNextText()
: change.splitBlock()
}
if (HOTKEYS.DELETE_CHAR_BACKWARD(event)) {
if (HOTKEYS.DELETE_CHAR_BACKWARD(event) && !IS_IOS) {
return change.deleteCharBackward()
}
if (HOTKEYS.DELETE_CHAR_FORWARD(event)) {
if (HOTKEYS.DELETE_CHAR_FORWARD(event) && !IS_IOS) {
return change.deleteCharForward()
}