File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
packages/block-library/src/classic Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ export default class ClassicEdit extends Component {
7878 onSetup ( editor ) {
7979 const { attributes : { content } , setAttributes } = this . props ;
8080 const { ref } = this ;
81+ let bookmark ;
8182
8283 this . editor = editor ;
8384
@@ -86,17 +87,25 @@ export default class ClassicEdit extends Component {
8687 }
8788
8889 editor . on ( 'blur' , ( ) => {
89- const bookmark = editor . selection . getBookmark ( 2 , true ) ;
90+ bookmark = editor . selection . getBookmark ( 2 , true ) ;
9091
9192 setAttributes ( {
9293 content : editor . getContent ( ) ,
9394 } ) ;
9495
95- editor . once ( 'focus' , ( ) => editor . selection . moveToBookmark ( bookmark ) ) ;
96+ editor . once ( 'focus' , ( ) => {
97+ if ( bookmark ) {
98+ editor . selection . moveToBookmark ( bookmark ) ;
99+ }
100+ } ) ;
96101
97102 return false ;
98103 } ) ;
99104
105+ editor . on ( 'mousedown touchstart' , ( ) => {
106+ bookmark = null ;
107+ } ) ;
108+
100109 editor . on ( 'keydown' , ( event ) => {
101110 if ( ( event . keyCode === BACKSPACE || event . keyCode === DELETE ) && isTmceEmpty ( editor ) ) {
102111 // delete the block
Original file line number Diff line number Diff line change 11// Jest Snapshot v1, https://goo.gl/fbAQLP
22
33exports [` Classic should be inserted 1` ] = ` "test"` ;
4-
5- exports [` Classic should insert media 1` ] = ` "test<img class =\\"alignnone size-full wp-image-130\\" src =\\"http://localhost:8889/wp-content/uploads/2018/11/b9682d07-fa29-4fbb-a9ce-f1019cc82ca1.png\\" alt =\\"\\" width =\\"10\\" height =\\"10\\" />"` ;
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ describe( 'Classic', () => {
6666 // Move focus away.
6767 await pressWithModifier ( 'shift' , 'Tab' ) ;
6868
69- expect ( await getEditedPostContent ( ) ) . toMatchSnapshot ( ) ;
69+ const regExp = new RegExp ( `test<img class="alignnone size-full wp-image-\\d+" src="[^"]+\\/${ filename } \\.png" alt="" width="10" height="10" \\/>` ) ;
70+ expect ( await getEditedPostContent ( ) ) . toMatch ( regExp ) ;
7071 } ) ;
7172} ) ;
You can’t perform that action at this time.
0 commit comments