|
|
@@ -676,5 +676,52 @@ describe( 'Schema', () => {
|
|
|
|
|
|
expect( schema.getLimitElement( doc.selection ) ).to.equal( article );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'returns the limit element which is the closest element to common ancestor for non-collapsed selection', () => {
|
|
|
+ schema.limits.add( 'section' );
|
|
|
+
|
|
|
+ setData( doc, '<div><section><article><paragraph>fo[o</paragraph></article>b]ar</section></div>' );
|
|
|
+
|
|
|
+ const section = root.getNodeByPath( [ 0, 0 ] );
|
|
|
+
|
|
|
+ expect( schema.getLimitElement( doc.selection ) ).to.equal( section );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'works fine with multi-range selections', () => {
|
|
|
+ schema.limits.add( 'div' );
|
|
|
+
|
|
|
+ setData(
|
|
|
+ doc,
|
|
|
+ '<div>' +
|
|
|
+ '<section>' +
|
|
|
+ '<article>' +
|
|
|
+ '<paragraph>[foo]</paragraph>' +
|
|
|
+ '</article>' +
|
|
|
+ '</section>' +
|
|
|
+ '<section>b[]ar</section>' +
|
|
|
+ '</div>'
|
|
|
+ );
|
|
|
+
|
|
|
+ const div = root.getNodeByPath( [ 0 ] );
|
|
|
+ expect( schema.getLimitElement( doc.selection ) ).to.equal( div );
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'works fine with multi-range selections even if limit elements are not defined', () => {
|
|
|
+ schema.limits.clear();
|
|
|
+
|
|
|
+ setData(
|
|
|
+ doc,
|
|
|
+ '<div>' +
|
|
|
+ '<section>' +
|
|
|
+ '<article>' +
|
|
|
+ '<paragraph>[foo]</paragraph>' +
|
|
|
+ '</article>' +
|
|
|
+ '</section>' +
|
|
|
+ '</div>' +
|
|
|
+ '<section>b[]ar</section>'
|
|
|
+ );
|
|
|
+
|
|
|
+ expect( schema.getLimitElement( doc.selection ) ).to.equal( root );
|
|
|
+ } );
|
|
|
} );
|
|
|
} );
|