File tree Expand file tree Collapse file tree 4 files changed +172
-96
lines changed
app/code/Magento/PageBuilder/view/adminhtml
js/content-type/video/converter/style
ts/js/content-type/video/converter/style Expand file tree Collapse file tree 4 files changed +172
-96
lines changed Original file line number Diff line number Diff line change 30
30
<css name =" css_classes" />
31
31
</element >
32
32
<element name =" wrapper" >
33
- <style name =" max_width" source =" max_width" converter =" Magento_PageBuilder/js/converter/style/remove-px " />
33
+ <style name =" max_width" source =" max_width" converter =" Magento_PageBuilder/js/content-type/video/ converter/style/max-width " />
34
34
<style name =" border" source =" border_style" converter =" Magento_PageBuilder/js/converter/style/border-style" />
35
35
<style name =" border_color" source =" border_color" />
36
36
<style name =" border_width" source =" border_width" converter =" Magento_PageBuilder/js/converter/style/remove-px" />
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ import ConverterInterface from "../../../../converter/converter-interface" ;
7
+ import { DataObject } from "../../../../data-store" ;
8
+
9
+ /**
10
+ * Subtract margin from max-width to fit inside parent container
11
+ *
12
+ * @api
13
+ */
14
+ export default class MaxWidth implements ConverterInterface {
15
+ /**
16
+ * Convert value to internal format
17
+ *
18
+ * @param value string
19
+ * @returns {string | object }
20
+ */
21
+ public fromDom ( value : string ) : object | string {
22
+ if ( value . indexOf ( "100%" ) !== - 1 ) {
23
+ return "" ;
24
+ }
25
+ return value . replace ( "px" , "" ) ;
26
+ }
27
+
28
+ /**
29
+ * Convert value to knockout format
30
+ *
31
+ * @param name string
32
+ * @param data Object
33
+ * @returns {string | object }
34
+ */
35
+ public toDom ( name : string , data : DataObject ) : string {
36
+ if ( data . max_width !== "" ) {
37
+ return data . max_width + "px" ;
38
+ }
39
+ const margins = data . margins_and_padding . margin || { } ;
40
+ const marginLeft = margins . left ? parseInt ( margins . left as string , 10 ) : 0 ;
41
+ const marginRight = margins . right ? parseInt ( margins . right as string , 10 ) : 0 ;
42
+
43
+ return "calc(100% - " + ( marginLeft + marginRight ) + "px)" ;
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments