mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-28 17:39:57 +02:00
remove leaves (#2715)
* first stab at removing leaves with tests passing * add deprecation warning for creating texts with leaves * fixes * update examples
This commit is contained in:
@@ -20,13 +20,8 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -15,17 +15,12 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
text: '',
|
||||
marks: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: '',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -15,17 +15,12 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
text: 'word',
|
||||
marks: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'word',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
44
packages/slate-hyperscript/test/fixtures/block-mark-multiple.js
vendored
Normal file
44
packages/slate-hyperscript/test/fixtures/block-mark-multiple.js
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
<block type="paragraph">
|
||||
<mark type="bold">one</mark>two<mark type="italic">three</mark>
|
||||
</block>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
object: 'block',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
text: 'one',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: 'three',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'italic',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
@@ -4,9 +4,11 @@ import h from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
<block type="paragraph">
|
||||
<mark type="bold">w</mark>
|
||||
<mark type="bold">
|
||||
w<mark type="italic">or</mark>d
|
||||
<mark type="italic">or</mark>
|
||||
</mark>
|
||||
<mark type="bold">d</mark>
|
||||
</block>
|
||||
)
|
||||
|
||||
@@ -17,44 +19,39 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
text: 'w',
|
||||
marks: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'w',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: 'or',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'italic',
|
||||
data: {},
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'or',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'italic',
|
||||
data: {},
|
||||
},
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: 'd',
|
||||
marks: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'd',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -11,13 +11,8 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@@ -15,13 +15,8 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@@ -15,13 +15,8 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@@ -33,13 +33,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -44,13 +44,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'inline',
|
||||
@@ -61,26 +56,16 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '1',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '3',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -93,13 +78,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '5',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'inline',
|
||||
@@ -110,26 +90,16 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '6',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '8',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -36,13 +36,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -55,13 +50,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -36,13 +36,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -55,13 +50,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -36,13 +36,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -55,13 +50,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
81
packages/slate-hyperscript/test/fixtures/cursor-across-empty-blocks.js
vendored
Normal file
81
packages/slate-hyperscript/test/fixtures/cursor-across-empty-blocks.js
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<block type="paragraph">
|
||||
<text>
|
||||
<anchor />
|
||||
</text>
|
||||
</block>
|
||||
<block type="paragraph">
|
||||
<text>
|
||||
<focus />
|
||||
</text>
|
||||
</block>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const options = {
|
||||
preserveSelection: true,
|
||||
preserveKeys: true,
|
||||
}
|
||||
|
||||
export const output = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
key: '4',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '1',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
key: '3',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
selection: {
|
||||
object: 'selection',
|
||||
anchor: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 0,
|
||||
},
|
||||
focus: {
|
||||
object: 'point',
|
||||
key: '2',
|
||||
path: [1, 0],
|
||||
offset: 0,
|
||||
},
|
||||
isFocused: true,
|
||||
marks: null,
|
||||
},
|
||||
}
|
@@ -37,13 +37,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -56,13 +51,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -75,13 +65,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '4',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -37,13 +37,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -56,13 +51,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -75,13 +65,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '4',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -37,13 +37,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -56,13 +51,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -75,13 +65,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '4',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -33,13 +33,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -33,13 +33,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -33,13 +33,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -39,13 +39,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
62
packages/slate-hyperscript/test/fixtures/cursor-empty-text-with-key.js
vendored
Normal file
62
packages/slate-hyperscript/test/fixtures/cursor-empty-text-with-key.js
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<block type="paragraph">
|
||||
<text key="a">
|
||||
<cursor />
|
||||
</text>
|
||||
</block>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const options = {
|
||||
preserveSelection: true,
|
||||
preserveKeys: true,
|
||||
}
|
||||
|
||||
export const output = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
key: '2',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '1',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: 'a',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
selection: {
|
||||
object: 'selection',
|
||||
anchor: {
|
||||
object: 'point',
|
||||
key: 'a',
|
||||
path: [0, 0],
|
||||
offset: 0,
|
||||
},
|
||||
focus: {
|
||||
object: 'point',
|
||||
key: 'a',
|
||||
path: [0, 0],
|
||||
offset: 0,
|
||||
},
|
||||
isFocused: true,
|
||||
marks: null,
|
||||
},
|
||||
}
|
62
packages/slate-hyperscript/test/fixtures/cursor-empty-text.js
vendored
Normal file
62
packages/slate-hyperscript/test/fixtures/cursor-empty-text.js
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<block type="paragraph">
|
||||
<text>
|
||||
<cursor />
|
||||
</text>
|
||||
</block>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const options = {
|
||||
preserveSelection: true,
|
||||
preserveKeys: true,
|
||||
}
|
||||
|
||||
export const output = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
key: '2',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '1',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
selection: {
|
||||
object: 'selection',
|
||||
anchor: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 0,
|
||||
},
|
||||
focus: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 0,
|
||||
},
|
||||
isFocused: true,
|
||||
marks: null,
|
||||
},
|
||||
}
|
@@ -37,13 +37,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'inline',
|
||||
@@ -54,26 +49,16 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '3',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -37,13 +37,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'inline',
|
||||
@@ -54,26 +49,16 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '3',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -37,13 +37,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'inline',
|
||||
@@ -54,26 +49,16 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '3',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -33,13 +33,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
73
packages/slate-hyperscript/test/fixtures/cursor-mark-after.js
vendored
Normal file
73
packages/slate-hyperscript/test/fixtures/cursor-mark-after.js
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<block type="paragraph">
|
||||
<mark type="bold">one</mark>
|
||||
<cursor />two
|
||||
</block>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const options = {
|
||||
preserveSelection: true,
|
||||
preserveKeys: true,
|
||||
}
|
||||
|
||||
export const output = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
data: {},
|
||||
key: '3',
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '2',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
text: 'one',
|
||||
key: '0',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '1',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
selection: {
|
||||
object: 'selection',
|
||||
anchor: {
|
||||
object: 'point',
|
||||
key: '1',
|
||||
path: [0, 1],
|
||||
offset: 0,
|
||||
},
|
||||
focus: {
|
||||
object: 'point',
|
||||
key: '1',
|
||||
path: [0, 1],
|
||||
offset: 0,
|
||||
},
|
||||
isFocused: true,
|
||||
marks: null,
|
||||
},
|
||||
}
|
@@ -26,41 +26,38 @@ export const output = {
|
||||
document: {
|
||||
object: 'document',
|
||||
data: {},
|
||||
key: '2',
|
||||
key: '4',
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '1',
|
||||
key: '3',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: '1',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: 'two',
|
||||
key: '0',
|
||||
leaves: [
|
||||
marks: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -70,14 +67,14 @@ export const output = {
|
||||
anchor: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 6,
|
||||
path: [0, 1],
|
||||
offset: 3,
|
||||
},
|
||||
focus: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 6,
|
||||
path: [0, 1],
|
||||
offset: 3,
|
||||
},
|
||||
isFocused: true,
|
||||
marks: null,
|
||||
|
@@ -26,41 +26,38 @@ export const output = {
|
||||
document: {
|
||||
object: 'document',
|
||||
data: {},
|
||||
key: '2',
|
||||
key: '4',
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '1',
|
||||
key: '3',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: '1',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
text: 'two',
|
||||
marks: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -70,14 +67,14 @@ export const output = {
|
||||
anchor: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 3,
|
||||
path: [0, 1],
|
||||
offset: 0,
|
||||
},
|
||||
focus: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 3,
|
||||
path: [0, 1],
|
||||
offset: 0,
|
||||
},
|
||||
isFocused: true,
|
||||
marks: null,
|
||||
|
@@ -26,41 +26,38 @@ export const output = {
|
||||
document: {
|
||||
object: 'document',
|
||||
data: {},
|
||||
key: '2',
|
||||
key: '4',
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '1',
|
||||
key: '3',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: '1',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
text: 'two',
|
||||
marks: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
text: 'three',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -70,14 +67,14 @@ export const output = {
|
||||
anchor: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 4,
|
||||
path: [0, 1],
|
||||
offset: 1,
|
||||
},
|
||||
focus: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
path: [0, 0],
|
||||
offset: 4,
|
||||
path: [0, 1],
|
||||
offset: 1,
|
||||
},
|
||||
isFocused: true,
|
||||
marks: null,
|
||||
|
@@ -33,13 +33,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
68
packages/slate-hyperscript/test/fixtures/custom-marks-with-text.js
vendored
Normal file
68
packages/slate-hyperscript/test/fixtures/custom-marks-with-text.js
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/** @jsx h */
|
||||
|
||||
import { createHyperscript } from 'slate-hyperscript'
|
||||
|
||||
const h = createHyperscript({
|
||||
blocks: {
|
||||
paragraph: 'paragraph',
|
||||
},
|
||||
marks: {
|
||||
b: 'bold',
|
||||
},
|
||||
})
|
||||
|
||||
export const input = (
|
||||
<value>
|
||||
<document>
|
||||
<paragraph>
|
||||
<text>one</text>
|
||||
<b>two</b>
|
||||
<b>three</b>
|
||||
</paragraph>
|
||||
</document>
|
||||
</value>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: 'two',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: 'three',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
@@ -40,30 +40,25 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
text: 'A string of ',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: 'bold',
|
||||
marks: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'A string of ',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'bold',
|
||||
marks: [
|
||||
{
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'leaf',
|
||||
text: ' in a ',
|
||||
marks: [],
|
||||
object: 'mark',
|
||||
type: 'bold',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
text: ' in a ',
|
||||
marks: [],
|
||||
},
|
||||
{
|
||||
object: 'inline',
|
||||
type: 'link',
|
||||
@@ -73,25 +68,15 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'Slate',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'Slate',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: ' editor!',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: ' editor!',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -30,25 +30,20 @@ export const output = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
key: '2',
|
||||
key: '3',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '1',
|
||||
key: '2',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'onetwothree',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
key: '1',
|
||||
text: 'onetwothree',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -59,13 +54,13 @@ export const output = {
|
||||
object: 'decoration',
|
||||
anchor: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
key: '1',
|
||||
path: [0, 0],
|
||||
offset: 3,
|
||||
},
|
||||
focus: {
|
||||
object: 'point',
|
||||
key: '0',
|
||||
key: '1',
|
||||
path: [0, 0],
|
||||
offset: 6,
|
||||
},
|
||||
|
@@ -45,13 +45,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '0',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'one',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -64,13 +59,8 @@ export const output = {
|
||||
{
|
||||
object: 'text',
|
||||
key: '2',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -11,13 +11,8 @@ export const output = {
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@@ -25,25 +25,20 @@ export const output = {
|
||||
object: 'value',
|
||||
document: {
|
||||
object: 'document',
|
||||
key: '1',
|
||||
key: '2',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'block',
|
||||
key: '0',
|
||||
key: '1',
|
||||
type: 'paragraph',
|
||||
data: {},
|
||||
nodes: [
|
||||
{
|
||||
object: 'text',
|
||||
key: 'a',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'two',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@@ -6,11 +6,6 @@ export const input = <text />
|
||||
|
||||
export const output = {
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: '',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: '',
|
||||
marks: [],
|
||||
}
|
||||
|
@@ -6,11 +6,6 @@ export const input = <text>word</text>
|
||||
|
||||
export const output = {
|
||||
object: 'text',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'word',
|
||||
marks: [],
|
||||
}
|
||||
|
15
packages/slate-hyperscript/test/fixtures/text-nested.js
vendored
Normal file
15
packages/slate-hyperscript/test/fixtures/text-nested.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/** @jsx h */
|
||||
|
||||
import h from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
<text>
|
||||
<text>word</text>
|
||||
</text>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
object: 'text',
|
||||
text: 'word',
|
||||
marks: [],
|
||||
}
|
@@ -11,11 +11,6 @@ export const options = {
|
||||
export const output = {
|
||||
object: 'text',
|
||||
key: 'a',
|
||||
leaves: [
|
||||
{
|
||||
object: 'leaf',
|
||||
text: 'word',
|
||||
marks: [],
|
||||
},
|
||||
],
|
||||
text: 'word',
|
||||
marks: [],
|
||||
}
|
||||
|
Reference in New Issue
Block a user