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
e6d86341
Commit
e6d86341
authored
Jul 13, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emoji picker: properly insert emoji upon click
parent
756a85fb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
12 deletions
+58
-12
spec/emojis.js
spec/emojis.js
+45
-1
src/components/emoji-picker-content.js
src/components/emoji-picker-content.js
+1
-4
src/components/emoji-picker.js
src/components/emoji-picker.js
+3
-1
src/converse-chatview.js
src/converse-chatview.js
+9
-6
No files found.
spec/emojis.js
View file @
e6d86341
...
...
@@ -99,7 +99,51 @@ describe("Emojis", function () {
done
();
}));
fit
(
"
allows you to search for particular emojis
"
,
it
(
"
properly inserts emojis into the chat textarea
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
const
muc_jid
=
'
lounge@montague.lit
'
;
await
mock
.
openAndEnterChatRoom
(
_converse
,
muc_jid
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
muc_jid
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
textarea
.
value
=
'
:gri
'
;
// Press tab
const
tab_event
=
{
'
target
'
:
textarea
,
'
preventDefault
'
:
function
preventDefault
()
{},
'
stopPropagation
'
:
function
stopPropagation
()
{},
'
keyCode
'
:
9
,
'
key
'
:
'
Tab
'
}
textarea
.
value
=
'
:
'
;
view
.
onKeyDown
(
tab_event
);
await
u
.
waitUntil
(()
=>
u
.
isVisible
(
view
.
el
.
querySelector
(
'
.emoji-picker__lists
'
)));
const
picker
=
view
.
el
.
querySelector
(
'
converse-emoji-picker
'
);
const
input
=
picker
.
querySelector
(
'
.emoji-search
'
);
input
.
dispatchEvent
(
new
KeyboardEvent
(
'
keydown
'
,
tab_event
));
await
u
.
waitUntil
(()
=>
input
.
value
===
'
:100:
'
);
const
enter_event
=
Object
.
assign
({},
tab_event
,
{
'
keyCode
'
:
13
,
'
key
'
:
'
Enter
'
,
'
target
'
:
input
});
input
.
dispatchEvent
(
new
KeyboardEvent
(
'
keydown
'
,
enter_event
));
expect
(
textarea
.
value
).
toBe
(
'
:100:
'
);
textarea
.
value
=
'
:
'
;
view
.
onKeyDown
(
tab_event
);
await
u
.
waitUntil
(()
=>
u
.
isVisible
(
view
.
el
.
querySelector
(
'
.emoji-picker__lists
'
)));
input
.
dispatchEvent
(
new
KeyboardEvent
(
'
keydown
'
,
tab_event
));
await
u
.
waitUntil
(()
=>
input
.
value
===
'
:100:
'
);
await
u
.
waitUntil
(()
=>
sizzle
(
'
.emojis-lists__container--search .insert-emoji:not(.hidden)
'
,
view
.
el
).
length
===
1
,
1000
);
const
emoji
=
sizzle
(
'
.emojis-lists__container--search .insert-emoji:not(.hidden) a
'
,
view
.
el
).
pop
();
emoji
.
click
();
expect
(
textarea
.
value
).
toBe
(
'
:100:
'
);
done
();
}));
it
(
"
allows you to search for particular emojis
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
...
...
src/components/emoji-picker-content.js
View file @
e6d86341
...
...
@@ -77,10 +77,7 @@ export default class EmojiPickerContent extends CustomElement {
ev
.
preventDefault
();
ev
.
stopPropagation
();
const
target
=
ev
.
target
.
nodeName
===
'
IMG
'
?
ev
.
target
.
parentElement
:
ev
.
target
;
const
replace
=
this
.
model
.
get
(
'
autocompleting
'
);
const
position
=
this
.
model
.
get
(
'
position
'
);
this
.
model
.
set
({
'
autocompleting
'
:
null
,
'
position
'
:
null
,
'
query
'
:
''
});
this
.
chatview
.
insertIntoTextArea
(
target
.
getAttribute
(
'
data-emoji
'
),
replace
,
false
,
position
);
this
.
parentElement
.
insertIntoTextArea
(
target
.
getAttribute
(
'
data-emoji
'
));
}
shouldBeHidden
(
shortname
)
{
...
...
src/components/emoji-picker.js
View file @
e6d86341
...
...
@@ -140,7 +140,7 @@ export default class EmojiPicker extends CustomElement {
insertIntoTextArea
(
value
)
{
this
.
chatview
.
onEmojiReceivedFromPicker
(
value
);
this
.
model
.
set
({
'
query
'
:
''
});
this
.
model
.
set
({
'
autocompleting
'
:
null
,
'
query
'
:
''
,
'
ac_position
'
:
null
});
}
chooseSkinTone
(
ev
)
{
...
...
@@ -279,6 +279,8 @@ export class EmojiDropdown extends BaseDropdown {
this
.
model
=
new
_converse
.
EmojiPicker
({
'
id
'
:
id
});
this
.
model
.
browserStorage
=
_converse
.
createStore
(
id
);
await
new
Promise
(
resolve
=>
this
.
model
.
fetch
({
'
success
'
:
resolve
,
'
error
'
:
resolve
}));
// We never want still be in the autocompleting state upon page load
this
.
model
.
set
({
'
autocompleting
'
:
null
,
'
ac_position
'
:
null
});
})();
}
return
this
.
init_promise
;
...
...
src/converse-chatview.js
View file @
e6d86341
...
...
@@ -722,18 +722,21 @@ converse.plugins.add('converse-chatview', {
const
emoji_dropdown
=
this
.
el
.
querySelector
(
'
converse-emoji-dropdown
'
);
const
emoji_picker
=
this
.
el
.
querySelector
(
'
converse-emoji-picker
'
);
if
(
emoji_picker
&&
emoji_dropdown
)
{
this
.
autocompleting
=
value
;
this
.
ac_position
=
input
.
selectionStart
;
emoji_picker
.
model
.
set
({
'
query
'
:
value
});
emoji_picker
.
model
.
set
({
'
ac_position
'
:
input
.
selectionStart
,
'
autocompleting
'
:
true
,
'
query
'
:
value
});
emoji_dropdown
.
firstElementChild
.
click
();
return
true
;
}
},
onEmojiReceivedFromPicker
(
emoji
)
{
this
.
insertIntoTextArea
(
emoji
,
!!
this
.
autocompleting
,
false
,
this
.
ac_position
);
this
.
autocompleting
=
false
;
this
.
ac_position
=
null
;
const
model
=
this
.
el
.
querySelector
(
'
converse-emoji-picker
'
).
model
;
const
autocompleting
=
model
.
get
(
'
autocompleting
'
);
const
ac_position
=
model
.
get
(
'
ac_position
'
);
this
.
insertIntoTextArea
(
emoji
,
!!
autocompleting
,
false
,
ac_position
);
},
/**
...
...
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