apostrophecms / apostrophecms/content-upgrader

Can't override core mapWidgetTypes

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
JavaScript
Stars
3
Forks
1
PR merge metrics
No merged PRs in 30d

Description

## Question or comment

Please include as much detail as possible so we can help more quickly.
* The way it is written, `self.options.mapWidgetTypes` takes any user-entered configuration, spreads it, then adds core widget config. This prevents users from overriding the core widget mapping. For image widgets it could be especially useful to be able to identify a different widget type and data structure

## Details

Current mapping:
```
self.options.mapWidgetTypes = {
...self.options.mapWidgetTypes,
'apostrophe-rich-text': '@apostrophecms/rich-text',
'apostrophe-images': async (widget) => ({
...widget,
type: '@apostrophecms/image',
imageFields: widget.relationships,
imageIds: (widget.pieceIds || []).slice(0, 1)
}),
'apostrophe-video': '@apostrophecms/video',
'apostrophe-html': '@apostrophecms/html'
};
```

https://github.com/apostrophecms/content-upgrader/blob/f405ce4ef16fb5803ac29f2a2b424bdb15426e9a/index.js#L29-L40

Contributor guide

Open the contributing guide

Research direction

Start in index.js around lines 29-40, where self.options.mapWidgetTypes is assembled. Check the mapping precedence and make the requested override behavior possible, including custom image widget types and data structures; done means user-entered mappings can replace the core widget mappings.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.