1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 02:19:52 +02:00

Remove deprecations (#2113)

#### Is this adding or improving a _feature_ or fixing a _bug_?

Debt.

#### What's the new behavior?

This removes almost all existing deprecations from previous API changes, to save on filesize and reduce complexity in the codebase going forward.

It also changes from using the `slate-dev-logger` to using the Facebook-inspired `slate-dev-warning` which can be compiled out of production builds with [`babel-plugin-dev-expression`](https://github.com/4Catalyzer/babel-plugin-dev-expression) to save even further on file size.

The only deprecations it keeps are in the `fromJSON` methods for data model changes like `.kind` and `.leaves` which may still may not have been migrated in databases, since this is a bigger pain point.

#### Have you checked that...?

* [x] The new code matches the existing patterns and styles.
* [x] The tests pass with `yarn test`.
* [x] The linter passes with `yarn lint`. (Fix errors with `yarn prettier`.)
* [x] The relevant examples still work. (Run examples with `yarn watch`.)

#### Does this fix any issues or need any specific reviewers?

Fixes: #1922 
Fixes: #2105
Fixes: #646 
Fixes: #2109
Fixes: #2107 
Fixes: #2018
This commit is contained in:
Ian Storm Taylor
2018-08-22 18:22:40 -07:00
committed by GitHub
parent 3d48f7a3e0
commit 36ed4397d8
223 changed files with 2767 additions and 4575 deletions

View File

@@ -4,6 +4,14 @@ This document maintains a list of changes to the `slate-hyperscript` package wit
---
### `0.10.0` — August 22, 2018
###### BREAKING
**Remove all previously deprecated code paths.** This helps to reduce some of the complexity in Slate by not having to handle these code paths anymore. And it helps to reduce file size. When upgrading, it's _highly_ recommended that you upgrade to the previous version first and ensure there are no deprecation warnings being logged, then upgrade to this version.
---
### `0.9.0` — August 22, 2018
###### NEW

View File

@@ -13,9 +13,7 @@
"lib/"
],
"dependencies": {
"is-empty": "^1.0.0",
"is-plain-object": "^2.0.4",
"slate-dev-logger": "^0.1.43"
"is-plain-object": "^2.0.4"
},
"peerDependencies": {
"slate": ">=0.37.0"

View File

@@ -7,7 +7,6 @@ import {
Mark,
Node,
Point,
Schema,
Selection,
Text,
Value,
@@ -173,7 +172,6 @@ const CREATORS = {
value(tagName, attributes, children) {
const { data, normalize = true } = attributes
const schema = Schema.create(attributes.schema || {})
const document = children.find(Document.isDocument)
let selection = children.find(Selection.isSelection) || Selection.create()
let anchor
@@ -263,7 +261,7 @@ const CREATORS = {
}
let value = Value.fromJSON(
{ data, document, selection, schema },
{ data, document, selection, ...attributes },
{ normalize }
)
@@ -471,19 +469,19 @@ function resolveCreators(options) {
}
Object.keys(blocks).map(key => {
creators[key] = normalizeNode(key, blocks[key], 'block')
creators[key] = normalizeNode(blocks[key], 'block')
})
Object.keys(inlines).map(key => {
creators[key] = normalizeNode(key, inlines[key], 'inline')
creators[key] = normalizeNode(inlines[key], 'inline')
})
Object.keys(marks).map(key => {
creators[key] = normalizeMark(key, marks[key])
creators[key] = normalizeMark(marks[key])
})
Object.keys(decorations).map(key => {
creators[key] = normalizeNode(key, decorations[key], 'decoration')
creators[key] = normalizeNode(decorations[key], 'decoration')
})
creators.value = (tagName, attributes = {}, children) => {
@@ -495,15 +493,14 @@ function resolveCreators(options) {
}
/**
* Normalize a node creator with `key` and `value`, of `object`.
* Normalize a node creator of `value` and `object`.
*
* @param {String} key
* @param {Function|Object|String} value
* @param {String} object
* @return {Function}
*/
function normalizeNode(key, value, object) {
function normalizeNode(value, object) {
if (typeof value == 'function') {
return value
}
@@ -514,11 +511,11 @@ function normalizeNode(key, value, object) {
if (isPlainObject(value)) {
return (tagName, attributes, children) => {
const { key: attrKey, ...rest } = attributes
const { key, ...rest } = attributes
const attrs = {
...value,
object,
key: attrKey,
key,
data: {
...(value.data || {}),
...rest,
@@ -535,14 +532,13 @@ function normalizeNode(key, value, object) {
}
/**
* Normalize a mark creator with `key` and `value`.
* Normalize a mark creator of `value`.
*
* @param {String} key
* @param {Function|Object|String} value
* @return {Function}
*/
function normalizeMark(key, value) {
function normalizeMark(value) {
if (typeof value == 'function') {
return value
}

View File

@@ -33,7 +33,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -51,7 +50,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -37,7 +37,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -36,13 +36,11 @@ export const output = {
{
object: 'block',
type: 'ul',
isVoid: false,
data: {},
nodes: [
{
object: 'block',
type: 'li',
isVoid: false,
data: {},
nodes: [
{
@@ -60,7 +58,6 @@ export const output = {
{
object: 'block',
type: 'li',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -37,7 +37,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -33,7 +33,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -51,7 +50,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -33,7 +33,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -51,7 +50,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -15,7 +15,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -28,7 +28,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -35,7 +35,6 @@ export const output = {
object: 'block',
key: '3',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -53,7 +52,6 @@ export const output = {
object: 'inline',
key: '1',
type: 'link',
isVoid: false,
data: {},
nodes: [
{
@@ -86,7 +84,6 @@ export const output = {
object: 'block',
key: '7',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -104,7 +101,6 @@ export const output = {
object: 'inline',
key: '5',
type: 'link',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -31,7 +31,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -51,7 +50,6 @@ export const output = {
object: 'block',
key: '3',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -31,7 +31,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -51,7 +50,6 @@ export const output = {
object: 'block',
key: '3',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -31,7 +31,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -51,7 +50,6 @@ export const output = {
object: 'block',
key: '3',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -52,7 +51,6 @@ export const output = {
object: 'block',
key: '3',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -72,7 +70,6 @@ export const output = {
object: 'block',
key: '5',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -52,7 +51,6 @@ export const output = {
object: 'block',
key: '3',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -72,7 +70,6 @@ export const output = {
object: 'block',
key: '5',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -52,7 +51,6 @@ export const output = {
object: 'block',
key: '3',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -72,7 +70,6 @@ export const output = {
object: 'block',
key: '5',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -28,7 +28,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -28,7 +28,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -28,7 +28,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -34,7 +34,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '4',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -50,7 +49,6 @@ export const output = {
object: 'inline',
key: '1',
type: 'link',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '4',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -50,7 +49,6 @@ export const output = {
object: 'inline',
key: '1',
type: 'link',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '4',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -50,7 +49,6 @@ export const output = {
object: 'inline',
key: '1',
type: 'link',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -5,10 +5,7 @@ import { createHyperscript } from 'slate-hyperscript'
const h = createHyperscript({
blocks: {
paragraph: 'paragraph',
image: {
type: 'image',
isVoid: true,
},
image: 'image',
},
inlines: {
link: 'link',
@@ -39,7 +36,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -71,7 +67,6 @@ export const output = {
{
object: 'inline',
type: 'link',
isVoid: false,
data: {
src: 'http://slatejs.org',
},
@@ -103,7 +98,6 @@ export const output = {
{
object: 'block',
type: 'image',
isVoid: true,
data: {
src: 'https://...',
},

View File

@@ -40,7 +40,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -60,7 +59,6 @@ export const output = {
object: 'block',
key: '3',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -37,7 +37,6 @@ export const output = {
object: 'block',
key: '1',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -17,7 +17,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -20,7 +20,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -20,7 +20,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -32,7 +32,6 @@ export const output = {
object: 'block',
key: '0',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{

View File

@@ -24,7 +24,6 @@ export const output = {
object: 'block',
key: '4',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -43,7 +42,6 @@ export const output = {
key: '1',
type: 'link',
data: {},
isVoid: false,
nodes: [
{
object: 'text',

View File

@@ -12,7 +12,7 @@ export const input = (
</inline>{' '}
editor!
</block>
<block type="image" data={{ src: 'https://...' }} isVoid />
<block type="image" data={{ src: 'https://...' }} />
</document>
</value>
)
@@ -26,7 +26,6 @@ export const output = {
{
object: 'block',
type: 'paragraph',
isVoid: false,
data: {},
nodes: [
{
@@ -58,7 +57,6 @@ export const output = {
{
object: 'inline',
type: 'link',
isVoid: false,
data: {
src: 'http://slatejs.org',
},
@@ -90,7 +88,6 @@ export const output = {
{
object: 'block',
type: 'image',
isVoid: true,
data: {
src: 'https://...',
},