@shoutem/ui 6.3.0 → 6.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Vimeo } from 'react-native-vimeo-iframe';
|
|
2
3
|
import YoutubePlayer from 'react-native-youtube-iframe';
|
|
3
4
|
import iframe from '@native-html/iframe-plugin';
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
@@ -41,6 +42,19 @@ const IframeRenderer = props => {
|
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
if (url && url.includes('vimeo')) {
|
|
46
|
+
const vimeoIdRegEx = /(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:[a-zA-Z0-9_\-]+)?/i;
|
|
47
|
+
const regExMatches = url.match(vimeoIdRegEx);
|
|
48
|
+
const vimeoId = regExMatches[1];
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Vimeo
|
|
52
|
+
videoId={vimeoId}
|
|
53
|
+
style={{ height: shoutemStyle.vimeoVideo.height }}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
return iframe(props);
|
|
45
59
|
};
|
|
46
60
|
|
|
@@ -15,6 +15,7 @@ import PropTypes from 'prop-types';
|
|
|
15
15
|
import { connectStyle } from '@shoutem/theme';
|
|
16
16
|
import { View } from '../../components/View';
|
|
17
17
|
import { resolveMaxWidth } from '../services/Dimensions';
|
|
18
|
+
import { onElement } from '../services/DomVisitors';
|
|
18
19
|
import AttachmentRenderer from './AttachmentRenderer';
|
|
19
20
|
import IframeRenderer from './IframeRenderer';
|
|
20
21
|
|
|
@@ -40,6 +41,7 @@ class SimpleHtml extends PureComponent {
|
|
|
40
41
|
customTagStyles,
|
|
41
42
|
unsupportedVideoFormatMessage,
|
|
42
43
|
attachments,
|
|
44
|
+
domVisitors,
|
|
43
45
|
...otherProps
|
|
44
46
|
} = this.props;
|
|
45
47
|
|
|
@@ -102,6 +104,7 @@ class SimpleHtml extends PureComponent {
|
|
|
102
104
|
},
|
|
103
105
|
WebView,
|
|
104
106
|
ignoredTags: IGNORED_TAGS,
|
|
107
|
+
domVisitors: { onElement },
|
|
105
108
|
};
|
|
106
109
|
|
|
107
110
|
return (
|
|
@@ -119,6 +122,7 @@ SimpleHtml.propTypes = {
|
|
|
119
122
|
customAlterNode: PropTypes.func,
|
|
120
123
|
customHandleLinkPress: PropTypes.func,
|
|
121
124
|
customTagStyles: PropTypes.object,
|
|
125
|
+
domVisitors: PropTypes.object,
|
|
122
126
|
unsupportedVideoFormatMessage: PropTypes.string,
|
|
123
127
|
};
|
|
124
128
|
|
|
@@ -129,6 +133,7 @@ SimpleHtml.defaultProps = {
|
|
|
129
133
|
customHandleLinkPress: undefined,
|
|
130
134
|
customTagStyles: undefined,
|
|
131
135
|
unsupportedVideoFormatMessage: undefined,
|
|
136
|
+
domVisitors: { onElement },
|
|
132
137
|
};
|
|
133
138
|
|
|
134
139
|
export default connectStyle('shoutem.ui.SimpleHtml')(SimpleHtml);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
|
|
3
|
+
// Shoutem RTE component wraps any video attachment (hosted inside iframe) with <figure>
|
|
4
|
+
// element. That element contains style that breaks the SimpleHtml UI - enormous blank
|
|
5
|
+
// space below attachment.
|
|
6
|
+
// This function removes height and padding-bottom styles from figure to fix this UI issue.
|
|
7
|
+
export const removeShoutemRteVideoAttachmentWrapper = element => {
|
|
8
|
+
if (
|
|
9
|
+
element.name === 'figure' &&
|
|
10
|
+
element.children.length > 0 &&
|
|
11
|
+
// <figure> can have multiple generated children too - type:text. Probably caused by empty space between
|
|
12
|
+
// figure and iframe elements in generated HTML.
|
|
13
|
+
_.some(element.children, ({ name }) => name === 'iframe')
|
|
14
|
+
) {
|
|
15
|
+
// Remove height and padding-bottom styles because they break the UI
|
|
16
|
+
element.attribs.style = element.attribs.style
|
|
17
|
+
? element.attribs.style
|
|
18
|
+
.replace(/height:[^;]+;?/, '')
|
|
19
|
+
.replace(/padding-bottom:[^;]+;?/, '')
|
|
20
|
+
: '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return element;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Collection of node (HTML element) alteration callbacks. Define any html element
|
|
28
|
+
* manipulations inside.
|
|
29
|
+
* @param {*} element - HTML element to check against and manipulate if necessary
|
|
30
|
+
* @returns Manipulated HTML element
|
|
31
|
+
*/
|
|
32
|
+
export const onElement = element => {
|
|
33
|
+
return removeShoutemRteVideoAttachmentWrapper(element);
|
|
34
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shoutem/ui",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"description": "Styleable set of components for React Native applications",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "eslint .",
|
|
@@ -135,4 +135,4 @@
|
|
|
135
135
|
"!/node_modules/@shoutem"
|
|
136
136
|
]
|
|
137
137
|
}
|
|
138
|
-
}
|
|
138
|
+
}
|
package/theme.js
CHANGED
|
@@ -2327,6 +2327,10 @@ export default () => {
|
|
|
2327
2327
|
height: responsiveWidth(194),
|
|
2328
2328
|
paddingBottom: resolveVariable('smallGutter'),
|
|
2329
2329
|
},
|
|
2330
|
+
// Just enough to display portrait mode Vimeo videos and all Vimeo player controls
|
|
2331
|
+
vimeoVideo: {
|
|
2332
|
+
height: responsiveHeight(220),
|
|
2333
|
+
},
|
|
2330
2334
|
fallback: {
|
|
2331
2335
|
width: window.width,
|
|
2332
2336
|
height: 40,
|