Help us learn about your current experience with the documentation. Take the survey.
表情符号
GitLab 通过 tanuki_emoji gem 原生支持表情符号。
如何更新表情符号
由于我们的表情符号支持同时在后端和前端实现,我们需要在三个里程碑中更新支持。
第一个里程碑(后端)
- 根据需要更新
tanuki_emojigem。 - 更新
Gemfile以使用最新的tanuki_emojigem。 - 更新
Gemfile以使用支持您要升级到的 Unicode 版本的最新unicode-emoji。 - 更新
lib/gitlab/emoji.rb中的EMOJI_VERSION bundle exec rake tanuki_emoji:import- 将所有备用图像导入到版本化的public/-/emojis目录。 确保看到新的单独图像被复制到那里。- 测试时,您应该能够使用任何新表情符号的短代码并显示它们。
- 有关后端的示例 MR,请参见 one 和 two。
第二个里程碑(前端)
- 更新
app/assets/javascripts/emoji/index.js中的EMOJI_VERSION - 使用
tanuki_emojigem 的 Rake tasks 来更新别名、摘要和精灵图。按以下顺序运行:-
bundle exec rake tanuki_emoji:aliases- 更新fixtures/emojis/aliases.json -
bundle exec rake tanuki_emoji:digests- 更新public/-/emojis/VERSION/emojis.json和fixtures/emojis/digests.json -
bundle exec rake tanuki_emoji:sprite- 创建新的精灵图如果添加了新的表情符号,精灵图的大小可能会改变。为了补偿 这种变化,首先使用上述 Rake 任务生成
app/assets/images/emoji.png精灵图, 然后检查新精灵图的尺寸并相应地更新lib/tasks/tanuki_emoji.rake中的SPRITESHEET_WIDTH和SPRITESHEET_HEIGHT常量。 然后重新运行该任务。- 使用 ImageOptim 或类似程序优化图像大小
-
- 确保为 1x 和 2x 生成了新的精灵图
app/assets/images/emoji.pngapp/assets/images/emoji@2x.png
- 使用任何我们想要突出显示为具有积极或消极意图的新表情符号更新
fixtures/emojis/intents.json。- 积极意图应设置为
0.5。 - 中性意图可以设置为
1。这会自动应用于所有表情符号,因此无需明确设置。 - 消极意图应设置为
1.5。
- 积极意图应设置为
- 您可能需要为不支持特定表情符号且需要回退到图像的平台
添加新的表情符号 Unicode 支持检查和规则。
请参见
app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js和app/assets/javascripts/emoji/support/unicode_support_map.js - 确保使用与支持的 Unicode 版本对应的 emoji-regex 版本。
这应该在
package.json中更新。用于 在app/assets/javascripts/emoji/index.js中过滤表情符号。 - 类别名称是否有任何更改?如果有,则需要更新
app/assets/javascripts/emoji/constants.js - 测试时
- 确保您可以在 GitLab Flavored Markdown (GLFM) 自动补全中看到新表情符号及其别名
- 确保您可以在表情符号反应菜单中看到新表情符号及其别名
第三个里程碑(清理)
从 public/-/emojis 目录中删除任何旧的表情符号版本。这不是严格必需的 -
如果不执行此操作,一切仍能正常工作。但清理一下是好的。