File tree Expand file tree Collapse file tree 3 files changed +41
-7
lines changed Expand file tree Collapse file tree 3 files changed +41
-7
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,35 @@ export default {
1313 blank: Boolean ,
1414 invisibles: Boolean ,
1515 kirbytags: Array ,
16+ },
17+ // below, code to refresh input within a newly expanded builder block
18+ computed: {
19+ builderBlock () {
20+ return this .getParentComponent (' builder-block' )
21+ },
22+ builderExpanded () {
23+ return this .builderBlock && this .builderBlock .expanded
24+ }
25+ },
26+ watch: {
27+ builderExpanded (newVal , oldVal ) {
28+ if (newVal === true ) {
29+ this .$root .$emit (' md-refresh' + this ._uid )
30+ }
31+ },
32+ },
33+ methods: {
34+ getParentComponent (componentName ) {
35+ let component = null
36+ let parent = this .$parent
37+ while (parent && ! component) {
38+ if (parent .$options ._componentTag === componentName) {
39+ component = parent
40+ }
41+ parent = parent .$parent
42+ }
43+ return component
44+ },
1645 }
1746};
1847 </script >
Original file line number Diff line number Diff line change @@ -46,10 +46,10 @@ export default {
4646 skipNextChangeEvent: false ,
4747 currentDialog: null ,
4848 currentTokenType: null ,
49- id: ' ' ,
5049 }
5150 },
5251 props: {
52+ id: Number ,
5353 autofocus: Boolean ,
5454 modals: Boolean ,
5555 blank: Boolean ,
@@ -90,15 +90,17 @@ export default {
9090 return this .$store .state .languages .current
9191 }
9292 },
93- created () {
94- this .id = this ._uid
95- },
9693 mounted () {
9794 this .editor = CodeMirror .fromTextArea (this .$refs .input , this .options );
9895 this .editor .setValue (this .value || ' ' );
9996
10097 // force refresh after setValue, else some text might not be rendered before the editor is clicked
101- this .$nextTick (() => this .editor .refresh ())
98+ this .refresh ()
99+
100+ // event triggered from parent
101+ this .$root .$on (' md-refresh' + this .id , () => {
102+ this .refresh ()
103+ })
102104
103105 // Custom autofocus: place the cursor at the end of current value
104106 if (this .autofocus ) {
@@ -180,10 +182,13 @@ export default {
180182 this .editor .scrollTo (scrollInfo .left , scrollInfo .top )
181183 }
182184 // force refresh
183- this .$nextTick (() => this . editor . refresh () )
185+ this .refresh ()
184186 },
185187 },
186188 methods: {
189+ refresh () {
190+ this .$nextTick (() => this .editor .refresh ())
191+ },
187192 /**
188193 * Close any open dialog and bring focus back to the editor
189194 */
You can’t perform that action at this time.
0 commit comments