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

Export wrapBlockByKey and add tests

This commit is contained in:
Soreine
2016-10-27 14:51:45 +02:00
parent 6e0799010c
commit 6a77aa1cf3
7 changed files with 78 additions and 0 deletions

View File

@@ -96,6 +96,7 @@ import {
splitNodeByKey,
unwrapInlineByKey,
unwrapBlockByKey,
wrapBlockByKey,
} from './by-key'
/**
@@ -252,6 +253,7 @@ export default {
splitNodeByKey,
unwrapInlineByKey,
unwrapBlockByKey,
wrapBlockByKey,
/**
* On selection.

View File

@@ -0,0 +1,7 @@
export default function (state) {
return state
.transform()
.wrapBlockByKey('key', 'quote')
.apply()
}

View File

@@ -0,0 +1,16 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: block
key: 'key'
type: code
nodes:
- kind: text
text: some code
- kind: inline
type: link
nodes:
- kind: text
text: text

View File

@@ -0,0 +1,18 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: block
type: quote
nodes:
- kind: block
type: code
nodes:
- kind: text
text: some code
- kind: inline
type: link
nodes:
- kind: text
text: text

View File

@@ -0,0 +1,7 @@
export default function (state) {
return state
.transform()
.wrapBlockByKey('key', 'quote')
.apply()
}

View File

@@ -0,0 +1,13 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
key: 'key'
text: some
- kind: inline
type: link
nodes:
- kind: text
text: text

View File

@@ -0,0 +1,15 @@
nodes:
- kind: block
type: paragraph
nodes:
- kind: block
type: quote
nodes:
- kind: text
text: some
- kind: inline
type: link
nodes:
- kind: text
text: text