File tree Expand file tree Collapse file tree 3 files changed +18
-25
lines changed Expand file tree Collapse file tree 3 files changed +18
-25
lines changed Original file line number Diff line number Diff line change @@ -18,20 +18,3 @@ const CMS = {
18
18
// in case some data is already attached to the global CMS
19
19
// we must not override it
20
20
window . CMS = CMS . $ . extend ( window . CMS || { } , CMS ) ;
21
-
22
- // Serve the data bridge:
23
- // We have a special case here cause the CMS namespace
24
- // can be either inside the current window or the parent
25
- if ( document . querySelector ( 'body.cms-close-frame script#data-bridge' ) ) {
26
- ( function ( Window ) {
27
- // the dataBridge is used to access plugin information from different resources
28
- // Do NOT move this!!!
29
- Window . CMS . API . Helpers . dataBridge = JSON . parse ( document . getElementById ( 'data-bridge' ) . textContent ) ;
30
- // make sure we're doing after the "modal" mechanism kicked in
31
- setTimeout ( function ( ) {
32
- // save current plugin
33
- Window . CMS . API . Helpers . onPluginSave ( ) ;
34
- } , 100 ) ; // eslint-disable-line no-magic-numbers
35
- } ) ( window . parent || window ) ;
36
- }
37
-
Original file line number Diff line number Diff line change @@ -1006,12 +1006,25 @@ class Modal {
1006
1006
true
1007
1007
) ;
1008
1008
} else {
1009
- setTimeout ( function ( ) {
1009
+ // Serve the data bridge:
1010
+ // We have a special case here cause the CMS namespace
1011
+ // can be either inside the current window or the parent
1012
+ const dataBridge = body [ 0 ] . querySelector ( 'script#data-bridge' ) ;
1013
+
1014
+ if ( dataBridge ) {
1010
1015
// hello ckeditor
1011
1016
Helpers . removeEventListener ( 'modal-close.text-plugin' ) ;
1012
1017
that . close ( ) ;
1013
- // must be more than 100ms
1014
- } , 150 ) ; // eslint-disable-line
1018
+ // the dataBridge is used to access plugin information from different resources
1019
+ // Do NOT move this!!!
1020
+ try {
1021
+ CMS . API . Helpers . dataBridge = JSON . parse ( dataBridge . textContent ) ;
1022
+ CMS . API . Helpers . onPluginSave ( ) ;
1023
+ } catch ( e ) {
1024
+ // istanbul ignore next
1025
+ Helpers . reloadBrowser ( ) ;
1026
+ }
1027
+ }
1015
1028
}
1016
1029
} else {
1017
1030
if ( that . ui . modal . hasClass ( 'cms-modal-open' ) ) {
Original file line number Diff line number Diff line change 1
- {% load i18n l10n static cms_static %}{% spaceless %}
1
+ {% spaceless %}
2
2
<!DOCTYPE html> < html >
3
3
< body class ="cms-close-frame ">
4
4
{# trick for cms to understand that the plugin was actually correctly saved #}
5
5
< div class ="messagelist ">
6
6
< div class ="success "> </ div >
7
7
</ div >
8
- {% if data_bridge %}
9
- {{ data_bridge|json_script:"data-bridge" }}
10
- < script src ="{% static_with_version "cms /js/dist/bundle.admin.base.min.js" %}" type="text/javascript "> </ script >
11
- {% endif %}
8
+ {% if data_bridge %}{{ data_bridge|json_script:"data-bridge" }}{% endif %}
12
9
</ body >
13
10
</ html >
14
11
{% endspaceless %}
You can’t perform that action at this time.
0 commit comments