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:
@@ -96,6 +96,7 @@ import {
|
||||
splitNodeByKey,
|
||||
unwrapInlineByKey,
|
||||
unwrapBlockByKey,
|
||||
wrapBlockByKey,
|
||||
} from './by-key'
|
||||
|
||||
/**
|
||||
@@ -252,6 +253,7 @@ export default {
|
||||
splitNodeByKey,
|
||||
unwrapInlineByKey,
|
||||
unwrapBlockByKey,
|
||||
wrapBlockByKey,
|
||||
|
||||
/**
|
||||
* On selection.
|
||||
|
@@ -0,0 +1,7 @@
|
||||
|
||||
export default function (state) {
|
||||
return state
|
||||
.transform()
|
||||
.wrapBlockByKey('key', 'quote')
|
||||
.apply()
|
||||
}
|
@@ -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
|
@@ -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
|
@@ -0,0 +1,7 @@
|
||||
|
||||
export default function (state) {
|
||||
return state
|
||||
.transform()
|
||||
.wrapBlockByKey('key', 'quote')
|
||||
.apply()
|
||||
}
|
@@ -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
|
@@ -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
|
Reference in New Issue
Block a user