mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-30 10:29:48 +02:00
This reverts commit 9c758bb4cb
.
This commit is contained in:
@@ -1736,4 +1736,3 @@ export type NodeMatch<T extends Node> =
|
|||||||
| ((node: Node, path: Path) => boolean)
|
| ((node: Node, path: Path) => boolean)
|
||||||
|
|
||||||
export type PropsCompare = (prop: Partial<Node>, node: Partial<Node>) => boolean
|
export type PropsCompare = (prop: Partial<Node>, node: Partial<Node>) => boolean
|
||||||
export type PropsMerge = (prop: Partial<Node>, node: Partial<Node>) => object
|
|
||||||
|
@@ -11,7 +11,7 @@ import {
|
|||||||
NodeEntry,
|
NodeEntry,
|
||||||
Ancestor,
|
Ancestor,
|
||||||
} from '..'
|
} from '..'
|
||||||
import { NodeMatch, PropsCompare, PropsMerge } from '../interfaces/editor'
|
import { NodeMatch, PropsCompare } from '../interfaces/editor'
|
||||||
|
|
||||||
export interface NodeTransforms {
|
export interface NodeTransforms {
|
||||||
insertNodes: <T extends Node>(
|
insertNodes: <T extends Node>(
|
||||||
@@ -76,7 +76,6 @@ export interface NodeTransforms {
|
|||||||
split?: boolean
|
split?: boolean
|
||||||
voids?: boolean
|
voids?: boolean
|
||||||
compare?: PropsCompare
|
compare?: PropsCompare
|
||||||
merge?: PropsMerge
|
|
||||||
}
|
}
|
||||||
) => void
|
) => void
|
||||||
splitNodes: <T extends Node>(
|
splitNodes: <T extends Node>(
|
||||||
@@ -571,11 +570,10 @@ export const NodeTransforms: NodeTransforms = {
|
|||||||
split?: boolean
|
split?: boolean
|
||||||
voids?: boolean
|
voids?: boolean
|
||||||
compare?: PropsCompare
|
compare?: PropsCompare
|
||||||
merge?: PropsMerge
|
|
||||||
} = {}
|
} = {}
|
||||||
): void {
|
): void {
|
||||||
Editor.withoutNormalizing(editor, () => {
|
Editor.withoutNormalizing(editor, () => {
|
||||||
let { match, at = editor.selection, compare, merge } = options
|
let { match, at = editor.selection, compare } = options
|
||||||
const {
|
const {
|
||||||
hanging = false,
|
hanging = false,
|
||||||
mode = 'lowest',
|
mode = 'lowest',
|
||||||
@@ -662,11 +660,7 @@ export const NodeTransforms: NodeTransforms = {
|
|||||||
// Omit new properties from the old properties list
|
// Omit new properties from the old properties list
|
||||||
if (node.hasOwnProperty(k)) properties[k] = node[k]
|
if (node.hasOwnProperty(k)) properties[k] = node[k]
|
||||||
// Omit properties that have been removed from the new properties list
|
// Omit properties that have been removed from the new properties list
|
||||||
if (merge) {
|
if (props[k] != null) newProperties[k] = props[k]
|
||||||
if (props[k] != null) newProperties[k] = merge(node[k], props[k])
|
|
||||||
} else {
|
|
||||||
if (props[k] != null) newProperties[k] = props[k]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
/** @jsx jsx */
|
|
||||||
import { Transforms, Text } from 'slate'
|
|
||||||
import { jsx } from '../../..'
|
|
||||||
import _ from 'lodash'
|
|
||||||
|
|
||||||
export const run = editor => {
|
|
||||||
Transforms.setNodes(
|
|
||||||
editor,
|
|
||||||
{ a: { b: 2, c: 3 } },
|
|
||||||
{ at: [0, 0], match: Text.isText, merge: (n, p) => _.defaultsDeep(p, n) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export const input = (
|
|
||||||
<editor>
|
|
||||||
<block>
|
|
||||||
<text a={{ b: 1 }}>word</text>
|
|
||||||
</block>
|
|
||||||
</editor>
|
|
||||||
)
|
|
||||||
export const output = (
|
|
||||||
<editor>
|
|
||||||
<block>
|
|
||||||
<text a={{ b: 2, c: 3 }}>word</text>
|
|
||||||
</block>
|
|
||||||
</editor>
|
|
||||||
)
|
|
Reference in New Issue
Block a user