Skip to content

Commit 30c8b16

Browse files
authored
Merge pull request #53 from brunolemos/UN-549
Add on:ready method (called after editor:ready event)
2 parents 5116c69 + 9b43607 commit 30c8b16

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ Next, you'll need to import the Email Editor component to your app.
4242
<button v-on:click="exportHtml">Export HTML</button>
4343
</div>
4444

45-
<EmailEditor ref="emailEditor" v-on:load="editorLoaded" />
45+
<EmailEditor
46+
ref="emailEditor"
47+
v-on:load="editorLoaded"
48+
v-on:ready="editorReady"
49+
/>
4650
</div>
4751
</div>
4852
</template>
@@ -56,10 +60,16 @@ Next, you'll need to import the Email Editor component to your app.
5660
EmailEditor,
5761
},
5862
methods: {
63+
// called when the editor is created
5964
editorLoaded() {
65+
console.log('editorLoaded');
6066
// Pass the template JSON here
6167
// this.$refs.emailEditor.editor.loadDesign({});
6268
},
69+
// called when the editor has finished loading
70+
editorReady() {
71+
console.log('editorReady');
72+
},
6373
saveDesign() {
6474
this.$refs.emailEditor.editor.saveDesign((design) => {
6575
console.log('saveDesign', design);
@@ -121,6 +131,7 @@ Here's an example using the above properties...
121131
:options="options"
122132
ref="emailEditor"
123133
v-on:load="editorLoaded"
134+
v-on:ready="editorReady"
124135
/>
125136
</div>
126137
</div>
@@ -157,10 +168,16 @@ Here's an example using the above properties...
157168
};
158169
},
159170
methods: {
171+
// called when the editor is created
160172
editorLoaded() {
173+
console.log('editorLoaded');
161174
// Pass your template JSON here
162175
// this.$refs.emailEditor.editor.loadDesign({});
163176
},
177+
// called when the editor has finished loading
178+
editorReady() {
179+
console.log('editorReady');
180+
},
164181
saveDesign() {
165182
this.$refs.emailEditor.editor.saveDesign((design) => {
166183
console.log('saveDesign', design);

src/components/EmailEditor.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export default {
6666
});
6767
6868
this.$emit('load');
69+
70+
this.editor.addEventListener('editor:ready', () => {
71+
this.$emit('ready');
72+
});
6973
},
7074
loadDesign(design) {
7175
this.editor.loadDesign(design);

src/views/DesignEdit.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<button v-on:click="exportHtml">Export HTML</button>
1010
</div>
1111

12-
<EmailEditor ref="emailEditor" v-on:load="editorLoaded" />
12+
<EmailEditor ref="emailEditor" v-on:load="editorLoaded" v-on:ready="editorReady" />
1313
</div>
1414
</div>
1515
</template>
@@ -23,7 +23,13 @@ export default {
2323
EmailEditor
2424
},
2525
methods: {
26+
// called when the editor is created
2627
editorLoaded() {
28+
console.log('editorLoaded');
29+
},
30+
// called when the editor has finished loading
31+
editorReady() {
32+
console.log('editorReady');
2733
},
2834
saveDesign() {
2935
this.$refs.emailEditor.editor.saveDesign(

src/views/Example.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<button v-on:click="exportHtml">Export HTML</button>
99
</div>
1010

11-
<EmailEditor ref="emailEditor" v-on:load="editorLoaded" />
11+
<EmailEditor ref="emailEditor" v-on:load="editorLoaded" v-on:ready="editorReady" />
1212
</div>
1313
</div>
1414
</template>
@@ -23,9 +23,15 @@ export default {
2323
EmailEditor
2424
},
2525
methods: {
26+
// called when the editor is created
2627
editorLoaded() {
28+
console.log('editorLoaded');
2729
this.$refs.emailEditor.editor.loadDesign(sample);
2830
},
31+
// called when the editor has finished loading
32+
editorReady() {
33+
console.log('editorReady');
34+
},
2935
saveDesign() {
3036
this.$refs.emailEditor.editor.saveDesign(
3137
(design) => {

0 commit comments

Comments
 (0)