Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
c01d1105
Commit
c01d1105
authored
Aug 22, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid interference between username and emoji autocomplete
parent
a59510bb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
27 deletions
+49
-27
spec/emojis.js
spec/emojis.js
+23
-1
src/converse-chatview.js
src/converse-chatview.js
+0
-4
src/converse-emoji-views.js
src/converse-emoji-views.js
+26
-22
No files found.
spec/emojis.js
View file @
c01d1105
...
...
@@ -60,7 +60,7 @@
}
view
.
onKeyDown
(
tab_event
);
await
u
.
waitUntil
(()
=>
u
.
isVisible
(
view
.
el
.
querySelector
(
'
.toggle-smiley .emoji-picker__container
'
)));
cons
t
picker
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.toggle-smiley .emoji-picker__container
'
));
le
t
picker
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.toggle-smiley .emoji-picker__container
'
));
const
input
=
picker
.
querySelector
(
'
.emoji-search
'
);
expect
(
input
.
value
).
toBe
(
'
:gri
'
);
let
visible_emojis
=
sizzle
(
'
.insert-emoji:not(.hidden)
'
,
picker
);
...
...
@@ -81,6 +81,28 @@
view
.
emoji_picker_view
.
onKeyDown
(
enter_event
);
expect
(
input
.
value
).
toBe
(
''
);
expect
(
textarea
.
value
).
toBe
(
'
:grimacing:
'
);
// Test that username starting with : doesn't cause issues
const
presence
=
$pres
({
'
from
'
:
`
${
muc_jid
}
/:username`
,
'
id
'
:
'
27C55F89-1C6A-459A-9EB5-77690145D624
'
,
'
to
'
:
_converse
.
jid
})
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/muc#user
'
})
.
c
(
'
item
'
,
{
'
jid
'
:
'
some1@montague.lit
'
,
'
affiliation
'
:
'
member
'
,
'
role
'
:
'
participant
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
textarea
.
value
=
'
:use
'
;
view
.
onKeyDown
(
tab_event
);
await
u
.
waitUntil
(()
=>
u
.
isVisible
(
view
.
el
.
querySelector
(
'
.toggle-smiley .emoji-picker__container
'
)));
picker
=
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.toggle-smiley .emoji-picker__container
'
));
expect
(
input
.
value
).
toBe
(
'
:use
'
);
visible_emojis
=
sizzle
(
'
.insert-emoji:not(.hidden)
'
,
picker
);
expect
(
visible_emojis
.
length
).
toBe
(
0
);
done
();
}));
...
...
src/converse-chatview.js
View file @
c01d1105
...
...
@@ -883,8 +883,6 @@ converse.plugins.add('converse-chatview', {
if
(
ev
.
keyCode
===
_converse
.
keycodes
.
FORWARD_SLASH
)
{
// Forward slash is used to run commands. Nothing to do here.
return
;
}
else
if
(
ev
.
keyCode
===
_converse
.
keycodes
.
TAB
)
{
return
this
.
onTabPressed
(
ev
);
}
else
if
(
ev
.
keyCode
===
_converse
.
keycodes
.
ESCAPE
)
{
return
this
.
onEscapePressed
(
ev
);
}
else
if
(
ev
.
keyCode
===
_converse
.
keycodes
.
ENTER
)
{
...
...
@@ -924,8 +922,6 @@ converse.plugins.add('converse-chatview', {
return
this
.
onFormSubmitted
(
ev
);
},
onTabPressed
(
ev
)
{},
// noop, overridden in other plugins
onEscapePressed
(
ev
)
{
ev
.
preventDefault
();
const
idx
=
this
.
model
.
messages
.
findLastIndex
(
'
correcting
'
),
...
...
src/converse-emoji-views.js
View file @
c01d1105
...
...
@@ -42,28 +42,6 @@ converse.plugins.add('converse-emoji-views', {
this
.
emoji_dropdown
.
toggle
();
}
this
.
__super__
.
onEnterPressed
.
apply
(
this
,
arguments
);
},
async
onTabPressed
(
ev
)
{
const
{
_converse
}
=
this
.
__super__
;
const
input
=
ev
.
target
;
const
value
=
u
.
getCurrentWord
(
input
,
null
,
/
(
:.*
?
:
)
/g
);
if
(
value
.
startsWith
(
'
:
'
))
{
ev
.
preventDefault
();
ev
.
stopPropagation
();
if
(
this
.
emoji_dropdown
===
undefined
)
{
this
.
createEmojiDropdown
();
}
await
_converse
.
api
.
waitUntil
(
'
emojisInitialized
'
);
this
.
emoji_picker_view
.
model
.
set
({
'
autocompleting
'
:
value
,
'
position
'
:
ev
.
target
.
selectionStart
},
{
'
silent
'
:
true
});
this
.
emoji_picker_view
.
filter
(
value
,
true
);
this
.
emoji_dropdown
.
toggle
();
}
else
{
this
.
__super__
.
onTabPressed
.
apply
(
this
,
arguments
);
}
}
},
...
...
@@ -71,6 +49,19 @@ converse.plugins.add('converse-emoji-views', {
events
:
{
'
click .toggle-smiley
'
:
'
toggleEmojiMenu
'
},
onKeyDown
(
ev
)
{
const
{
_converse
}
=
this
.
__super__
;
if
(
ev
.
keyCode
===
_converse
.
keycodes
.
TAB
)
{
const
value
=
u
.
getCurrentWord
(
ev
.
target
,
null
,
/
(
:.*
?
:
)
/g
);
if
(
value
.
startsWith
(
'
:
'
))
{
ev
.
preventDefault
();
ev
.
stopPropagation
();
return
this
.
autocompleteInPicker
(
ev
.
target
,
value
);
}
}
return
this
.
__super__
.
onKeyDown
.
call
(
this
,
ev
);
}
}
},
...
...
@@ -92,6 +83,19 @@ converse.plugins.add('converse-emoji-views', {
const
emoji_aware_chat_view
=
{
async
autocompleteInPicker
(
input
,
value
)
{
if
(
this
.
emoji_dropdown
===
undefined
)
{
this
.
createEmojiDropdown
();
}
await
_converse
.
api
.
waitUntil
(
'
emojisInitialized
'
);
this
.
emoji_picker_view
.
model
.
set
({
'
autocompleting
'
:
value
,
'
position
'
:
input
.
selectionStart
},
{
'
silent
'
:
true
});
this
.
emoji_picker_view
.
filter
(
value
,
true
);
this
.
emoji_dropdown
.
toggle
();
},
createEmojiPicker
()
{
if
(
!
_converse
.
emojipicker
)
{
const
storage
=
_converse
.
config
.
get
(
'
storage
'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment