@subiz/widget-v4 4.1.85 → 4.1.86

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.
@@ -56,7 +56,7 @@ class TextMessage extends _common.Com {
56
56
  }, tags);
57
57
  }
58
58
  renderBlock(block) {
59
- if (_index.default.size(block) == 0) return null;
59
+ if (isEmptyBlock(block)) return null;
60
60
  let byType = _index.default.get(this.props.ev, 'by.type');
61
61
  if (byType !== 'user') byType = 'agent';
62
62
  if (byType === 'agent') {
@@ -73,4 +73,9 @@ class TextMessage extends _common.Com {
73
73
  }));
74
74
  }
75
75
  }
76
- exports.default = TextMessage;
76
+ exports.default = TextMessage;
77
+ function isEmptyBlock(block) {
78
+ if (!block || !block.type) return true;
79
+ let hasContent = _index.default.size(_index.default.filter(_index.default.map(block.content, block => isEmptyBlock(block)), isEmpty => !isEmpty)) > 0;
80
+ return !_index.default.trim(block.text) && !hasContent;
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.1.85",
3
+ "version": "4.1.86",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -49,9 +49,8 @@ export default class TextMessage extends Com {
49
49
  }
50
50
 
51
51
  renderBlock(block) {
52
- if (sb.size(block) == 0) return null
52
+ if (isEmptyBlock(block)) return null
53
53
  let byType = sb.get(this.props.ev, 'by.type')
54
-
55
54
  if (byType !== 'user') byType = 'agent'
56
55
  if (byType === 'agent') {
57
56
  return (
@@ -67,3 +66,15 @@ export default class TextMessage extends Com {
67
66
  )
68
67
  }
69
68
  }
69
+
70
+ function isEmptyBlock(block) {
71
+ if (!block || !block.type) return true
72
+ let hasContent =
73
+ sb.size(
74
+ sb.filter(
75
+ sb.map(block.content, (block) => isEmptyBlock(block)),
76
+ (isEmpty) => !isEmpty,
77
+ ),
78
+ ) > 0
79
+ return !sb.trim(block.text) && !hasContent
80
+ }