Skip to content

Commit 61a7f37

Browse files
committed
Add default section appearance setting
Allow editors to configure the default text background style (shadow, cards, or transparent) for new sections.
1 parent e41b3e4 commit 61a7f37

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

entry_types/scrolled/config/locales/de.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,13 @@ de:
14781478
centerRagged: Zentriert
14791479
left: Links
14801480
right: Rechts
1481+
defaultSectionAppearance:
1482+
label: Abblendung
1483+
inline_help: Standard-Erscheinung neuer Abschnitte.
1484+
values:
1485+
cards: Karte
1486+
shadow: Schatten
1487+
transparent: Keine
14811488
topPaddingVisualization:
14821489
label: Abstand oben
14831490
defaultSectionPaddingTop:

entry_types/scrolled/config/locales/en.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,13 @@ en:
14611461
centerRagged: Centered (Ragged)
14621462
left: Left
14631463
right: Right
1464+
defaultSectionAppearance:
1465+
label: Text background
1466+
inline_help: Default appearance of new sections.
1467+
values:
1468+
cards: Card
1469+
shadow: Shadow
1470+
transparent: Transparent
14641471
topPaddingVisualization:
14651472
label: Top padding
14661473
defaultSectionPaddingTop:

entry_types/scrolled/doc/creating_content_element_types.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,57 @@ pageflow_scrolled:
379379
inline_help: "..."
380380
```
381381

382+
## Defaults Inputs
383+
384+
Content element types can contribute inputs to the entry defaults
385+
settings. These inputs allow editors to configure default values that
386+
are applied when creating new content elements of that type.
387+
388+
To define defaults inputs, provide a `defaultsInputs` function when
389+
registering your content element type:
390+
391+
```javascript
392+
import {editor} from 'pageflow-scrolled/editor';
393+
import {CheckBoxInputView} from 'pageflow/ui';
394+
395+
editor.contentElementTypes.register('inlineImage', {
396+
configurationEditor({entry}) {
397+
// ...
398+
},
399+
400+
defaultsInputs() {
401+
this.input('enableFullscreen', CheckBoxInputView);
402+
}
403+
});
404+
```
405+
406+
The `defaultsInputs` function is called in a similar context as the
407+
`this.tab` callback in `configurationEditor`. Property names are
408+
automatically prefixed with `default-{typeName}-` when stored in the
409+
entry metadata configuration.
410+
411+
For translations, Pageflow first looks for keys under a `defaults`
412+
namespace, then falls back to normal attribute translations:
413+
414+
```
415+
pageflow_scrolled:
416+
editor:
417+
content_elements:
418+
inlineImage:
419+
defaults:
420+
attributes:
421+
enableFullscreen:
422+
label: "..."
423+
inline_help: "..."
424+
attributes:
425+
enableFullscreen:
426+
label: "..."
427+
inline_help: "..."
428+
```
429+
430+
If the `defaults.attributes` translation is not found, the normal
431+
`attributes` translation is used as a fallback.
432+
382433
## Using Palette Colors
383434

384435
[Palette

entry_types/scrolled/package/spec/editor/models/Chapter-spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ describe('Chapter', () => {
5959
expect(section.configuration.get('layout')).toEqual('right');
6060
});
6161

62+
it('uses default appearance from entry metadata configuration', () => {
63+
const {entry} = testContext;
64+
65+
entry.metadata.configuration.set('defaultSectionAppearance', 'cards');
66+
const section = entry.chapters.first().addSection();
67+
68+
expect(section.configuration.get('appearance')).toEqual('cards');
69+
});
70+
6271
it('handles sparse positions correctly', () => {
6372
const {entry} = testContext;
6473

entry_types/scrolled/package/src/editor/models/Chapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const Chapter = Backbone.Model.extend({
6565
const defaultConfiguration = options.skipDefaults ? {} : {
6666
transition: this.entry.metadata.configuration.get('defaultTransition'),
6767
layout: this.entry.metadata.configuration.get('defaultSectionLayout'),
68+
appearance: this.entry.metadata.configuration.get('defaultSectionAppearance'),
6869
paddingTop: this.entry.metadata.configuration.get('defaultSectionPaddingTop'),
6970
paddingBottom: this.entry.metadata.configuration.get('defaultSectionPaddingBottom')
7071
};

entry_types/scrolled/package/src/editor/views/EditDefaultsView.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export const EditDefaultsView = EditConfigurationView.extend({
2828
values: ['left', 'right', 'center', 'centerRagged']
2929
});
3030

31+
this.input('defaultSectionAppearance', SelectInputView, {
32+
values: ['shadow', 'cards', 'transparent']
33+
});
34+
3135
if (features.isEnabled('section_paddings')) {
3236
const paddingTopScale = entry.getScale('sectionPaddingTop');
3337
const paddingBottomScale = entry.getScale('sectionPaddingBottom');

0 commit comments

Comments
 (0)