Changeset View
Changeset View
Standalone View
Standalone View
src/applications/macro/markup/PhabricatorEmojiRemarkupRule.php
<?php | <?php | ||||
final class PhabricatorEmojiRemarkupRule extends PhutilRemarkupRule { | final class PhabricatorEmojiRemarkupRule extends PhutilRemarkupRule { | ||||
public function getPriority() { | public function getPriority() { | ||||
return 200.0; | return 200.0; | ||||
} | } | ||||
public function apply($text) { | public function apply($text) { | ||||
return preg_replace_callback( | return preg_replace_callback( | ||||
'(\B:(\S+):\B)', | '(\B:(\S+):\B)', | ||||
array($this, 'markupEmoji'), | array($this, 'markupEmoji'), | ||||
$text); | $text); | ||||
} | } | ||||
public function markupEmojiJSON() { | |||||
$root = dirname(phutil_get_library_root('phabricator')); | |||||
$json = Filesystem::readFile( | |||||
$root.'/resources/emoji/manifest.json'); | |||||
return $json; | |||||
} | |||||
public function markupEmoji(array $matches) { | public function markupEmoji(array $matches) { | ||||
if (!$this->isFlatText($matches[0])) { | if (!$this->isFlatText($matches[0])) { | ||||
return $matches[0]; | return $matches[0]; | ||||
} | } | ||||
static $map = array( | static $map = array( | ||||
epriestley: We have to keep these intact, as-is, because the two lists are different. For example, if we… | |||||
'watch' => "\xE2\x8C\x9A", | 'watch' => "\xE2\x8C\x9A", | ||||
'hourglass' => "\xE2\x8C\x9B", | 'hourglass' => "\xE2\x8C\x9B", | ||||
'fast_forward' => "\xE2\x8F\xA9", | 'fast_forward' => "\xE2\x8F\xA9", | ||||
'rewind' => "\xE2\x8F\xAA", | 'rewind' => "\xE2\x8F\xAA", | ||||
'arrow_double_up' => "\xE2\x8F\xAB", | 'arrow_double_up' => "\xE2\x8F\xAB", | ||||
'arrow_double_down' => "\xE2\x8F\xAC", | 'arrow_double_down' => "\xE2\x8F\xAC", | ||||
'alarm_clock' => "\xE2\x8F\xB0", | 'alarm_clock' => "\xE2\x8F\xB0", | ||||
'hourglass_flowing_sand' => "\xE2\x8F\xB3", | 'hourglass_flowing_sand' => "\xE2\x8F\xB3", | ||||
▲ Show 20 Lines • Show All 874 Lines • Show Last 20 Lines |
We have to keep these intact, as-is, because the two lists are different. For example, if we make this change (removing this map), :+1: will break in all existing text.
This map basically has to be here forever since we shipped it, unless we're OK breaking a bunch of stuff or want to try to do a migration to replace all the :+1: in stuff in the database with the real emoji.
But you can just safely get rid of this now since the remarkup rule and the emoji typeahead no longer interact at all.