Skip to content

Commit

Permalink
feat(slate): Add css identifier to slate style menu options (#4847)
Browse files Browse the repository at this point in the history
Co-authored-by: Steve Piercy <web@stevepiercy.com>
  • Loading branch information
razvanMiu and stevepiercy authored Jun 9, 2023
1 parent c0bec37 commit 8d74597
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/4846.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a CSS identifier to the Slate style menu options. @razvanMiu
18 changes: 14 additions & 4 deletions packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const StyleMenuButton = ({ icon, active, ...props }) => (
<ToolbarButton {...props} icon={icon} active={active} />
);

const MenuOpts = ({ editor, toSelect, option, ...rest }) => {
const MenuOpts = ({ editor, toSelect, option, type }) => {
const isActive = toSelect.includes(option);
return (
<Dropdown.Item
as="span"
active={isActive}
className={cx({ active: isActive })}
className={cx(`${type}-${option.value}`, { active: isActive })}
{...omit(option, ['isBlock'])}
data-isblock={option.isBlock}
onClick={(event, selItem) => {
Expand Down Expand Up @@ -118,7 +118,12 @@ const StylingsButton = (props) => {
content={intl.formatMessage(messages.inlineStyle)}
/>
{inlineOpts.map((option, index) => (
<MenuOpts {...menuItemProps} option={option} key={index} />
<MenuOpts
{...menuItemProps}
type="inline-style"
option={option}
key={index}
/>
))}
</>
)}
Expand All @@ -129,7 +134,12 @@ const StylingsButton = (props) => {
content={intl.formatMessage(messages.paragraphStyle)}
/>
{blockOpts.map((option, index) => (
<MenuOpts {...menuItemProps} option={option} key={index} />
<MenuOpts
{...menuItemProps}
type="block-style"
option={option}
key={index}
/>
))}
</>
)}
Expand Down

0 comments on commit 8d74597

Please sign in to comment.