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
6319f566
Commit
6319f566
authored
Sep 04, 2020
by
Christoph Scholz
Committed by
JC Brand
Sep 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix emojis in case `use_system_emojis == false`
parent
0594c480
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
7 deletions
+54
-7
CHANGES.md
CHANGES.md
+1
-0
spec/emojis.js
spec/emojis.js
+42
-0
src/headless/converse-emoji.js
src/headless/converse-emoji.js
+11
-7
No files found.
CHANGES.md
View file @
6319f566
...
...
@@ -30,6 +30,7 @@ Soon we'll deprecate the latter, so prepare now.
-
#2199: Fix BOSH session restore.
-
#2201: added html to converse.env
-
#2213: added CustomElement to converse.env
-
#2220: fix rendering of emojis in case
`use_system_emojis == false`
(again).
-
Removed the mockups from the project. Recommended to use tests instead.
-
The API method
`api.settings.update`
has been deprecated in favor of
`api.settings.extend`
.
-
The API methods under the
`api.user.status`
namespace are now asynchronous and need to be
`await`
ed.
...
...
spec/emojis.js
View file @
6319f566
...
...
@@ -340,6 +340,48 @@ describe("Emojis", function () {
done
()
}));
it
(
"
can render emojis as images
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
use_system_emojis
'
:
false
},
async
function
(
done
,
_converse
)
{
await
mock
.
waitForRoster
(
_converse
,
'
current
'
);
const
sender_jid
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
_converse
.
handleMessageStanza
(
$msg
({
'
from
'
:
sender_jid
,
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
chat
'
,
'
id
'
:
_converse
.
connection
.
getUniqueId
()
}).
c
(
'
body
'
).
t
(
'
😇
'
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
());
await
new
Promise
(
resolve
=>
_converse
.
on
(
'
chatBoxViewInitialized
'
,
resolve
));
const
view
=
_converse
.
api
.
chatviews
.
get
(
sender_jid
);
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
await
u
.
waitUntil
(()
=>
u
.
hasClass
(
'
chat-msg__text--larger
'
,
view
.
content
.
querySelector
(
'
.chat-msg__text
'
)));
const
last_msg_sel
=
'
converse-chat-message:last-child .chat-msg__text
'
;
let
message
=
view
.
content
.
querySelector
(
last_msg_sel
);
await
u
.
waitUntil
(()
=>
u
.
isVisible
(
message
.
querySelector
(
'
.emoji
'
)),
1000
);
let
imgs
=
message
.
querySelectorAll
(
'
.emoji
'
);
expect
(
imgs
.
length
).
toBe
(
1
);
expect
(
imgs
[
0
].
src
).
toBe
(
_converse
.
api
.
settings
.
get
(
'
emoji_image_path
'
)
+
'
/72x72/1f607.png
'
);
const
textarea
=
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
);
textarea
.
value
=
'
:poop: :innocent:
'
;
view
.
onKeyDown
({
target
:
textarea
,
preventDefault
:
function
preventDefault
()
{},
keyCode
:
13
// Enter
});
await
new
Promise
(
resolve
=>
view
.
model
.
messages
.
once
(
'
rendered
'
,
resolve
));
message
=
view
.
content
.
querySelector
(
last_msg_sel
);
await
u
.
waitUntil
(()
=>
u
.
isVisible
(
message
.
querySelector
(
'
.emoji
'
)),
1000
);
imgs
=
message
.
querySelectorAll
(
'
.emoji
'
);
expect
(
imgs
.
length
).
toBe
(
2
);
expect
(
imgs
[
0
].
src
).
toBe
(
_converse
.
api
.
settings
.
get
(
'
emoji_image_path
'
)
+
'
/72x72/1f4a9.png
'
);
expect
(
imgs
[
1
].
src
).
toBe
(
_converse
.
api
.
settings
.
get
(
'
emoji_image_path
'
)
+
'
/72x72/1f607.png
'
);
done
()
}));
it
(
"
can show custom emojis
"
,
mock
.
initConverse
(
...
...
src/headless/converse-emoji.js
View file @
6319f566
...
...
@@ -119,8 +119,9 @@ export function getEmojiMarkup (data, options={unicode_only: false, add_title_wr
const
emoji
=
data
.
emoji
;
const
shortname
=
data
.
shortname
;
if
(
emoji
)
{
if
(
options
.
add_title_wrapper
)
{
if
(
api
.
settings
.
get
(
'
use_system_emojis
'
))
{
return
(
options
.
add_title_wrapper
&&
shortname
)
?
html
`<span title="
${
shortname
}
">
${
emoji
}
</span>`
:
emoji
;
return
shortname
?
html
`<span title="
${
shortname
}
">
${
emoji
}
</span>`
:
emoji
;
}
else
{
const
path
=
api
.
settings
.
get
(
'
emoji_image_path
'
);
return
html
`<img class="emoji"
...
...
@@ -128,6 +129,9 @@ export function getEmojiMarkup (data, options={unicode_only: false, add_title_wr
alt="
${
emoji
}
"
src="
${
path
}
/72x72/
${
data
.
cp
}
.png"/>`
;
}
}
else
{
return
emoji
;
}
}
else
if
(
options
.
unicode_only
)
{
return
shortname
;
}
else
{
...
...
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