@mediafly/js-ui 47.2.1-beta.0 → 47.3.1-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.
Files changed (54) hide show
  1. package/CHANGELOG.md +2 -14
  2. package/lib/auto-complete/auto-complete-match-renderer.component.d.ts +0 -2
  3. package/lib/auto-complete/auto-complete-match-renderer.component.js +4 -18
  4. package/lib/auto-complete/auto-complete-match-renderer.component.js.map +1 -1
  5. package/lib/auto-complete/auto-complete.component.html +2 -1
  6. package/lib/font-selector/font-selector.d.ts +39 -8
  7. package/lib/font-selector/font-selector.html +62 -13
  8. package/lib/font-selector/font-selector.js +190 -18
  9. package/lib/font-selector/font-selector.js.map +1 -1
  10. package/lib/font-selector/google-webfonts-api.service.d.ts +1 -1
  11. package/lib/font-selector/google-webfonts-api.service.js +10 -2
  12. package/lib/font-selector/google-webfonts-api.service.js.map +1 -1
  13. package/lib/font-selector/webfont-loader.service.d.ts +1 -2
  14. package/lib/font-selector/webfont-loader.service.js +2 -2
  15. package/lib/font-selector/webfont-loader.service.js.map +1 -1
  16. package/lib/jsui.module.css +13 -2
  17. package/lib/localization/index.strings.json +1 -1
  18. package/lib/rich-text/index.d.ts +0 -1
  19. package/lib/rich-text/index.js +0 -1
  20. package/lib/rich-text/index.js.map +1 -1
  21. package/lib/rich-text/rich-text.component.d.ts +2 -2
  22. package/lib/rich-text/rich-text.component.html +6 -14
  23. package/lib/rich-text/rich-text.component.js +6 -5
  24. package/lib/rich-text/rich-text.component.js.map +1 -1
  25. package/lib/styles.css +25 -16
  26. package/lib/tsconfig.deploy.tsbuildinfo +21 -33
  27. package/package.json +2 -2
  28. package/src/components/auto-complete/auto-complete-match-renderer.component.ts +5 -23
  29. package/src/components/auto-complete/auto-complete.component.html +2 -1
  30. package/src/components/auto-complete/auto-complete.component.less +2 -1
  31. package/src/components/font-selector/font-selector.html +62 -13
  32. package/src/components/font-selector/font-selector.less +116 -0
  33. package/src/components/font-selector/font-selector.ts +210 -17
  34. package/src/components/font-selector/google-webfonts-api.backend.ts +1 -1
  35. package/src/components/font-selector/google-webfonts-api.service.ts +10 -2
  36. package/src/components/font-selector/webfont-loader.service.ts +2 -2
  37. package/src/components/index.less +1 -1
  38. package/src/components/less/objects/buttons.less +8 -0
  39. package/src/components/less/objects/buttons.module.css +11 -0
  40. package/src/components/less/variables/colors.less +2 -2
  41. package/src/components/less/variables.module.css +2 -2
  42. package/src/components/localization/index.strings.json +1 -1
  43. package/src/components/rich-text/index.ts +0 -1
  44. package/src/components/rich-text/rich-text.component.html +6 -14
  45. package/src/components/rich-text/rich-text.component.less +5 -1
  46. package/src/components/rich-text/rich-text.component.ts +7 -5
  47. package/tsconfig.tsbuildinfo +48 -65
  48. package/lib/rich-text/rich-text-toolbar-container.component.d.ts +0 -16
  49. package/lib/rich-text/rich-text-toolbar-container.component.html +0 -12
  50. package/lib/rich-text/rich-text-toolbar-container.component.js +0 -75
  51. package/lib/rich-text/rich-text-toolbar-container.component.js.map +0 -1
  52. package/src/components/rich-text/rich-text-toolbar-container.component.html +0 -12
  53. package/src/components/rich-text/rich-text-toolbar-container.component.ts +0 -66
  54. package/src/components/rich-text/rich-text-toolbar-container.less +0 -21
