@@ -7,8 +7,9 @@ import { BasicEditor } from '../../bundle-basic-editor/BasicEditor';
77import { Core } from '../../core/src/Core' ;
88import { Layout } from '../../plugin-layout/src/Layout' ;
99
10- const deleteForward = async ( editor : JWEditor ) : Promise < void > =>
10+ const deleteForward = async ( editor : JWEditor ) : Promise < void > => {
1111 await editor . execCommand < Core > ( 'deleteForward' ) ;
12+ } ;
1213const deleteBackward = async ( editor : JWEditor ) : Promise < void > =>
1314 await editor . execCommand < Core > ( 'deleteBackward' ) ;
1415const insertParagraphBreak = async ( editor : JWEditor ) : Promise < void > =>
@@ -548,9 +549,11 @@ describe('VDocument', () => {
548549 stepFunction : ( editor : JWEditor ) => {
549550 const domEngine = editor . plugins . get ( Layout ) . engines . dom ;
550551 const editable = domEngine . components . get ( 'editable' ) [ 0 ] ;
551- editable . firstChild ( ) . breakable = false ;
552- editable . lastChild ( ) . breakable = false ;
553- return deleteForward ( editor ) ;
552+ return editor . execBatch ( ( ) => {
553+ editable . firstChild ( ) . breakable = false ;
554+ editable . lastChild ( ) . breakable = false ;
555+ return deleteForward ( editor ) ;
556+ } ) ;
554557 } ,
555558 contentAfter : '<p>a[</p><p>]f</p>' ,
556559 } ) ;
@@ -1506,15 +1509,17 @@ describe('VDocument', () => {
15061509 await testEditor ( BasicEditor , {
15071510 contentBefore : 'ab[]' ,
15081511 stepFunction : async ( editor : JWEditor ) => {
1509- const domEngine = editor . plugins . get ( Layout ) . engines . dom ;
1510- const editable = domEngine . components . get ( 'editable' ) [ 0 ] ;
1511- const aNode = editable . next ( node => node . name === 'a' ) ;
1512- await withRange ( editor , VRange . at ( aNode ) , async range => {
1513- await editor . execCommand < Char > ( 'insertText' , {
1514- text : 'c' ,
1515- context : {
1516- range : range ,
1517- } ,
1512+ await editor . execBatch ( async ( ) => {
1513+ const domEngine = editor . plugins . get ( Layout ) . engines . dom ;
1514+ const editable = domEngine . components . get ( 'editable' ) [ 0 ] ;
1515+ const aNode = editable . next ( node => node . name === 'a' ) ;
1516+ await withRange ( editor , VRange . at ( aNode ) , async range => {
1517+ await editor . execCommand < Char > ( 'insertText' , {
1518+ text : 'c' ,
1519+ context : {
1520+ range : range ,
1521+ } ,
1522+ } ) ;
15181523 } ) ;
15191524 } ) ;
15201525 } ,
@@ -1525,15 +1530,17 @@ describe('VDocument', () => {
15251530 await testEditor ( BasicEditor , {
15261531 contentBefore : 'ab[]' ,
15271532 stepFunction : async ( editor : JWEditor ) => {
1528- const domEngine = editor . plugins . get ( Layout ) . engines . dom ;
1529- const editable = domEngine . components . get ( 'editable' ) [ 0 ] ;
1530- const aNode = editable . next ( node => node . name === 'a' ) ;
1531- await withRange ( editor , VRange . selecting ( aNode , aNode ) , async range => {
1532- await editor . execCommand < Char > ( 'insertText' , {
1533- text : 'c' ,
1534- context : {
1535- range : range ,
1536- } ,
1533+ await editor . execBatch ( async ( ) => {
1534+ const domEngine = editor . plugins . get ( Layout ) . engines . dom ;
1535+ const editable = domEngine . components . get ( 'editable' ) [ 0 ] ;
1536+ const aNode = editable . next ( node => node . name === 'a' ) ;
1537+ await withRange ( editor , VRange . selecting ( aNode , aNode ) , async range => {
1538+ await editor . execCommand < Char > ( 'insertText' , {
1539+ text : 'c' ,
1540+ context : {
1541+ range : range ,
1542+ } ,
1543+ } ) ;
15371544 } ) ;
15381545 } ) ;
15391546 } ,
@@ -1551,12 +1558,14 @@ describe('VDocument', () => {
15511558 [ aNode , RelativePosition . BEFORE ] ,
15521559 [ aNode , RelativePosition . BEFORE ] ,
15531560 ] ;
1554- await withRange ( editor , rangeParams , async range => {
1555- await editor . execCommand < Char > ( 'insertText' , {
1556- text : 'c' ,
1557- context : {
1558- range : range ,
1559- } ,
1561+ await editor . execBatch ( async ( ) => {
1562+ await withRange ( editor , rangeParams , async range => {
1563+ await editor . execCommand < Char > ( 'insertText' , {
1564+ text : 'c' ,
1565+ context : {
1566+ range : range ,
1567+ } ,
1568+ } ) ;
15601569 } ) ;
15611570 } ) ;
15621571 } ,
@@ -1574,12 +1583,14 @@ describe('VDocument', () => {
15741583 [ aNode , RelativePosition . BEFORE ] ,
15751584 [ aNode , RelativePosition . AFTER ] ,
15761585 ] ;
1577- await withRange ( editor , rangeParams , async range => {
1578- await editor . execCommand < Char > ( 'insertText' , {
1579- text : 'c' ,
1580- context : {
1581- range : range ,
1582- } ,
1586+ await editor . execBatch ( async ( ) => {
1587+ await withRange ( editor , rangeParams , async range => {
1588+ await editor . execCommand < Char > ( 'insertText' , {
1589+ text : 'c' ,
1590+ context : {
1591+ range : range ,
1592+ } ,
1593+ } ) ;
15831594 } ) ;
15841595 } ) ;
15851596 } ,
@@ -1597,12 +1608,14 @@ describe('VDocument', () => {
15971608 [ aNode , RelativePosition . AFTER ] ,
15981609 [ aNode , RelativePosition . AFTER ] ,
15991610 ] ;
1600- await withRange ( editor , rangeParams , async range => {
1601- await editor . execCommand < Char > ( 'insertText' , {
1602- text : 'c' ,
1603- context : {
1604- range : range ,
1605- } ,
1611+ await editor . execBatch ( async ( ) => {
1612+ await withRange ( editor , rangeParams , async range => {
1613+ await editor . execCommand < Char > ( 'insertText' , {
1614+ text : 'c' ,
1615+ context : {
1616+ range : range ,
1617+ } ,
1618+ } ) ;
16061619 } ) ;
16071620 } ) ;
16081621 } ,
@@ -1621,12 +1634,14 @@ describe('VDocument', () => {
16211634 [ aNode , RelativePosition . AFTER ] ,
16221635 [ bNode , RelativePosition . BEFORE ] ,
16231636 ] ;
1624- await withRange ( editor , rangeParams , async range => {
1625- await editor . execCommand < Char > ( 'insertText' , {
1626- text : 'c' ,
1627- context : {
1628- range : range ,
1629- } ,
1637+ await editor . execBatch ( async ( ) => {
1638+ await withRange ( editor , rangeParams , async range => {
1639+ await editor . execCommand < Char > ( 'insertText' , {
1640+ text : 'c' ,
1641+ context : {
1642+ range : range ,
1643+ } ,
1644+ } ) ;
16301645 } ) ;
16311646 } ) ;
16321647 } ,
@@ -1645,12 +1660,14 @@ describe('VDocument', () => {
16451660 [ aNode , RelativePosition . AFTER ] ,
16461661 [ bNode , RelativePosition . AFTER ] ,
16471662 ] ;
1648- await withRange ( editor , rangeParams , async range => {
1649- await editor . execCommand < Char > ( 'insertText' , {
1650- text : 'c' ,
1651- context : {
1652- range : range ,
1653- } ,
1663+ await editor . execBatch ( async ( ) => {
1664+ await withRange ( editor , rangeParams , async range => {
1665+ await editor . execCommand < Char > ( 'insertText' , {
1666+ text : 'c' ,
1667+ context : {
1668+ range : range ,
1669+ } ,
1670+ } ) ;
16541671 } ) ;
16551672 } ) ;
16561673 } ,
0 commit comments