File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828
2929import { generateCSSVarTokens , getUITheme } from ' ../helpers/coolParameters.js'
3030import { getCoolServerUrl } from ' ../helpers/url.js'
31+ import PostMessageService from ' ../services/postMessage.tsx'
3132
3233export default {
3334 name: ' CoolFrame' ,
@@ -59,9 +60,16 @@ export default {
5960 formAction: ' ' ,
6061 cssVariables: generateCSSVarTokens (),
6162 uiTheme: getUITheme (),
63+ postMessage: null ,
6264 }
6365 },
6466 mounted () {
67+ this .postMessage = new PostMessageService ({
68+ parent: window .parent ,
69+ })
70+
71+ window .addEventListener (' message' , this .handlePostMessage )
72+
6573 // Ensure publicWopiUrl is used to construct formAction
6674 if (this .publicWopiUrl ) {
6775 this .formAction = getCoolServerUrl (this .publicWopiUrl )
@@ -79,14 +87,32 @@ export default {
7987 }
8088 })
8189 },
90+ beforeDestroy () {
91+ window .removeEventListener (' message' , this .handlePostMessage )
92+ },
93+ methods: {
94+ handlePostMessage (event ) {
95+ try {
96+ const data = event .data
97+ if (data .MessageId === ' Iframe_Height' ) {
98+ document .getElementById (this .iframeName ).height = data .Values .ContentHeight
99+ }
100+ } catch (e) {
101+ console .error (' Something went wrong with post message' , e)
102+ }
103+ },
104+ },
105+
82106}
83107 </script >
84108
85109 <style scoped>
86110 .cool-frame-iframe {
87111 width : 100% ;
88112 border : none ;
89- height : 60vh ;
90- overflow-y : auto ;
113+ overflow-y : auto ;
114+ box-sizing : border-box ;
115+ padding : 0 ;
116+ margin : 0 ;
91117 }
92118 </style >
You can’t perform that action at this time.
0 commit comments