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
b5a27b34
Commit
b5a27b34
authored
Jun 30, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render newlines
parent
cc98cea0
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
133 deletions
+154
-133
dist/converse.js
dist/converse.js
+109
-129
spec/messages.js
spec/messages.js
+40
-4
src/converse-message-view.js
src/converse-message-view.js
+1
-0
src/utils/core.js
src/utils/core.js
+4
-0
No files found.
dist/converse.js
View file @
b5a27b34
This diff is collapsed.
Click to expand it.
spec/messages.js
View file @
b5a27b34
...
...
@@ -1067,6 +1067,43 @@
done
();
}));
it
(
"
will render newlines
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
let
stanza
=
Strophe
.
xmlHtmlNode
(
"
<message from='
"
+
contact_jid
+
"
'
"
+
"
type='chat'
"
+
"
to='dummy@localhost/resource'>
"
+
"
<body>Hey
\n
Have you heard the news?</body>
"
+
"
</message>
"
).
firstChild
;
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
expect
(
chat_content
.
querySelector
(
'
.chat-msg-text
'
).
innerHTML
).
toBe
(
'
Hey<br>Have you heard the news?
'
);
stanza
=
Strophe
.
xmlHtmlNode
(
"
<message from='
"
+
contact_jid
+
"
'
"
+
"
type='chat'
"
+
"
to='dummy@localhost/resource'>
"
+
"
<body>Hey
\n\n\n
Have you heard the news?</body>
"
+
"
</message>
"
).
firstChild
;
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
chat_content
.
querySelector
(
'
.message:last-child .chat-msg-text
'
).
innerHTML
).
toBe
(
'
Hey<br>Have you heard the news?
'
);
stanza
=
Strophe
.
xmlHtmlNode
(
"
<message from='
"
+
contact_jid
+
"
'
"
+
"
type='chat'
"
+
"
to='dummy@localhost/resource'>
"
+
"
<body>Hey
\n
Have you heard
\n
the news?</body>
"
+
"
</message>
"
).
firstChild
;
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
chat_content
.
querySelector
(
'
.message:last-child .chat-msg-text
'
).
innerHTML
).
toBe
(
'
Hey<br>Have you heard<br>the news?
'
);
done
();
}));
it
(
"
will render images from their URLs
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
...
...
@@ -1081,9 +1118,8 @@
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
test_utils
.
sendMessage
(
view
,
message
);
test_utils
.
waitUntil
(
function
()
{
return
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-image
'
).
length
;
},
1000
).
then
(
function
()
{
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-image
'
).
length
)
.
then
(()
=>
{
expect
(
view
.
model
.
sendMessage
).
toHaveBeenCalled
();
var
msg
=
$
(
view
.
el
).
find
(
'
.chat-content .chat-msg
'
).
last
().
find
(
'
.chat-msg-text
'
);
expect
(
msg
.
html
().
trim
()).
toEqual
(
...
...
@@ -1095,7 +1131,7 @@
return
test_utils
.
waitUntil
(
function
()
{
return
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-image
'
).
length
===
2
;
},
1000
);
}).
then
(
function
()
{
}).
then
(
()
=>
{
expect
(
view
.
model
.
sendMessage
).
toHaveBeenCalled
();
var
msg
=
$
(
view
.
el
).
find
(
'
.chat-content
'
).
find
(
'
.chat-msg
'
).
last
().
find
(
'
.chat-msg-text
'
);
expect
(
msg
.
html
().
trim
()).
toEqual
(
...
...
src/converse-message-view.js
View file @
b5a27b34
...
...
@@ -145,6 +145,7 @@
msg_content
.
innerHTML
=
_
.
flow
(
_
.
partial
(
u
.
geoUriToHttp
,
_
,
_converse
.
geouri_replacement
),
u
.
addHyperlinks
,
u
.
renderNewLines
,
_
.
partial
(
u
.
addEmoji
,
_converse
,
emojione
,
_
)
)(
text
);
}
...
...
src/utils/core.js
View file @
b5a27b34
...
...
@@ -222,6 +222,10 @@
});
};
u
.
renderNewLines
=
function
(
text
)
{
return
text
.
replace
(
/
\n
+/g
,
'
<br/>
'
);
};
u
.
renderImageURLs
=
function
(
_converse
,
obj
)
{
/* Returns a Promise which resolves once all images have been loaded.
*/
...
...
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