@mediafly/js-ui 52.0.1 → 53.0.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## @mediafly/js-ui changelog
2
2
 
3
+ **53.0.0**
4
+
5
+ * **Breaking:** Prevents any HTML/JS injection into feedback alerts by default. HTML can still be included by explicitly setting `trustAsHtml` to true.
6
+
3
7
  **52.0.1**
4
8
 
5
9
  * Update Lodash version
@@ -24,9 +24,26 @@
24
24
  <span class="far fa-times"></span>
25
25
  </button>
26
26
 
27
- <span class="c-feedback__message" ng-bind-html="alert.msg"></span>
27
+ <span
28
+ class="c-feedback__message"
29
+ ng-if="!alert.trustAsHtml"
30
+ ng-bind="alert.message"
31
+ ></span>
32
+ <span
33
+ class="c-feedback__message"
34
+ ng-if="alert.trustAsHtml"
35
+ ng-bind-html="alert.message"
36
+ ></span>
37
+ <br class="c-feedback__copy-link-break" ng-if="alert.clipboardContents && alert.copyLinkText" />
38
+ <a
39
+ ng-if="alert.clipboardContents && alert.copyLinkText"
40
+ class="o-link c-feedback__copy-link"
41
+ href
42
+ ng-attr-data-clipboard-text="{{ alert.clipboardContents }}"
43
+ ng-attr-data-clipboard-success="{{ alert.copySuccessMessage || '' }}"
44
+ ng-bind="alert.copyLinkText"
45
+ ></a>
28
46
  </div>
29
47
 
30
48
  </div>
31
49
  </div>
32
-
@@ -1,5 +1,4 @@
1
1
  /// <reference types="angular-mocks" />
2
- /// <reference types="angular-sanitize" />
3
2
  import { IComponentController } from 'angular';
4
3
  import ClipboardService from './clipboard.service';
5
4
  export declare type FeedbackType = 'success' | 'danger' | 'info' | 'warning';
@@ -9,22 +8,29 @@ export interface FeedbackOptions {
9
8
  copyLinkText?: string;
10
9
  copySuccessMessage?: string;
11
10
  manualClose?: boolean;
12
- type?: FeedbackType;
13
11
  trustAsHtml?: boolean;
12
+ type?: FeedbackType;
13
+ }
14
+ export interface FeedbackAlert {
15
+ clipboardContents?: string;
16
+ copyLinkText?: string;
17
+ copySuccessMessage?: string;
18
+ message?: string;
19
+ trustAsHtml: boolean;
20
+ type: FeedbackType;
14
21
  }
