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
1dc6442f
Commit
1dc6442f
authored
Jan 17, 2018
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
924fcca2
210a75b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
16 deletions
+29
-16
spec/chatbox.js
spec/chatbox.js
+6
-7
src/converse-chatview.js
src/converse-chatview.js
+1
-1
src/utils.js
src/utils.js
+22
-8
No files found.
spec/chatbox.js
View file @
1dc6442f
...
...
@@ -1612,8 +1612,8 @@
expect
(
view
.
sendMessage
).
toHaveBeenCalled
();
var
msg
=
$
(
view
.
el
).
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-msg-content
'
);
expect
(
msg
.
html
()).
toEqual
(
'
<a target="_blank" rel="noopener" href="
'
+
base_url
+
'
/logo/conversejs.svg"><img
src="
'
+
message
+
'
" class="chat-image
"></a>
'
);
'
<a target="_blank" rel="noopener" href="
'
+
base_url
+
'
/logo/conversejs.svg"><img
class="chat-image"
'
+
'
src="
'
+
message
+
'
"></a>
'
);
message
+=
"
?param1=val1¶m2=val2
"
;
test_utils
.
sendMessage
(
view
,
message
);
return
test_utils
.
waitUntil
(
function
()
{
...
...
@@ -1623,9 +1623,8 @@
expect
(
view
.
sendMessage
).
toHaveBeenCalled
();
var
msg
=
$
(
view
.
el
).
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-msg-content
'
);
expect
(
msg
.
html
()).
toEqual
(
'
<a target="_blank" rel="noopener" href="
'
+
base_url
+
'
/logo/conversejs.svg?param1=val1&param2=val2"><img src="
'
+
message
.
replace
(
/&/g
,
'
&
'
)
+
'
" class="chat-image"></a>
'
)
'
<a target="_blank" rel="noopener" href="
'
+
base_url
+
'
/logo/conversejs.svg?param1=val1&param2=val2"><img
'
+
'
class="chat-image" src="
'
+
message
.
replace
(
/&/g
,
'
&
'
)
+
'
"></a>
'
)
// Test now with two images in one message
message
+=
'
hello world
'
+
base_url
+
"
/logo/conversejs.svg
"
;
...
...
@@ -1638,9 +1637,9 @@
var
msg
=
$
(
view
.
el
).
find
(
'
.chat-content
'
).
find
(
'
.chat-message
'
).
last
().
find
(
'
.chat-msg-content
'
);
expect
(
msg
.
html
()).
toEqual
(
'
<a target="_blank" rel="noopener" href="
'
+
base_url
+
'
/logo/conversejs.svg?param1=val1&param2=val2">
'
+
'
<img
src="
'
+
base_url
+
'
/logo/conversejs.svg?param1=val1&param2=val2" class="chat-image
"></a> hello world
'
+
'
<img
class="chat-image" src="
'
+
base_url
+
'
/logo/conversejs.svg?param1=val1&param2=val2
"></a> hello world
'
+
'
<a target="_blank" rel="noopener" href="
'
+
base_url
+
'
/logo/conversejs.svg">
'
+
'
<img
src="
'
+
base_url
+
'
/logo/conversejs.svg" class="chat-image
"></a>
'
'
<img
class="chat-image" src="
'
+
base_url
+
'
/logo/conversejs.svg
"></a>
'
)
done
();
});
...
...
src/converse-chatview.js
View file @
1dc6442f
...
...
@@ -573,7 +573,7 @@
msg_content
.
innerHTML
=
u
.
addEmoji
(
_converse
,
emojione
,
u
.
addHyperlinks
(
xss
.
filterXSS
(
text
,
{
'
whiteList
'
:
{}}))
);
u
.
renderImageURLs
(
msg_content
);
u
.
renderImageURLs
(
msg_content
)
.
then
(
this
.
scrollDown
.
bind
(
this
))
;
return
msg
;
},
...
...
src/utils.js
View file @
1dc6442f
...
...
@@ -180,15 +180,29 @@
};
u
.
renderImageURLs
=
function
(
obj
)
{
/* Returns a Promise which resolves once all images have been loaded.
*/
const
list
=
obj
.
textContent
.
match
(
URL_REGEX
)
||
[];
_
.
forEach
(
list
,
function
(
url
)
{
isImage
(
url
).
then
(
function
(
img
)
{
img
.
className
=
'
chat-image
'
;
var
anchors
=
sizzle
(
`a[href="
${
url
}
"]`
,
obj
);
_
.
each
(
anchors
,
(
a
)
=>
{
a
.
innerHTML
=
img
.
outerHTML
;
});
});
});
return
obj
;
return
Promise
.
all
(
_
.
map
(
list
,
(
url
)
=>
new
Promise
((
resolve
,
reject
)
=>
isImage
(
url
).
then
(
function
(
img
)
{
// XXX: need to create a new image, otherwise the event
// listener doesn't fire
const
i
=
new
Image
();
i
.
className
=
'
chat-image
'
;
i
.
src
=
img
.
src
;
i
.
addEventListener
(
'
load
'
,
resolve
);
// We also resolve for non-images, otherwise the
// Promise.all resolves prematurely.
i
.
addEventListener
(
'
error
'
,
resolve
);
var
anchors
=
sizzle
(
`a[href="
${
url
}
"]`
,
obj
);
_
.
each
(
anchors
,
(
a
)
=>
{
a
.
replaceChild
(
i
,
a
.
firstChild
);
});
}).
catch
(
resolve
)
)
))
};
u
.
slideInAllElements
=
function
(
elements
,
duration
=
300
)
{
...
...
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