File tree 1 file changed +27
-1
lines changed
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 77
77
78
78
<img style =" visibility: hidden" id =' image' src =" {{ imageUrl }}" />
79
79
<script {{ pimcore_csp.getNonceHtmlAttribute ()| raw }}>
80
- window .addEventListener (' load' , function (e ) {
80
+
81
+ /* *
82
+ * wait for image editor to be fully available
83
+ * before loading image to editor
84
+ */
85
+ async function loadEditor (e ) {
86
+ return new Promise (resolve => {
87
+ var checkInterval = setInterval (() => {
88
+ if (window .Layers ) {
89
+ clearInterval (checkInterval);
90
+ loadImageToEditor (e);
91
+ resolve (true );
92
+ }
93
+ }, 300 );
94
+ });
95
+ }
96
+
97
+ function loadImageToEditor (e ) {
81
98
var image = document .getElementById (' image' );
82
99
window .Layers .insert ({
83
100
name: " {{ asset.getFilename() }}" ,
109
126
110
127
return false ;
111
128
});
129
+ }
130
+
131
+ window .addEventListener (" load" , function (e ) {
132
+ loadEditor (e).then (function () {
133
+ console .log (" editor loaded" );
134
+ });
112
135
}, false );
136
+
137
+
138
+
113
139
</script >
114
140
115
141
</body >
You can’t perform that action at this time.
0 commit comments