mirror of
https://github.com/flarum/framework.git
synced 2025-04-25 14:14:03 +08:00
commit
6e414568db
11
extensions/emoji/js/forum/dist/extension.js
vendored
11
extensions/emoji/js/forum/dist/extension.js
vendored
@ -176,15 +176,18 @@ System.register('flarum/emoji/addComposerAutocomplete', ['flarum/extend', 'flaru
|
|||||||
|
|
||||||
if (this.selectionEnd - cursor > 0) return;
|
if (this.selectionEnd - cursor > 0) return;
|
||||||
|
|
||||||
// Search backwards from the cursor for an ':' symbol, without any
|
// Search backwards from the cursor for an ':' symbol. If we find
|
||||||
// intervening whitespace. If we find one, we will want to show the
|
// one and followed by a whitespace, we will want to show the
|
||||||
// autocomplete dropdown!
|
// autocomplete dropdown!
|
||||||
var value = this.value;
|
var value = this.value;
|
||||||
emojiStart = 0;
|
emojiStart = 0;
|
||||||
for (var i = cursor - 1; i >= 0; i--) {
|
for (var i = cursor - 1; i >= 0; i--) {
|
||||||
var character = value.substr(i, 1);
|
var character = value.substr(i, 1);
|
||||||
if (/\s/.test(character)) break;
|
// check what user typed, emoji names only contains alphanumeric,
|
||||||
if (character === ':') {
|
// underline, '+' and '-'
|
||||||
|
if (!/[a-z0-9]|\+|\-|_|\:/.test(character)) break;
|
||||||
|
// make sure ':' followed by a whitespace
|
||||||
|
if (character === ':' && (i == 0 || value.substr(i - 1, 1) === ' ')) {
|
||||||
emojiStart = i + 1;
|
emojiStart = i + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -44,15 +44,18 @@ export default function addComposerAutocomplete() {
|
|||||||
|
|
||||||
if (this.selectionEnd - cursor > 0) return;
|
if (this.selectionEnd - cursor > 0) return;
|
||||||
|
|
||||||
// Search backwards from the cursor for an ':' symbol, without any
|
// Search backwards from the cursor for an ':' symbol. If we find
|
||||||
// intervening whitespace. If we find one, we will want to show the
|
// one and followed by a whitespace, we will want to show the
|
||||||
// autocomplete dropdown!
|
// autocomplete dropdown!
|
||||||
const value = this.value;
|
const value = this.value;
|
||||||
emojiStart = 0;
|
emojiStart = 0;
|
||||||
for (let i = cursor - 1; i >= 0; i--) {
|
for (let i = cursor - 1; i >= 0; i--) {
|
||||||
const character = value.substr(i, 1);
|
const character = value.substr(i, 1);
|
||||||
if (/\s/.test(character)) break;
|
// check what user typed, emoji names only contains alphanumeric,
|
||||||
if (character === ':') {
|
// underline, '+' and '-'
|
||||||
|
if (!/[a-z0-9]|\+|\-|_|\:/.test(character)) break;
|
||||||
|
// make sure ':' followed by a whitespace
|
||||||
|
if (character === ':' && (i == 0 || value.substr(i-1, 1) === ' ')) {
|
||||||
emojiStart = i + 1;
|
emojiStart = i + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user