Help us learn about your current experience with the documentation. Take the survey.

表情符号

GitLab 通过 tanuki_emoji gem 原生支持表情符号。

如何更新表情符号

由于我们的表情符号支持同时在后端和前端实现,我们需要在三个里程碑中更新支持。

第一个里程碑(后端)

  1. 根据需要更新 tanuki_emoji gem。
  2. 更新 Gemfile 以使用最新的 tanuki_emoji gem。
  3. 更新 Gemfile 以使用支持您要升级到的 Unicode 版本的最新 unicode-emoji
  4. 更新 lib/gitlab/emoji.rb 中的 EMOJI_VERSION
  5. bundle exec rake tanuki_emoji:import - 将所有备用图像导入到版本化的 public/-/emojis 目录。 确保看到新的单独图像被复制到那里。
  6. 测试时,您应该能够使用任何新表情符号的短代码并显示它们。
  7. 有关后端的示例 MR,请参见 onetwo

第二个里程碑(前端)

  1. 更新 app/assets/javascripts/emoji/index.js 中的 EMOJI_VERSION
  2. 使用 tanuki_emoji gem 的 Rake tasks 来更新别名、摘要和精灵图。按以下顺序运行:
    1. bundle exec rake tanuki_emoji:aliases - 更新 fixtures/emojis/aliases.json

    2. bundle exec rake tanuki_emoji:digests - 更新 public/-/emojis/VERSION/emojis.jsonfixtures/emojis/digests.json

    3. bundle exec rake tanuki_emoji:sprite - 创建新的精灵图

      如果添加了新的表情符号,精灵图的大小可能会改变。为了补偿 这种变化,首先使用上述 Rake 任务生成 app/assets/images/emoji.png 精灵图, 然后检查新精灵图的尺寸并相应地更新 lib/tasks/tanuki_emoji.rake 中的 SPRITESHEET_WIDTHSPRITESHEET_HEIGHT 常量。 然后重新运行该任务。

      • 使用 ImageOptim 或类似程序优化图像大小
  3. 确保为 1x 和 2x 生成了新的精灵图
    • app/assets/images/emoji.png
    • app/assets/images/emoji@2x.png
  4. 使用任何我们想要突出显示为具有积极或消极意图的新表情符号更新 fixtures/emojis/intents.json
    • 积极意图应设置为 0.5
    • 中性意图可以设置为 1。这会自动应用于所有表情符号,因此无需明确设置。
    • 消极意图应设置为 1.5
  5. 您可能需要为不支持特定表情符号且需要回退到图像的平台 添加新的表情符号 Unicode 支持检查和规则。 请参见 app/assets/javascripts/emoji/support/is_emoji_unicode_supported.jsapp/assets/javascripts/emoji/support/unicode_support_map.js
  6. 确保使用与支持的 Unicode 版本对应的 emoji-regex 版本。 这应该在 package.json 中更新。用于 在 app/assets/javascripts/emoji/index.js 中过滤表情符号。
  7. 类别名称是否有任何更改?如果有,则需要更新 app/assets/javascripts/emoji/constants.js
  8. 测试时
    1. 确保您可以在 GitLab Flavored Markdown (GLFM) 自动补全中看到新表情符号及其别名
    2. 确保您可以在表情符号反应菜单中看到新表情符号及其别名

第三个里程碑(清理)

public/-/emojis 目录中删除任何旧的表情符号版本。这不是严格必需的 - 如果不执行此操作,一切仍能正常工作。但清理一下是好的。