@@ -39,7 +39,7 @@ class CMSEditor {
39
39
40
40
if ( this . mainWindow ) {
41
41
// Only needs to happen on the main window.
42
- this . mainWindow . addEventListener ( 'load ', ( ) => {
42
+ this . CMS . $ ( window ) . on ( 'cms-content-refresh ', ( ) => {
43
43
this . _resetInlineEditors ( ) ;
44
44
} ) ;
45
45
}
@@ -49,7 +49,7 @@ class CMSEditor {
49
49
this . _admin_selector = this . _inline_admin_selector + ':not(.empty-form) ' + this . _admin_selector ;
50
50
}
51
51
this . initAll ( ) ;
52
- } ) ;
52
+ } , { once : true } ) ;
53
53
}
54
54
55
55
// CMS Editor: init_all
@@ -92,10 +92,6 @@ class CMSEditor {
92
92
if ( ! el . id ) {
93
93
el . id = "cms-edit-" + Math . random ( ) . toString ( 36 ) . slice ( 2 , 9 ) ;
94
94
}
95
- if ( el . id in this . _editor_settings ) {
96
- // Already initialized - happens when an inline editor is scrolled back into the viewport
97
- return ;
98
- }
99
95
// Create editor
100
96
if ( ! el . dataset . cmsType || el . dataset . cmsType === 'TextPlugin' || el . dataset . cmsType === 'HTMLField' ) {
101
97
this . _createRTE ( el ) ;
@@ -122,14 +118,15 @@ class CMSEditor {
122
118
this . observer = this . observer || new IntersectionObserver ( ( entries ) => {
123
119
entries . forEach ( ( entry ) => {
124
120
if ( entry . isIntersecting ) {
125
- this . init ( entry . target ) ;
126
121
this . observer . unobserve ( entry . target ) ; // Only init once
122
+ this . init ( entry . target ) ;
127
123
}
128
124
} , this ) ;
129
125
} , {
130
126
root : null ,
131
127
threshold : 0.05
132
128
} ) ;
129
+ this . observer . disconnect ( ) ;
133
130
134
131
let generic_inline_fields = document . getElementById ( 'cms-generic-inline-fields' ) || { } ;
135
132
if ( generic_inline_fields ) {
@@ -495,7 +492,7 @@ class CMSEditor {
495
492
}
496
493
}
497
494
// Additional content for the page disrupts inline editing and needs to be removed
498
- delete this . CMS . API . Helpers . dataBridge . structure . content ;
495
+ delete this . CMS . API . Helpers . dataBridge . structure ? .content ;
499
496
500
497
if ( this . CMS . settings . version . startsWith ( '3.' ) ) {
501
498
/* Reflect dirty flag in django CMS < 4 */
@@ -632,7 +629,7 @@ class CMSEditor {
632
629
633
630
// CMS Editor: resetInlineEditors
634
631
_resetInlineEditors ( ) {
635
- this . initAll ( ) ;
632
+ this . initInlineEditors ( ) ;
636
633
}
637
634
638
635
// CMS Editor: loadToolbar
0 commit comments