|
53 | 53 |
|
54 | 54 | {# Load the editor. #} |
55 | 55 | <script type="text/javascript"> |
56 | | -
|
57 | | - {# Go. #} |
58 | | - const {{ id }}_function = function() { |
59 | | - (function(){ |
60 | | - const editInstance = new FroalaEditor( "#{{ id }}",{ |
61 | | - {# Add license. #} |
62 | | - {% if froala_serialNumber is defined %} |
63 | | - key : "{{ froala_serialNumber }}", |
64 | | - {% endif %} |
65 | | - {% for option, value in froala_arrOption %} |
66 | | - {{ option }} : {% include "@LeaptFroalaEditor/Form/value.html.twig" %} |
67 | | - {% endfor %} |
68 | | -
|
69 | | - events: { |
70 | | - 'image.error': function ( error ) { |
71 | | - froalaDisplayError( this, error ); |
72 | | - }, |
73 | | - 'imageManager.error': function ( error ) { |
74 | | - froalaDisplayError( this, error ); |
75 | | - }, |
76 | | - 'save.error': function ( error ) { |
77 | | - froalaDisplayError( this, error ); |
78 | | - }, |
79 | | - 'file.error': function ( error, responses ) { |
80 | | - froalaDisplayError( this, error ); |
81 | | - }, |
82 | | - 'video.error': function ( error, responses ) { |
83 | | - froalaDisplayError( this, error ); |
84 | | - } |
85 | | - {% for event, func in froala_events %} |
86 | | - ,'{{ event }}': {{ func }} |
| 56 | + if (typeof {{ id }}_function === 'undefined') { |
| 57 | + const {{ id }}_function = function() { |
| 58 | + (function(){ |
| 59 | + const editInstance = new FroalaEditor( "#{{ id }}",{ |
| 60 | + {# Add license. #} |
| 61 | + {% if froala_serialNumber is defined %} |
| 62 | + key : "{{ froala_serialNumber }}", |
| 63 | + {% endif %} |
| 64 | + {% for option, value in froala_arrOption %} |
| 65 | + {{ option }} : {% include "@LeaptFroalaEditor/Form/value.html.twig" %} |
87 | 66 | {% endfor %} |
88 | | - }}) |
89 | | - })(); |
90 | | -
|
91 | | -
|
92 | | - } |
93 | 67 |
|
94 | | - document.addEventListener("DOMContentLoaded", {{ id }}_function); |
95 | | - if (document.readyState === "interactive" || document.readyState === "complete" ) { |
96 | | - {{ id }}_function(); |
| 68 | + events: { |
| 69 | + 'image.error': function ( error ) { |
| 70 | + froalaDisplayError( this, error ); |
| 71 | + }, |
| 72 | + 'imageManager.error': function ( error ) { |
| 73 | + froalaDisplayError( this, error ); |
| 74 | + }, |
| 75 | + 'save.error': function ( error ) { |
| 76 | + froalaDisplayError( this, error ); |
| 77 | + }, |
| 78 | + 'file.error': function ( error, responses ) { |
| 79 | + froalaDisplayError( this, error ); |
| 80 | + }, |
| 81 | + 'video.error': function ( error, responses ) { |
| 82 | + froalaDisplayError( this, error ); |
| 83 | + } |
| 84 | + {% for event, func in froala_events %} |
| 85 | + ,'{{ event }}': {{ func }} |
| 86 | + {% endfor %} |
| 87 | + }}) |
| 88 | + })(); |
| 89 | + } |
| 90 | +
|
| 91 | + document.addEventListener("DOMContentLoaded", {{ id }}_function); |
| 92 | + if (document.readyState === "interactive" || document.readyState === "complete" ) { |
| 93 | + {{ id }}_function(); |
| 94 | + } |
97 | 95 | } |
98 | 96 | </script> |
99 | 97 |
|
|
0 commit comments