我只需要在Draft-js-emoji-plugin 中扩展几个 CSS 规则。
记录的方法是将theme
对象传递给配置:
const theme = {
emojiSelectButton: 'someclassname'
};
const emojiPlugin = createEmojiPlugin({theme});
不幸的是,这会覆盖整个主题类名,而不是添加一个。根据代码中的注释,此行为是设计使然:
// Styles are overwritten instead of merged as merging causes a lot of confusion.
//
// Why? Because when merging a developer needs to know all of the underlying
// styles which needs a deep dive into the code. Merging also makes it prone to
// errors when upgrading as basically every styling change would become a major
// breaking change. 1px of an increased padding can break a whole layout.
在相关问题中,开发人员建议draft-js-emoji-plugin/lib/plugin.css
在代码中导入和扩展它。无论如何,这个文件中的每个类名都有后缀(CSS module),它们可能会被更改,因此它是可靠的。
我不知道如何在不处理整个主题的情况下应用多个修复程序。