Skip to content

Commit 1616a28

Browse files
committed
Add feature flag to allow custom text colors
REDMINE-21001
1 parent 7ae152c commit 1616a28

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

entry_types/scrolled/lib/pageflow_scrolled/plugin.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def configure(config)
4848
c.features.register('frontend_v2')
4949
c.features.register('scrolled_entry_fragment_caching')
5050
c.features.register('backdrop_content_elements')
51+
c.features.register('custom_palette_colors')
5152

5253
c.additional_frontend_seed_data.register(
5354
'frontendVersion',

entry_types/scrolled/package/src/contentElements/textBlock/editor.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,35 @@ editor.contentElementTypes.register('textBlock', {
1111
supportedPositions: ['inline'],
1212

1313
configurationEditor({entry, contentElement}) {
14-
this.listenTo(contentElement.transientState,
15-
'change:exampleNode',
16-
() => this.refresh());
14+
let pendingRefresh;
15+
16+
this.listenTo(
17+
contentElement.transientState,
18+
'change:exampleNode',
19+
() => {
20+
// This is a terrible hack to prevent closing the minicolors
21+
// dropdown while adjusting colors. Calling refresh is needed
22+
// to update typography drop downs. Delay until color picker
23+
// is closed.
24+
if (document.activeElement &&
25+
document.activeElement.tagName === 'INPUT' &&
26+
document.activeElement.className === 'minicolors-input') {
27+
28+
if (!pendingRefresh) {
29+
document.activeElement.addEventListener('blur', () => {
30+
pendingRefresh = false;
31+
this.refresh()
32+
}, {once: true});
33+
34+
pendingRefresh = true;
35+
}
36+
37+
return;
38+
}
39+
40+
this.refresh()
41+
}
42+
);
1743

1844
this.tab('general', function() {
1945
const exampleNode = ensureTextContent(

entry_types/scrolled/package/src/editor/views/configurationEditors/groups/CommonContentElementAttributes.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
import {ConfigurationEditorTabView, CheckBoxInputView, SelectInputView, SliderInputView} from 'pageflow/ui';
1+
import {features} from 'pageflow/frontend';
2+
3+
import {
4+
ConfigurationEditorTabView,
5+
CheckBoxInputView,
6+
SelectInputView,
7+
SliderInputView
8+
} from 'pageflow/ui';
29

310
import {
411
TypographyVariantSelectInputView
512
} from '../../inputs/TypographyVariantSelectInputView';
613

14+
import {
15+
ColorSelectOrCustomColorInputView
16+
} from '../../inputs/ColorSelectOrCustomColorInputView';
17+
718
import {
819
ColorSelectInputView
920
} from '../../inputs/ColorSelectInputView';
@@ -144,14 +155,20 @@ ConfigurationEditorTabView.groups.define(
144155
'PaletteColor',
145156
function({propertyName, entry, model}) {
146157
const [values, texts] = entry.getPaletteColors();
158+
const inputView = features.isEnabled('custom_palette_colors') ?
159+
ColorSelectOrCustomColorInputView :
160+
ColorSelectInputView;
147161

148162
if (values.length) {
149-
this.input(propertyName, ColorSelectInputView, {
163+
this.input(propertyName, inputView, {
150164
model: model || this.model,
151165
includeBlank: true,
152166
blankTranslationKey: 'pageflow_scrolled.editor.' +
153167
'common_content_element_attributes.' +
154168
'palette_color.blank',
169+
customColorTranslationKey: 'pageflow_scrolled.editor.' +
170+
'common_content_element_attributes.' +
171+
'palette_color.custom',
155172
values,
156173
texts,
157174
});

0 commit comments

Comments
 (0)