diff --git a/packages/slate/src/transforms/general.ts b/packages/slate/src/transforms/general.ts index b737e1c2b..c5e769d38 100755 --- a/packages/slate/src/transforms/general.ts +++ b/packages/slate/src/transforms/general.ts @@ -248,7 +248,6 @@ export const GeneralTransforms: GeneralTransforms = { const after = node.text.slice(position) node.text = before newNode = { - ...node, ...(properties as Partial), text: after, } @@ -258,7 +257,6 @@ export const GeneralTransforms: GeneralTransforms = { node.children = before newNode = { - ...node, ...(properties as Partial), children: after, } diff --git a/packages/slate/test/operations/split_node/element-empty-properties.tsx b/packages/slate/test/operations/split_node/element-empty-properties.tsx new file mode 100644 index 000000000..b405ba153 --- /dev/null +++ b/packages/slate/test/operations/split_node/element-empty-properties.tsx @@ -0,0 +1,30 @@ +/** @jsx jsx */ +import { jsx } from '../..' + +export const input = ( + + + before text + hyperlink + after text + + +) +export const operations = [ + { + type: 'split_node', + path: [0], + position: 1, + properties: {}, + }, +] +export const output = ( + + before text + + + hyperlink + after text + + +) diff --git a/packages/slate/test/operations/split_node/element.tsx b/packages/slate/test/operations/split_node/element.tsx new file mode 100644 index 000000000..d6f6120ee --- /dev/null +++ b/packages/slate/test/operations/split_node/element.tsx @@ -0,0 +1,32 @@ +/** @jsx jsx */ +import { jsx } from '../..' + +export const input = ( + + + before text + hyperlink + after text + + +) +export const operations = [ + { + type: 'split_node', + path: [0], + position: 1, + properties: { + data: true, + }, + }, +] +export const output = ( + + before text + + + hyperlink + after text + + +) diff --git a/packages/slate/test/operations/split_node/text-empty-properties.tsx b/packages/slate/test/operations/split_node/text-empty-properties.tsx new file mode 100644 index 000000000..13445a9e1 --- /dev/null +++ b/packages/slate/test/operations/split_node/text-empty-properties.tsx @@ -0,0 +1,26 @@ +/** @jsx jsx */ +import { jsx } from '../..' + +export const input = ( + + + some text + + +) +export const operations = [ + { + type: 'split_node', + path: [0, 0], + position: 5, + properties: {}, + }, +] +export const output = ( + + + some + text + + +) diff --git a/packages/slate/test/operations/split_node/text.tsx b/packages/slate/test/operations/split_node/text.tsx new file mode 100644 index 000000000..1939532b3 --- /dev/null +++ b/packages/slate/test/operations/split_node/text.tsx @@ -0,0 +1,36 @@ +/** @jsx jsx */ +import { jsx } from '../..' + +export const input = ( + + + some text + + +) +export const operations = [ + { + type: 'split_node', + path: [0, 0], + position: 5, + properties: { + bold: true, + }, + }, + { + type: 'split_node', + path: [0], + position: 1, + properties: {}, + }, +] +export const output = ( + + + some + + + text + + +) diff --git a/packages/slate/test/transforms/splitNodes/path/block-with-attributes.tsx b/packages/slate/test/transforms/splitNodes/path/block-with-attributes.tsx new file mode 100644 index 000000000..ef34925e0 --- /dev/null +++ b/packages/slate/test/transforms/splitNodes/path/block-with-attributes.tsx @@ -0,0 +1,32 @@ +/** @jsx jsx */ +import { Transforms } from 'slate' +import { jsx } from '../../..' + +export const run = editor => { + Transforms.splitNodes(editor, { at: [0, 2] }) +} +export const input = ( + + + + one + + two + + + +) +export const output = ( + + + + one + + + + + two + + + +) diff --git a/packages/slate/test/transforms/splitNodes/point/text-with-marks.tsx b/packages/slate/test/transforms/splitNodes/point/text-with-marks.tsx new file mode 100644 index 000000000..2acd4caf3 --- /dev/null +++ b/packages/slate/test/transforms/splitNodes/point/text-with-marks.tsx @@ -0,0 +1,26 @@ +/** @jsx jsx */ +import { Editor, Transforms } from 'slate' +import { jsx } from '../../..' + +export const run = editor => { + Transforms.splitNodes(editor, { + at: { path: [0, 0], offset: 2 }, + }) +} +export const input = ( + + + word + + +) +export const output = ( + + + wo + + + rd + + +)