@@ -0,0 +1,116 @@
1
+ @import '../less/variables/colors.less';
2
+
3
+ .c-font-selector {
4
+ display: block;
5
+ position: relative;
6
+ }
7
+
8
+ .c-font-selector__select {
9
+ background-color: #fff;
10
+ border: 1px solid @color-gray-x-light;
11
+ border-radius: 3px;
12
+ color: @color-gray-x-dark;
13
+ cursor: pointer;
14
+ display: grid;
15
+ font-size: 14px;
16
+ grid-template-columns: auto 8px;
17
+ height: 34px;
18
+ line-height: 1.7;
19
+ padding: 5px 12px;
20
+ width: 100%;
21
+
22
+ &.is-disabled {
23
+ background-color: @color-gray-x-light;
24
+ cursor: not-allowed;
25
+ }
26
+ }
27
+
28
+ .c-font-selector__select__icon {
29
+ padding-top: 4px;
30
+ }
31
+
32
+ .c-font-selector__warning {
33
+ color: @color-danger;
34
+ position: absolute;
35
+ right: 0;
36
+ }
37
+
38
+ .c-font-selector__dropdown {
39
+ background-color: #fff;
40
+ border: 1px solid @color-gray-x-light;
41
+ border-radius: 4px;
42
+ box-shadow: @dropdown-box-shadow;
43
+ display: none;
44
+ max-height: 300px;
45
+ position: absolute;
46
+ top: 36px;
47
+ width: 370px;
48
+ z-index: 2;
49
+
50
+ &.is-visible {
51
+ display: block;
52
+ }
53
+
54
+ &.is-showing-popular {
55
+ max-height: 330px;
56
+ }
57
+ }
58
+
59
+ .c-font-selector__dropdown__label {
60
+ border-bottom: 1px solid @color-gray-light;
61
+ color: @color-gray-light;
62
+ font-size: 13px;
63
+ font-style: italic;
64
+ padding: 5px 10px;
65
+ }
66
+
67
+ .o-form-control.c-font-selector__input {
68
+ margin: 4px 3px 10px;
69
+ outline: none;
70
+ padding-right: 36px; // add padding to not allow text under close button
71
+ width: 362px;
72
+
73
+ .c-font-selector__dropdown.is-showing-popular & {
74
+ margin: 4px 3px 0;
75
+ }
76
+ }
77
+
78
+ .c-font-selector__dropdown__spinner.far {
79
+ // combination selector used to override FA styles
80
+ display: none;
81
+ position: absolute;
82
+ right: 10px;
83
+ top: 14px;
84
+
85
+ &.is-visible {
86
+ display: inline;
87
+ }
88
+ }
89
+
90
+ .c-font-selector__dropdown__close {
91
+ cursor: pointer;
92
+ display: inline;
93
+ font-size: 20px;
94
+ position: absolute;
95
+ right: 10px;
96
+ top: 11px;
97
+
98
+ &:hover {
99
+ color: @color-gray-x-dark;
100
+ }
101
+ }
102
+
103
+ .c-font-selector__dropdown__matches {
104
+ max-height: 250px;
105
+ overflow-y: auto;
106
+ }
107
+
108
+ .c-font-selector__match-row {
109
+ cursor: pointer;
110
+ padding: 5px 10px;
111
+
112
+ &.with-mouse:hover,
113
+ &.with-keyboard.is-selected {
114
+ background-color: @color-gray-xx-light;
115
+ }
116
+ }
@@ -1,9 +1,8 @@
1
1
  import { Component, Inject, Input, Output } from '../decorators'
2
2
  import GoogleWebfontsApiService from './google-webfonts-api.service'
3
- import { AutoCompleteMatchObject } from '../auto-complete/auto-complete-match-renderer.component'
4
3
  import WebfontLoaderService from './webfont-loader.service'
5
4
  import { TranslateFactory } from '../translate/translate-factory'
6
-
5
+ import _ from 'lodash'
7
6
 
