@@ -16,16 +16,15 @@ export const setBlockNode = (
16
16
const { at : location , key } = options ;
17
17
if ( ! node ) {
18
18
// 注意`setNodes Match`的查找顺序可能与直觉不一致 顺序是由顶`Editor`至底`Node`
19
- // https://github.com/ianstormtaylor/slate/blob/25be3b/packages/slate/src/transforms/node.ts#L565
20
19
// 因此这里需要使用`Editor.above`实现更精确的查找 再将`node`直接传入来精确变换
21
- // https://github.com/ianstormtaylor/slate/blob/25be3b/packages/slate/src/interfaces/editor.ts#L334
22
20
const above = getAboveNode ( editor , {
23
21
at : location ,
24
22
match : node => isBlock ( editor , node ) && ( key ? existKey ( node , key ) : true ) ,
25
23
} ) ;
26
24
if ( above && above . node ) node = above . node as BlockElement ;
27
25
}
28
26
if ( ! node ) return void 0 ;
27
+ // https://github.com/ianstormtaylor/slate/blob/25be3b/packages/slate/src/transforms/node.ts#L565
29
28
Transforms . setNodes ( editor , config , { match : n => n === node , at : location } ) ;
30
29
} ;
31
30
@@ -92,10 +91,10 @@ export const setWrapNodes = (
92
91
} = { }
93
92
) => {
94
93
const { at } = options ;
95
- const config = { ...wrapConfig } as BlockElement ;
96
94
Editor . withoutNormalizing ( editor , ( ) => {
97
- Transforms . wrapNodes ( editor , config , { match : n => isBlock ( editor , n ) , at } ) ;
98
- setBlockNode ( editor , itemConfig , { at } ) ;
95
+ // 配合`Normalizer`在此处的规则是新建内层`Node`
96
+ setBlockNode ( editor , wrapConfig , { at } ) ;
97
+ Transforms . wrapNodes ( editor , itemConfig as BlockElement , { match : isText , at } ) ;
99
98
} ) ;
100
99
} ;
101
100
0 commit comments