15
22
  export default class FeedbackManager implements IComponentController {
16
23
  private $interval;
17
24
  private $rootScope;
18
- private $sanitize;
19
25
  private $sce;
20
26
  private $timeout;
21
27
  private clipboardService;
22
- protected alerts: object[];
28
+ protected alerts: FeedbackAlert[];
23
29
  private timer;
24
- constructor($interval: ng.IIntervalService, $rootScope: ng.IRootScopeService, $sanitize: ng.sanitize.ISanitizeService, $sce: ng.ISCEService, $timeout: ng.ITimeoutService, clipboardService: ClipboardService);
30
+ constructor($interval: ng.IIntervalService, $rootScope: ng.IRootScopeService, $sce: ng.ISCEService, $timeout: ng.ITimeoutService, clipboardService: ClipboardService);
25
31
  $onInit(): void;
26
32
  $onDestroy(): void;
27
- protected closeAlert(index: number): void;
33
+ protected closeAlert(): void;
28
34
  private handleFeedbackClick;
29
35
  private addAlert;
30
36
  private removeTimer;
@@ -18,10 +18,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const decorators_1 = require("../decorators");
19
19
  const clipboard_service_1 = __importDefault(require("./clipboard.service"));
20
20
  let FeedbackManager = class FeedbackManager {
21
- constructor($interval, $rootScope, $sanitize, $sce, $timeout, clipboardService) {
21
+ constructor($interval, $rootScope, $sce, $timeout, clipboardService) {
22
22
  this.$interval = $interval;
23
23
  this.$rootScope = $rootScope;
24
- this.$sanitize = $sanitize;
25
24
  this.$sce = $sce;
26
25
  this.$timeout = $timeout;
27
26
  this.clipboardService = clipboardService;
@@ -44,39 +43,43 @@ let FeedbackManager = class FeedbackManager {
44
43
  // Handle clicks on copy-links inside feedback
45
44
  window.addEventListener('click', this.handleFeedbackClick);
46
45
  this.$rootScope.$on('showFeedback', (event, args) => {
47
- args.alertMessage = args.trustAsHtml ? args.alertMessage : this.$sanitize(args.alertMessage);
48
46
  if (args.autoCopyContents && args.clipboardContents) {
49
47
  throw new Error('The clipboardContents and autoCopyContents options are mutually exclusive.');
50
48
  }
51
- if (args.clipboardContents && args.copyLinkText) {
52
- args.alertMessage += `<br/><a class="o-link" data-clipboard-text="${this.$sanitize(args.clipboardContents)}" data-clipboard-success="${this.$sanitize(args.copySuccessMessage || '')}">
53
- ${this.$sanitize(args.copyLinkText)}
54
- </a>`;
55
- }
56
49
  if (args.autoCopyContents) {
57
50
  this.clipboardService.writeToClipboard(args.autoCopyContents, args.copySuccessMessage);
58
51
  return;
59
52
  }
60
- this.removeTimer(this.timer);
61
53
  this.addAlert(args.alertMessage, args);
62
54
  });
63
55
  }
64
56
  $onDestroy() {
65
57
  window.removeEventListener('click', this.handleFeedbackClick);
66
58
  }
67
- closeAlert(index) {
59
+ closeAlert() {
68
60
  this.removeTimer(this.timer);
69
- this.alerts.splice(index, 1);
61
+ this.alerts = [];
70
62
  }
71
63
  addAlert(message, options) {
72
- this.alerts = [{
73
- msg: this.$sce.trustAsHtml(message),
74
- type: options.type || 'warning'
75
- }];
64
+ this.removeTimer(this.timer);
65
+ const trustAsHtml = !!options.trustAsHtml;
66
+ const alert = {
67
+ clipboardContents: options.clipboardContents || undefined,
68
+ copyLinkText: options.copyLinkText,
69
+ copySuccessMessage: options.copySuccessMessage,
70
+ trustAsHtml,
71
+ type: options.type || 'warning',
72
+ };
73
+ if (trustAsHtml) {
74
+ alert.message = this.$sce.trustAsHtml(message);
75
+ }
76
+ else {
77
+ alert.message = message;
78
+ }
79
+ this.alerts = [alert];
76
80
  if (!options.manualClose) {
77
81
  this.timer = this.$interval(() => {
78
- this.removeTimer(this.timer);
79
- this.closeAlert(this.alerts.length - 1);
82
+ this.closeAlert();
80
83
  }, 5000, 1);
81
84
  }
82
85
  }
@@ -93,11 +96,10 @@ FeedbackManager = __decorate([
93
96
  }),
94
97
  __param(0, decorators_1.Inject('$interval')),
95
98
  __param(1, decorators_1.Inject('$rootScope')),
96
- __param(2, decorators_1.Inject('$sanitize')),
97
- __param(3, decorators_1.Inject('$sce')),
98
- __param(4, decorators_1.Inject('$timeout')),
99
- __param(5, decorators_1.Inject('clipboardService')),
100
- __metadata("design:paramtypes", [Function, Object, Function, Object, Function, clipboard_service_1.default])
99
+ __param(2, decorators_1.Inject('$sce')),
100
+ __param(3, decorators_1.Inject('$timeout')),
101
+ __param(4, decorators_1.Inject('clipboardService')),
102
+ __metadata("design:paramtypes", [Function, Object, Object, Function, clipboard_service_1.default])
101
103
  ], FeedbackManager);
102
104
  exports.default = FeedbackManager;
103
105
  //# sourceMappingURL=feedback.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"feedback.component.js","sourceRoot":"","sources":["../../../../src/components/feedback/feedback.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,8CAAiD;AACjD,4EAAkD;AAsBlD,IAAqB,eAAe,GAApC,MAAqB,eAAe;IAInC,YAC8B,SAA8B,EAC7B,UAAgC,EACjC,SAAuC,EAC5C,IAAoB,EAChB,QAA4B,EACpB,gBAAkC;QALzC,cAAS,GAAT,SAAS,CAAqB;QAC7B,eAAU,GAAV,UAAU,CAAsB;QACjC,cAAS,GAAT,SAAS,CAA8B;QAC5C,SAAI,GAAJ,IAAI,CAAgB;QAChB,aAAQ,GAAR,QAAQ,CAAoB;QACpB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAT7D,WAAM,GAAa,EAAE,CAAA;QAmDvB,wBAAmB,GAAG,CAAC,KAAiB,EAAE,EAAE;YACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;gBAClB,MAAM,MAAM,GAAG,KAAK,CAAC,MAA4B,CAAA;gBACjD,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,uBAAuB,CAAC,CAAA,EAAE;oBAAE,OAAM;iBAAE;gBAEzD,MAAM,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC,qBAAqB,CAAC,CAAA;gBAC1D,MAAM,SAAS,G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WAAA,mBAAM,CAAC,YAAY,CAAC,CAAA;IACpB,WAAA,mBAAM,CAAC,WAAW,CAAC,CAAA;IACnB,WAAA,mBAAM,CAAC,MAAM,CAAC,CAAA;IACd,WAAA,mBAAM,CAAC,UAAU,CAAC,CAAA;IAClB,WAAA,mBAAM,CAAC,kBAAkB,CAAC,CAAA;mFAA2B,2BAAgB;GAVnD,eAAe,CAqFnC;kBArFoB,eAAe"}
1
+ {"version":3,"file":"feedback.component.js","sourceRoot":"","sources":["../../../../src/components/feedback/feedback.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,8CAAiD;AACjD,4EAAkD;AA+BlD,IAAqB,eAAe,GAApC,MAAqB,eAAe;IAInC,YAC8B,SAA8B,EAC7B,UAAgC,EACtC,IAAoB,EAChB,QAA4B,EACpB,gBAAkC;QAJzC,cAAS,GAAT,SAAS,CAAqB;QAC7B,eAAU,GAAV,UAAU,CAAsB;QACtC,SAAI,GAAJ,IAAI,CAAgB;QAChB,aAAQ,GAAR,QAAQ,CAAoB;QACpB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAR7D,WAAM,GAAoB,EAAE,CAAA;QAyC9B,wBAAmB,GAAG,CAAC,KAAiB,EAAE,EAAE;YACnD,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;gBAClB,MAAM,MAAM,GAAG,KAAK,CAAC,MAA4B,CAAA;gBACjD,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,uBAAuB,CAAC,CAAA,EAAE;oBAAE,OAAM;iBAAE;gBAEzD,MAAM,MAAM,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC,qBAAqB,CAAC,CAAA;gBAC1D,MAAM,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,CAAC,wBAAwB,CAAC,CAAA;gBAChE,IAAI,MAAM,EAAE;oBACX,IAAI,CAAC,gBAAgB,CAAC,gBAA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AAO,CAAC,kBAAkB;YAC9C,WAAW;YACX,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,SAAS;SAC/B,CAAA;QAED,IAAI,WAAW,EAAE;YAChB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAW,CAAA;SACxD;aAAM;YACN,KAAK,CAAC,OAAO,GAAG,OAAO,CAAA;SACvB;QAED,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAA;QAErB,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YACzB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;gBAChC,IAAI,CAAC,UAAU,EAAE,CAAA;YAClB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;SACX;IACF,CAAC;IAEO,WAAW,CAAC,KAAmC;QACtD,IAAI,KAAK,EAAE;YACV,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SAC5B;IACF,CAAC;CACD,CAAA;AAxFoB,eAAe;IAJnC,sBAAS,CAAC;QACV,QAAQ,EAAE,iBAAiB;QAC3B,QAAQ,EAAE,OAAO,CAAC,2BAA2B,CAAC;KAC9C,CAAC;IAMC,WAAA,mBAAM,CAAC,WAAW,CAAC,CAAA;IACnB,WAAA,mBAAM,CAAC,YAAY,CAAC,CAAA;IACpB,WAAA,mBAAM,CAAC,MAAM,CAAC,CAAA;IACd,WAAA,mBAAM,CAAC,UAAU,CAAC,CAAA;IAClB,WAAA,mBAAM,CAAC,kBAAkB,CAAC,CAAA;yEAA2B,2BAAgB;GATnD,eAAe,CAwFnC;kBAxFoB,eAAe"}
@@ -1002,8 +1002,8 @@
1002
1002
  "affectsGlobalScope": false
1003
1003
  },
1004
1004
  "../src/components/feedback/feedback.component.ts": {
1005
- "version": "7946a389a1784dff666637b4632bcf8b0b12a17009b7c1b8ab31db54e5b185b0",
1006
- "signature": "cad18625fe46b5fe4492f8b424612c71c963ca0b905114ab077bb9b1164b58a5",
1005
+ "version": "5b9d3ab2c63b9ea7a984253f0cacd893133bbb0a655ec81ed15c4f6d0cf49d7c",
1006
+ "signature": "0f4351c13f1b59e13657154e4cf8b2d1bb436fd763848e7f5218858d683734c8",
1007
1007
  "affectsGlobalScope": false
1008
1008
  },
1009
1009
  "../src/components/feedback/feedback.service.ts": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mediafly/js-ui",
3
- "version": "52.0.1",
3
+ "version": "53.0.0",
4
4
  "license": "UNLICENSED",
5
5
  "description": "UI components for Mediafly Angular applications",
6
6
  "repository": {
@@ -24,9 +24,26 @@
24
24
  <span class="far fa-times"></span>
25
25
  </button>
26
26
 
27
- <span class="c-feedback__message" ng-bind-html="alert.msg"></span>
27
+ <span
28
+ class="c-feedback__message"
29
+ ng-if="!alert.trustAsHtml"
30
+ ng-bind="alert.message"
31
+ ></span>
32
+ <span
33
+ class="c-feedback__message"
34
+ ng-if="alert.trustAsHtml"
35
+ ng-bind-html="alert.message"
36
+ ></span>
37
+ <br class="c-feedback__copy-link-break" ng-if="alert.clipboardContents && alert.copyLinkText" />
38
+ <a
39
+ ng-if="alert.clipboardContents && alert.copyLinkText"
40
+ class="o-link c-feedback__copy-link"
41
+ href
42
+ ng-attr-data-clipboard-text="{{ alert.clipboardContents }}"
43
+ ng-attr-data-clipboard-success="{{ alert.copySuccessMessage || '' }}"
44
+ ng-bind="alert.copyLinkText"
45
+ ></a>
28
46
  </div>
29
47
 
30
48
  </div>
31
49
  </div>
32
-
@@ -14,8 +14,17 @@ export interface FeedbackOptions {
14
14
  copyLinkText?: string
15
15
  copySuccessMessage?: string
16
16
  manualClose?: boolean
17
- type?: FeedbackType
18
17
  trustAsHtml?: boolean
18
+ type?: FeedbackType
19
+ }
20
+
21
+ export interface FeedbackAlert {
22
+ clipboardContents?: string
23
+ copyLinkText?: string
24
+ copySuccessMessage?: string
25
+ message?: string
26
+ trustAsHtml: boolean
27
+ type: FeedbackType
19
28
  }
20
29
 
21
30
  @Component({
@@ -23,13 +32,12 @@ export interface FeedbackOptions {
23
32
  template: require('./feedback.component.html'),
24
33
  })
25
34
  export default class FeedbackManager implements IComponentController {
26
- protected alerts: object[] = []
35
+ protected alerts: FeedbackAlert[] = []
27
36
  private timer: ng.IPromise<any> | undefined
28
37
 
29
38
  constructor(
30
39
  @Inject('$interval') private $interval: ng.IIntervalService,
31
40
  @Inject('$rootScope') private $rootScope: ng.IRootScopeService,
32
- @Inject('$sanitize') private $sanitize: ng.sanitize.ISanitizeService,
33
41
  @Inject('$sce') private $sce: ng.ISCEService,
34
42
  @Inject('$timeout') private $timeout: ng.ITimeoutService,
35
43
  @Inject('clipboardService') private clipboardService: ClipboardService,
@@ -42,24 +50,15 @@ export default class FeedbackManager implements IComponentController {
42
50
 
43
51
  this.$rootScope.$on('showFeedback', (event, args: FeedbackOptions & {alertMessage: string}) => {
44
52
 
45
- args.alertMessage = args.trustAsHtml ? args.alertMessage : this.$sanitize(args.alertMessage)
46
-
47
53
  if (args.autoCopyContents && args.clipboardContents) {
48
54
  throw new Error('The clipboardContents and autoCopyContents options are mutually exclusive.')
49
55
  }
50
56
 
51
- if (args.clipboardContents && args.copyLinkText) {
52
- args.alertMessage += `<br/><a class="o-link" data-clipboard-text="${this.$sanitize(args.clipboardContents)}" data-clipboard-success="${this.$sanitize(args.copySuccessMessage || '')}">
53
- ${this.$sanitize(args.copyLinkText)}
54
- </a>`
55
- }
56
-
57
57
  if (args.autoCopyContents) {
58
58
  this.clipboardService.writeToClipboard(args.autoCopyContents, args.copySuccessMessage)
59
59
  return
60
60
  }
61
61
 
62
- this.removeTimer(this.timer)
63
62
  this.addAlert(args.alertMessage, args)
64
63
  })
65
64
  }
@@ -68,10 +67,10 @@ export default class FeedbackManager implements IComponentController {
68
67
  window.removeEventListener('click', this.handleFeedbackClick)
69
68
  }
70
69
 
71
- protected closeAlert(index: number) {
70
+ protected closeAlert() {
72
71
 
73
72
  this.removeTimer(this.timer)
74
- this.alerts.splice(index, 1)
73
+ this.alerts = []
75
74
  }
76
75
 
77
76
  private handleFeedbackClick = (event: MouseEvent) => {
@@ -89,15 +88,28 @@ export default class FeedbackManager implements IComponentController {
89
88
 
90
89
  private addAlert(message: string, options: FeedbackOptions) {
91
90
 
92
- this.alerts = [{
93
- msg: this.$sce.trustAsHtml(message),
94
- type: options.type || 'warning'
95
- }]
91
+ this.removeTimer(this.timer)
92
+
93
+ const trustAsHtml = !!options.trustAsHtml
94
+ const alert: FeedbackAlert = {
95
+ clipboardContents: options.clipboardContents || undefined,
96
+ copyLinkText: options.copyLinkText,
97
+ copySuccessMessage: options.copySuccessMessage,
98
+ trustAsHtml,
99
+ type: options.type || 'warning',
100
+ }
101
+
102
+ if (trustAsHtml) {
103
+ alert.message = this.$sce.trustAsHtml(message) as string
104
+ } else {
105
+ alert.message = message
106
+ }
107
+
108
+ this.alerts = [alert]
96
109
 
97
110
  if (!options.manualClose) {
98
111
  this.timer = this.$interval(() => {
99
- this.removeTimer(this.timer)
100
- this.closeAlert(this.alerts.length - 1)
112
+ this.closeAlert()
101
113
  }, 5000, 1)
102
114
  }
103
115
  }
@@ -69,7 +69,9 @@
69
69
  }
70
70
  }
71
71
 
72
- .c-feedback__message {
72
+ .c-feedback__message,
73
+ .c-feedback__copy-link-break,
74
+ .c-feedback__copy-link {
73
75
  font-size: @font-size-base;
74
76
  }
75
77