Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-31137: Fixed styles dropdown when custom ones are in use for RTE #1217

Merged
merged 4 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class EzBtnStylesListItem extends AlloyEditor.ButtonStylesListIte
className={className}
dangerouslySetInnerHTML={{ __html: this._preview }}
onClick={() => {
this.clearEzAttributes();
dew326 marked this conversation as resolved.
Show resolved Hide resolved
this._onClick();
this.fireCustomUpdateEvent();
}}
Expand All @@ -26,6 +27,16 @@ export default class EzBtnStylesListItem extends AlloyEditor.ButtonStylesListIte
);
}

clearEzAttributes() {
const nativeEditor = this.props.editor.get('nativeEditor');
const block = nativeEditor.elementPath().block;
const attrsToRemove = ['ezelement', 'eztype', 'ezname'];

if (block.$.dataset.eztype === 'style') {
attrsToRemove.forEach(attr => block.$.removeAttribute('data-' + attr));
}
}

fireCustomUpdateEvent() {
const nativeEditor = this.props.editor.get('nativeEditor');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ export default class EzCustomStyleConfig extends EzConfigBase {
this.addExtraButtons(config.extraButtons);
}

getStyles(customStyles = []) {
return {
name: 'styles',
cfg: {
showRemoveStylesItem: false,
styles: [...customStyles],
},
};
}

/**
* Tests whether the `custom style` toolbar should be visible. It is
* visible when an existing custom style gets the focus.
Expand Down