8
7
  export interface FontFamilyStyle {
9
8
  'font-family': string
@@ -16,48 +15,242 @@ export interface FontFamilyStyle {
16
15
 
17
16
  export default class FontSelectorController implements ng.IComponentController {
18
17
 
19
- @Input() isDisabled?: boolean
20
- @Input() isRequired?: boolean
21
- @Output() onFontSelect!: (param: { font: google.fonts.WebfontFamily }) => void
18
+ @Input('<') inputId!: string
19
+ @Input('<') isDisabled?: boolean
20
+ @Input('<') isRequired?: boolean
21
+ @Input('=?') fontFamily?: string
22
+
23
+ @Output('&?') onFontSelect?: (param: { fontFamily: string }) => void
22
24
 
25
+ protected delay: number = 500
26
+ protected googleFonts: string[]
27
+ protected inputValue?: string
28
+ protected interactionMode: 'mouse' | 'keyboard' = 'mouse'
29
+ protected isDropdownVisible: boolean
30
+ protected isFetching: boolean
31
+ protected kbSelectedIndex = -1
32
+ protected keyEventElement: HTMLInputElement | null = null
33
+ protected loadingFonts: boolean = true
23
34
  protected placeholderText!: string
35
+ protected popularFonts: string[]
36
+ protected matches: string[] = []
37
+ protected minLength: number = 2
38
+ protected requiredText: string
39
+ protected showPopular: boolean = true
40
+
41
+ private debouncedFetchAndSetMatches = _.debounce(() => this.fetchAndSetMatches(), this.delay)
42
+ private inputElement: HTMLElement
43
+ private observer: MutationObserver
24
44
 
25
45
  constructor (
46
+ @Inject('$document') private $document: ng.IDocumentService,
47
+ @Inject('$element') private $element: ng.IAugmentedJQuery,
48
+ @Inject('$timeout') private $timeout: ng.ITimeoutService,
49
+ @Inject('$q') private $q: ng.IQService,
26
50
  @Inject('googleWebfontsApiService') private googleWebfontsApiService: GoogleWebfontsApiService,
27
51
  @Inject('translateFactory') private translateFactory: TranslateFactory,
28
52
  @Inject('webfontLoaderService') private webfontLoaderService: WebfontLoaderService,
29
53
  ) {}
30
54
 
31
- protected googleFonts: google.fonts.WebfontFamily[]
55
+ $onDestroy() {
56
+ if (this.keyEventElement) {
57
+ this.keyEventElement.removeEventListener('input', this.debouncedFetchAndSetMatches)
58
+ this.keyEventElement.removeEventListener('keydown', this.onKeyDown)
59
+ }
60
+
61
+ const body = (this.$document[0] as Document).body
62
+ body.removeEventListener('click', this.onClickElsewhere)
63
+
64
+ this.observer.disconnect()
65
+ }
32
66
 
33
67
  $onInit() {
68
+ if (!this.inputId) { throw new Error(`You must provide a string to key-event-element-id on the AutoCompleteMatchRenderer.`) }
34
69
  // set label text
35
- this.placeholderText = this.translateFactory.instant('JSUI.SEARCH_FONTS')
70
+ this.placeholderText = this.translateFactory.instant('JSUI.SEARCH_ALL_FONTS')
71
+
72
+ this.requiredText = this.translateFactory.instant('JSUI.REQUIRED')
73
+
74
+ // init list of popylar fonts
75
+ this.googleWebfontsApiService.getFontList('popularity')
76
+ .then(popularList => {
77
+ this.popularFonts = popularList.map(f => f.family)
78
+ this.popularFonts = this.popularFonts.slice(0, 50)
79
+ this.webfontLoaderService.loadFonts(this.popularFonts)
80
+ this.matches = this.popularFonts
81
+ })
36
82
 
37
83
  // init list of google fonts
38
84
  this.googleWebfontsApiService.getFontList()
39
- .then(fontList => { this.googleFonts = fontList })
85
+ .then(fontList => {
86
+ this.googleFonts = fontList.map(f => f.family)
87
+ this.loadingFonts = false
88
+ })
89
+
90
+ const body = (this.$document[0] as Document).body
91
+ body.addEventListener('click', this.onClickElsewhere)
92
+
93
+ // Set up an observer that will find the input element and attach events when it is present.
94
+ this.observer = new MutationObserver(() => {
95
+ // expect the tag-input component to be defined in a div with the id autocomplete-tag-lookup
96
+ // this allows us to more reliably find the input to listen to when there are multiple instances of this combination
97
+ this.inputElement = this.$element.parent().find(`#${this.inputId}`)[0]
98
+ if (this.inputElement) {
99
+ this.keyEventElement = this.inputElement as HTMLInputElement
100
+ this.keyEventElement.addEventListener('input', this.debouncedFetchAndSetMatches)
101
+ this.keyEventElement.addEventListener('keydown', this.onKeyDown)
102
+ this.observer.disconnect()
103
+ }
104
+ })
105
+
106
+ this.observer.observe(body, { attributes: true, childList: true, characterData: false, subtree: true })
107
+ }
108
+
109
+ protected clearInput($event): void {
110
+ this.inputValue = ''
111
+ this.matches = this.popularFonts
112
+ this.showPopular = true
113
+ $event.stopPropagation()
114
+ }
115
+
116
+ protected clickSelect($event): void {
117
+ if (this.isDisabled) { return }
118
+ this.isDropdownVisible = !this.isDropdownVisible
119
+ if (this.isDropdownVisible) {
120
+ this.$timeout(() => {
121
+ this.inputElement.focus()
122
+ }, 250)
123
+ }
124
+ $event.stopPropagation()
125
+ }
126
+
127
+ // When the user mouses over the dropdown, we should remove any keyboard
128
+ // highlighting, since the mouse hover provides it too.
129
+ dropdownWasMousedOver() {
130
+ this.interactionMode = 'mouse'
131
+ this.kbSelectedIndex = -1
132
+ }
133
+
134
+ protected inputClick($event): void{
135
+ $event.stopPropagation()
136
+ }
137
+
138
+ protected inputValueWasChanged() {
139
+ this.debouncedFetchAndSetMatches()
140
+ }
141
+
142
+ protected matchWasSelected(match: string) {
143
+ this.matches = this.popularFonts
144
+ this.showPopular = true
145
+ this.kbSelectedIndex = -1
146
+ this.inputValue = ''
147
+ this.fontFamily = match
148
+ this.isDropdownVisible = false
149
+ if (this.onFontSelect) {
150
+ this.onFontSelect({fontFamily: this.fontFamily})
151
+ }
40
152
  }
41
153
 
42
- protected onFontLookup(value: string): AutoCompleteMatchObject<google.fonts.WebfontFamily>[] {
154
+ protected onFontLookup(value: string): ng.IPromise<string[]> {
43
155
 
156
+ value = value.toLocaleLowerCase()
157
+
158
+ // const fonts: google.fonts.WebfontFamily[] = []
44
159
  const fonts = this.googleFonts.filter(font => {
45
- return font.family.toLowerCase().includes(value.toLowerCase())
160
+ return font.toLowerCase().includes(value)
46
161
  })
47
162
 
48
163
  // load this set with the api service
49
164
  this.webfontLoaderService.loadFonts(fonts)
50
165
 
166
+ return this.$q.resolve(fonts)
167
+ }
168
+
169
+ private fetchAndSetMatches(): void {
170
+
171
+ this.isFetching = true
172
+
173
+ const input = this.inputValue || (this.keyEventElement ? this.keyEventElement.value : '')
174
+
175
+ if (input.length < this.minLength) {
176
+ this.$timeout(() => {
177
+ this.matches = this.popularFonts
178
+ this.showPopular = true
179
+ })
180
+ return
181
+ }
51
182
 
52
- return fonts.map(font => ({
53
- cssStyle: { 'font-family': font.family } as FontFamilyStyle,
54
- displayValue: font.family,
55
- value: font
56
- }))
183
+ this.isFetching = true
57
184
 
185
+ // Wrap the entire fetch in a timeout so that fetching callbacks will
186
+ // be called correctly while the async part happens.
187
+ this.$timeout(() => {
188
+ this.$q.when(this.onFontLookup(input))
189
+ .then(matches => {
190
+ this.matches = matches
191
+ this.showPopular = false
192
+ this.isFetching = false
193
+ })
194
+ })
58
195
  }
59
196
 
60
- protected onSelect(font: google.fonts.WebfontFamily) {
61
- this.onFontSelect({ font })
197
+ private onClickElsewhere = ($event: MouseEvent) => {
198
+
199
+ this.$timeout(() => {
200
+ this.isDropdownVisible = false
201
+ })
62
202
  }
203
+
204
+ private onKeyDown = ($event: KeyboardEvent) => this.$timeout(() => {
205
+
206
+ this.interactionMode = 'keyboard'
207
+
208
+ // Enter with no selection: let the $event through
209
+ if ($event.key === 'Enter' && this.kbSelectedIndex === -1) { return }
210
+
211
+ // If the dropdown is closed, all we can do is arrow down to open the thing
212
+ if (this.matches.length === 0 && $event.key !== 'ArrowDown') { return }
213
+
214
+ // Escape: close the dropdown
215
+ if ($event.key === 'Escape') {
216
+ this.matches = this.popularFonts
217
+ this.showPopular = true
218
+ }
219
+
220
+ // Arrow down with dropdown closed: fetch matches
221
+ if ($event.key === 'ArrowDown' && this.matches.length === 0) {
222
+ this.fetchAndSetMatches()
223
+ }
224
+
225
+ // Arrow keys with dropdown open: move the selection highlight
226
+ if ($event.key === 'ArrowDown' && this.matches.length > 0) {
227
+ const idx = Math.min(this.kbSelectedIndex + 1, this.matches.length - 1)
228
+ this.kbSelectedIndex = idx
229
+ this.scrollToMatch(idx)
230
+ }
231
+
232
+ if ($event.key === 'ArrowUp') {
233
+ const idx = Math.max(this.kbSelectedIndex - 1, 0)
234
+ this.kbSelectedIndex = idx
235
+ this.scrollToMatch(idx)
236
+ }
237
+
238
+ // Enter with a selection: set the selection to the currently highlighted match
239
+ if ($event.key === 'Enter' && this.kbSelectedIndex > -1) {
240
+ const match = this.matches[this.kbSelectedIndex]
241
+ this.matchWasSelected(match)
242
+ $event.preventDefault()
243
+ }
244
+
245
+ $event.stopPropagation()
246
+ })
247
+
248
+ private scrollToMatch(index: number) {
249
+
250
+ const row = this.$element.find('.c-font-selector__match-row')[index] as HTMLDivElement
251
+ if (row) {
252
+ row.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
253
+ }
254
+ }
255
+
63
256
  }
@@ -3,6 +3,6 @@ import angular from 'angular'
3
3
  angular.module('app').run((
4
4
  $httpBackend: ng.IHttpBackendService
5
5
  ) => {
6
- $httpBackend.whenGET('https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyB-3EKXiPv1rjJ0Ab3u4s9iUaTqHXMLVOI').passThrough()
6
+ $httpBackend.whenGET(/^https:\/\/www.googleapis.com\/webfonts\/v1\/webfonts\?key=AIzaSyB-3EKXiPv1rjJ0Ab3u4s9iUaTqHXMLVOI(.*)?/).passThrough()
7
7
  })
8
8
 
@@ -10,8 +10,16 @@ export default class GoogleWebfontsApiService {
10
10
  ) { }
11
11
 
12
12
 
13
- getFontList(): ng.IPromise<google.fonts.WebfontFamily[]> {
14
- return this.$http.get<google.fonts.WebfontList>('https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyB-3EKXiPv1rjJ0Ab3u4s9iUaTqHXMLVOI')
13
+ getFontList(sort?: string): ng.IPromise<google.fonts.WebfontFamily[]> {
14
+ const call = 'https://www.googleapis.com/webfonts/v1/webfonts'
15
+
16
+ if (!sort) { sort = 'alpha' }
17
+
18
+ const params = {
19
+ key: 'AIzaSyB-3EKXiPv1rjJ0Ab3u4s9iUaTqHXMLVOI',
20
+ sort,
21
+ }
22
+ return this.$http.get<google.fonts.WebfontList>(call, { params })
15
23
  .then((response) => {
16
24
  return this.apiSuccessHandler.response(response).items
17
25
  })
@@ -5,9 +5,9 @@ import WebFont from 'webfontloader'
5
5
  export default class WebfontLoaderService {
6
6
 
7
7
 
8
- loadFonts(fontList: google.fonts.WebfontFamily[]): void {
8
+ loadFonts(families: string[]): void {
9
9
 
10
- const families = fontList.map(f => f.family)
10
+ // const families = fontList.map(f => f.family)
11
11
  let hasFonts = true
12
12
 
13
13
  try {
@@ -9,6 +9,7 @@
9
9
  @import './dropdown/dropdown';
10
10
  @import './feedback/feedback';
11
11
  @import './first-time-motivator/first-time-motivator';
12
+ @import './font-selector/font-selector';
12
13
  @import './footer/footer';
13
14
  @import './hierarchy/hierarchy';
14
15
  @import './hover-tooltip/hover-tooltip';
@@ -24,7 +25,6 @@
24
25
  @import './paging/paging';
25
26
  @import './progress-bar/progress-bar';
26
27
  @import './progress-circle/progress-circle';
27
- @import './rich-text/rich-text-toolbar-container.less';
28
28
  @import './rich-text/rich-text.component.less';
29
29
  @import './site-header/site-header';
30
30
  @import './slides/slides';
@@ -182,12 +182,20 @@
182
182
  // Small button
183
183
  // -------------------------------------------------
184
184
  &.o-button--small {
185
+ background: #fff;
186
+ border: 1px solid @color-gray-x-light;
185
187
  border-radius: 16px;
186
188
  font-size: 13px;
187
189
  font-weight: @font-weight-regular;
188
190
  line-height: 1;
189
191
  padding: 6px 12px;
190
192
  white-space: nowrap;
193
+
194
+ @media (hover) {
195
+ &:hover {
196
+ .hover-button();
197
+ }
198
+ }
191
199
  }
192
200
 
193
201
  // Fix outline border-radius for smaller buttons
@@ -96,12 +96,23 @@
96
96
  }
97
97
 
98
98
  .button.isSmall {
99
+ background: #fff;
100
+ border: 1px solid var(--color-gray-x-light);
99
101
  border-radius: 16px;
100
102
  font-size: 13px;
101
103
  font-weight: var(--font-weight-regular);
102
104
  height: auto; /* Match the non-module large button height instead of using fixed height of flex button */
103
105
  line-height: 1;
104
106
  padding: 6px 12px;
107
+
108
+ /* We set an explicit background on this button so we need more specificity on the hover style: */
109
+ @media (hover: hover) {
110
+ &:hover {
111
+ background-color: var(--color-button-default-hover-background);
112
+ border-color: var(--color-button-default-hover-border);
113
+ color: var(--color-button-default-text);
114
+ }
115
+ }
105
116
  }
106
117
 
107
118
  .button.isRoundRect {
@@ -29,8 +29,8 @@
29
29
  // ----------------------------------------------
30
30
  @color-success-light: #d8f2e6;
31
31
  @color-success: #008c48;
32
- @color-danger-light: #f7dfe4;
33
- @color-danger: #d90d36;
32
+ @color-danger-light: #f9ebee;
33
+ @color-danger: #89142e;
34
34
  @color-warning-light: #f9e4de;
35
35
  @color-warning: #de6a44;
36
36
  @color-info-light: #d8edf5;
@@ -32,8 +32,8 @@
32
32
  /* UI colors */
33
33
  --color-success-light: #d8f2e6;
34
34
  --color-success: #008c48;
35
- --color-danger-light: #f7dfe4;
36
- --color-danger: #d90d36;
35
+ --color-danger-light: #f9ebee;
36
+ --color-danger: #89142e;
37
37
  --color-warning-light: #f9e4de;
38
38
  --color-warning: #de6a44;
39
39
  --color-info-light: #d8edf5;
@@ -34,7 +34,7 @@
34
34
  "PRIVACY_POLICY": "Privacy Policy",
35
35
  "RECENT_CHANGES": "Recent Changes",
36
36
  "REQUIRED": "Required",
37
- "SEARCH_FONTS": "Search fonts",
37
+ "SEARCH_ALL_FONTS": "Search all fonts",
38
38
  "STATUS_CHECK": "Status Check",
39
39
  "SUPPORT": "Need help?",
40
40
  "TERMS_OF_USE": "Terms of Use",
@@ -1,2 +1 @@
1
1
  import './rich-text.component'
2
- import './rich-text-toolbar-container.component'
@@ -1,19 +1,11 @@
1
1
  <div id="toolbar" class="c-rich-text">
2
2
 
3
- <span ng-if="$ctrl.allowFontSelection" class="ql-formats">
4
- <mfly:rich-text-toolbar-container>
5
- <mfly:toolbar-icon>
6
- <span ng-style="$ctrl.fontStyle">{{ $ctrl.selectedFont }}</span>
7
- <span class="c-rich-text-sort fas fa-sort"></span>
8
- </mfly:toolbar-icon>
9
- <mfly:toolbar-container>
10
- <mfly:font-selector
11
- label-text="{{ $ctrl.fontLabelText }}"
12
- on-font-select="$ctrl.fontSelected(font)">
13
- </mfly:font-selector>
14
- </mfly:toolbar-container>
15
- </mfly:rich-text-toolbar-container>
16
-
3
+ <span ng-if="$ctrl.allowFontSelection" class="ql-formats c-rich-text-font-container">
4
+ <mfly:font-selector
5
+ input-id="$ctrl.fontSelectorId"
6
+ font-family="$ctrl.selectedFont"
7
+ on-font-select="$ctrl.fontSelected(fontFamily)">
8
+ </mfly:font-selector>
17
9
  </span>
18
10
 
19
11
  <span class="ql-formats">
@@ -34,7 +34,7 @@ rich-text {
34
34
  }
35
35
 
36
36
  // override validation coloring
37
- .c-auto-complete__input {
37
+ .c-font-selector__dropdown__input {
38
38
  .c-rich-text & {
39
39
  border-color: #bbb !important; /* stylelint-disable-line declaration-no-important */
40
40
  }
@@ -45,6 +45,10 @@ rich-text {
45
45
  padding-left: 8px;
46
46
  }
47
47
 
48
+ .c-rich-text-font-container {
49
+ min-width: 140px;
50
+ }
51
+
48
52
  // Color class overrides
49
53
  .ql-color-\#e60000 { color: #e60000; }
50
54
  .ql-color-\#ff9900 { color: #f90; }
@@ -14,6 +14,7 @@ export default class RichTextComponentController implements ng.IComponentControl
14
14
  protected allowColorSelection?: boolean
15
15
  protected allowFontSelection?: boolean
16
16
  protected fontStyle?: FontFamilyStyle
17
+ protected fontSelectorId: string
17
18
  protected isRequired: boolean
18
19
  protected requiredText: string
19
20
  protected selectedColor: string
@@ -55,6 +56,7 @@ export default class RichTextComponentController implements ng.IComponentControl
55
56
  this.requiredText = this.translateFactory.instant('JSUI.REQUIRED')
56
57
  this.selectedColor = this.DEFAULT_COLOR
57
58
  this.selectedFont = this.DEFAULT_FONT
59
+ this.fontSelectorId = 'rteFontSelector' + Math.floor(Math.random() * 1000 + 1)
58
60
 
59
61
  this.colorPicker = document.getElementById('rteColorInput')
60
62
  this.colorPicker.addEventListener('change', this.colorChanged.bind(this))
@@ -109,15 +111,15 @@ export default class RichTextComponentController implements ng.IComponentControl
109
111
  this.applyColor()
110
112
  }
111
113
 
112
- protected fontSelected(font: google.fonts.WebfontFamily): void {
113
- if (font.family) {
114
+ protected fontSelected(fontFamily: string): void {
115
+ if (fontFamily) {
114
116
 
115
117
  this.$rootScope.$broadcast('richTextToolbarContainer:closeContainer')
116
118
  const fontAtributor = Quill.import('attributors/style/font')
117
- fontAtributor.whitelist = [font.family]
118
- this.updateFontDisplay(font.family)
119
+ fontAtributor.whitelist = [fontFamily]
120
+ this.updateFontDisplay(fontFamily)
119
121
  Quill.register(fontAtributor, true)
120
- this.editor.format('font', font.family)
122
+ this.editor.format('font', fontFamily)
121
123
 
122
124
  this.sanitizeContents()
123
125
  }