Add suggest menu for user mentions in text editor

This commit is contained in:
Frederic Guillot
2016-11-27 15:44:45 -05:00
parent 04ff67e26b
commit d8b0423d15
21 changed files with 454 additions and 30 deletions

View File

@@ -52,6 +52,37 @@ function array_column_index(array &$input, $column)
return $result;
}
/**
* Create indexed array from a list of dict with unique values
*
* $input = [
* ['k1' => 1, 'k2' => 2], ['k1' => 3, 'k2' => 4], ['k1' => 1, 'k2' => 5]
* ]
*
* array_column_index_unique($input, 'k1') will returns:
*
* [
* 1 => ['k1' => 1, 'k2' => 2],
* 3 => ['k1' => 3, 'k2' => 4],
* ]
*
* @param array $input
* @param string $column
* @return array
*/
function array_column_index_unique(array &$input, $column)
{
$result = array();
foreach ($input as &$row) {
if (isset($row[$column]) && ! isset($result[$row[$column]])) {
$result[$row[$column]] = $row;
}
}
return $result;
}
/**
* Sum all values from a single column in the input array
*