nice-elements 1.13.0 → 1.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -93,6 +93,7 @@ angular.module('niceElements')
93
93
  }
94
94
 
95
95
  const getFilter = function (item) {
96
+ if (!item) return;
96
97
  // Create filter for finding object by objValue with _.where()
97
98
  const filter = {};
98
99
  if (item.hasOwnProperty($scope.objKey))
@@ -33,7 +33,7 @@ angular.module('niceElements')
33
33
  objValue: '@', // Optional - default is 'value'
34
34
  objKey: '@?', // Optional - default is 'id'. Used only when returnOnlyKey=true.
35
35
  selectedIsKey: '@?',
36
- nullable: '@', // No selection is possible
36
+ nullable: '=', // No selection is possible
37
37
  required: '=', // Model cannot be NULL
38
38
  noMargin: '@', // margin-bottom: 0px
39
39
  multiple: '@', // Can select multiple items
@@ -66,7 +66,6 @@ angular.module('niceElements')
66
66
  if (!$scope.selectedText) { $scope.selectedText = gettextCatalog.getString("selected", null, "Nice"); }
67
67
  if (!$scope.addButtonFunction) { $scope.addButtonFunction = null; }
68
68
  if (!$scope.placement) { $scope.placement = "bottom-start"; }
69
- $scope.nullable = $scope.nullable === 'true' || $scope.nullable === true;
70
69
  $scope.noMargin = $scope.noMargin === 'true' || $scope.noMargin === true;
71
70
  $scope.multiple = $scope.multiple === 'true' || $scope.multiple === true;
72
71
  $scope.clearOnSelect = $scope.clearOnSelect === 'true' || $scope.clearOnSelect === true;
@@ -13,7 +13,9 @@
13
13
  <div class="text text-placeholder" ng-if="dragging" translate translate-group="Nice">Drop file here</div>
14
14
  <div class="error" ng-if="error">{{ error }}</div>
15
15
  </div>
16
- <img ng-if="imageSource" data-ng-src="{{ imageSource }}" />
16
+ <div ng-if="imageSource" ng-transclude>
17
+ <img data-ng-src="{{ imageSource }}" />
18
+ </div>
17
19
  </div>
18
20
  <input class="input-file" type="file" accept="{{ accept }}" ng-model="file" ng-required="required" ng-disabled="isDisabled || loading" />
19
21
  <nice-loader fulldiv="true" ng-if="loading"></nice-loader>
@@ -77,7 +77,7 @@
77
77
  }
78
78
  }
79
79
 
80
- img {
80
+ img, video {
81
81
  width: 100%;
82
82
  height: 100%;
83
83
  object-fit: contain;
@@ -8,9 +8,28 @@
8
8
  */
9
9
  angular.module('niceElements').filter('niceHighlight', function () {
10
10
  return function (value, highlightedText) {
11
- if (!value) return "";
11
+ if (!value || !highlightedText) return "";
12
12
  const regex = new RegExp(highlightedText, 'gmi');
13
- const newValue = String(value).replace(regex, "<span class='nice-highligh'>$&</span>");
13
+ const newValue = String(value).replace(regex, "<span class='nice-highlight'>$&</span>");
14
14
  return newValue;
15
15
  };
16
16
  });
17
+
18
+ angular.module('niceElements')
19
+ .filter('h', function ($sce, $sanitize) {
20
+ return function (text, phrase) {
21
+ if (!phrase || !text) return text;
22
+
23
+ // 1. Sanitize the original text to prevent XSS
24
+ let cleanText = $sanitize(text);
25
+
26
+ // 2. Create the case-insensitive global Regex
27
+ const regex = new RegExp('(' + phrase + ')', 'gi');
28
+
29
+ // 3. Replace matches with the h element
30
+ const highlighted = cleanText.replace(regex, '<h>$1</h>');
31
+
32
+ // 4. Trust the result so ng-bind-html renders it
33
+ return $sce.trustAsHtml(highlighted);
34
+ };
35
+ });
@@ -10,7 +10,7 @@ angular.module('niceElements')
10
10
  .service('NiceService', function ($rootScope) {
11
11
  const service = {
12
12
  name: "Nice elements",
13
- version: "1.13.0",
13
+ version: "1.13.1",
14
14
  getHeader: function () {
15
15
  return {};
16
16
  },
@@ -452,7 +452,7 @@ p.nice {
452
452
  }
453
453
  }
454
454
 
455
- .nice-highligh {
455
+ h, .nice-highlight {
456
456
  background: yellow;
457
457
  }
458
458