Render newlines

This commit is contained in:
JC Brand 2018-06-30 15:07:30 +02:00
parent cc98cea009
commit b5a27b34a1
4 changed files with 154 additions and 133 deletions

134
dist/converse.js vendored
View File

@ -36,34 +36,19 @@
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@ -2575,7 +2560,13 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
if (_.isFunction(this.beforeRender)) {
this.beforeRender();
}
const new_vnode = tovnode.toVNode(parseHTMLToDOM(this.toHTML()));
let new_vnode;
if (!_.isNil(this.toHTML)) {
new_vnode = tovnode.toVNode(parseHTMLToDOM(this.toHTML()));
} else {
new_vnode = tovnode.toVNode(this.toDOM());
}
new_vnode.data.hook = _.extend({
create: this.updateEventListeners.bind(this),
update: this.updateEventListeners.bind(this)
@ -4529,7 +4520,7 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(global) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Native Javascript for Bootstrap 4 v2.0.23 | © dnp_theme | MIT-License
/* WEBPACK VAR INJECTION */(function(global) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Native Javascript for Bootstrap 4 v2.0.22 | © dnp_theme | MIT-License
(function (root, factory) {
if (true) {
// AMD support:
@ -4638,14 +4629,12 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
getBoundingClientRect = 'getBoundingClientRect',
querySelectorAll = 'querySelectorAll',
getElementsByCLASSNAME = 'getElementsByClassName',
getComputedStyle = 'getComputedStyle',
indexOf = 'indexOf',
parentNode = 'parentNode',
length = 'length',
toLowerCase = 'toLowerCase',
Transition = 'Transition',
Duration = 'Duration',
Webkit = 'Webkit',
style = 'style',
push = 'push',
@ -4674,7 +4663,6 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
// transitionEnd since 2.0.4
supportTransitions = Webkit+Transition in HTML[style] || Transition[toLowerCase]() in HTML[style],
transitionEndEvent = Webkit+Transition in HTML[style] ? Webkit[toLowerCase]()+Transition+'End' : Transition[toLowerCase]()+'end',
transitionDuration = Webkit+Duration in HTML[style] ? Webkit[toLowerCase]()+Transition+Duration : Transition[toLowerCase]()+Duration,
// set new focus element since 2.0.3
setFocus = function(element){
@ -4728,16 +4716,9 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
off(element, event, handlerWrapper);
});
},
getTransitionDurationFromElement = function(element) {
var duration = globalObject[getComputedStyle](element)[transitionDuration];
duration = parseFloat(duration);
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0;
return duration + 50; // we take a short offset to make sure we fire on the next frame after animation
},
emulateTransitionEnd = function(element,handler){ // emulateTransitionEnd since 2.0.4
var called = 0, duration = getTransitionDurationFromElement(element);
supportTransitions && one(element, transitionEndEvent, function(e){ handler(e); called = 1; });
setTimeout(function() { !called && handler(); }, duration);
if (supportTransitions) { one(element, transitionEndEvent, function(e){ handler(e); }); }
else { handler(); }
},
bootstrapCustomEvent = function (eventName, componentName, related) {
var OriginalCustomEvent = new CustomEvent( eventName + '.bs.' + componentName);
@ -4833,7 +4814,7 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
arrowLeft && (arrow[style][left] = arrowLeft + 'px');
};
BSN.version = '2.0.23';
BSN.version = '2.0.22';
/* Native Javascript for Bootstrap 4 | Alert
-------------------------------------------*/
@ -5003,7 +4984,7 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
// DATA API
var intervalAttribute = element[getAttribute](dataInterval),
intervalOption = options[interval],
intervalData = intervalAttribute === 'false' ? 0 : parseInt(intervalAttribute),
intervalData = intervalAttribute === 'false' ? 0 : parseInt(intervalAttribute) || 5000, // bootstrap carousel default interval
pauseData = element[getAttribute](dataPause) === hoverEvent || false,
keyboardData = element[getAttribute](dataKeyboard) === 'true' || false,
@ -5018,8 +4999,8 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
this[pause] = (options[pause] === hoverEvent || pauseData) ? hoverEvent : false; // false / hover
this[interval] = typeof intervalOption === 'number' ? intervalOption
: intervalOption === false || intervalData === 0 || intervalData === false ? 0
: 5000; // bootstrap carousel default interval
: intervalData === 0 ? 0
: intervalData;
// bind, event targets
var self = this, index = element.index = 0, timer = element.timer = 0,
@ -5138,10 +5119,10 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
addClass(slides[next],carouselItem +'-'+ slideDirection);
addClass(slides[activeItem],carouselItem +'-'+ slideDirection);
one(slides[next], transitionEndEvent, function(e) {
var timeout = e[target] !== slides[next] ? e.elapsedTime*1000+100 : 20;
one(slides[activeItem], transitionEndEvent, function(e) {
var timeout = e[target] !== slides[activeItem] ? e.elapsedTime*1000 : 0;
isSliding && setTimeout(function(){
setTimeout(function(){
isSliding = false;
addClass(slides[next],active);
@ -5156,7 +5137,7 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
if ( !DOC.hidden && self[interval] && !hasClass(element,paused) ) {
self.cycle();
}
}, timeout);
},timeout+100);
});
} else {
@ -5221,24 +5202,23 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
// event targets and constants
var accordion = null, collapse = null, self = this,
isAnimating = false, // when true it will prevent click handlers
accordionData = element[getAttribute]('data-parent'),
activeCollapse, activeElement,
// component strings
component = 'collapse',
collapsed = 'collapsed',
isAnimating = 'isAnimating',
// private methods
openAction = function(collapseElement,toggle) {
bootstrapCustomEvent.call(collapseElement, showEvent, component);
collapseElement[isAnimating] = true;
isAnimating = true;
addClass(collapseElement,collapsing);
removeClass(collapseElement,component);
collapseElement[style][height] = collapseElement[scrollHeight] + 'px';
emulateTransitionEnd(collapseElement, function() {
collapseElement[isAnimating] = false;
isAnimating = false;
collapseElement[setAttribute](ariaExpanded,'true');
toggle[setAttribute](ariaExpanded,'true');
removeClass(collapseElement,collapsing);
@ -5250,7 +5230,7 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
},
closeAction = function(collapseElement,toggle) {
bootstrapCustomEvent.call(collapseElement, hideEvent, component);
collapseElement[isAnimating] = true;
isAnimating = true;
collapseElement[style][height] = collapseElement[scrollHeight] + 'px'; // set height first
removeClass(collapseElement,component);
removeClass(collapseElement,showClass);
@ -5259,7 +5239,7 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
collapseElement[style][height] = '0px';
emulateTransitionEnd(collapseElement, function() {
collapseElement[isAnimating] = false;
isAnimating = false;
collapseElement[setAttribute](ariaExpanded,'false');
toggle[setAttribute](ariaExpanded,'false');
removeClass(collapseElement,collapsing);
@ -5278,29 +5258,29 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
// public methods
this.toggle = function(e) {
e[preventDefault]();
if (isAnimating) return;
if (!hasClass(collapse,showClass)) { self.show(); }
else { self.hide(); }
};
this.hide = function() {
if ( collapse[isAnimating] ) return;
closeAction(collapse,element);
addClass(element,collapsed);
};
this.show = function() {
if ( accordion ) {
activeCollapse = queryElement('.'+component+'.'+showClass,accordion);
activeElement = activeCollapse && (queryElement('['+dataToggle+'="'+component+'"]['+dataTarget+'="#'+activeCollapse.id+'"]',accordion)
|| queryElement('['+dataToggle+'="'+component+'"][href="#'+activeCollapse.id+'"]',accordion) );
var activeCollapse = queryElement('.'+component+'.'+showClass,accordion),
toggle = activeCollapse && (queryElement('['+dataToggle+'="'+component+'"]['+dataTarget+'="#'+activeCollapse.id+'"]',accordion)
|| queryElement('['+dataToggle+'="'+component+'"][href="#'+activeCollapse.id+'"]',accordion) ),
correspondingCollapse = toggle && (toggle[getAttribute](dataTarget) || toggle.href);
if ( activeCollapse && toggle && activeCollapse !== collapse ) {
closeAction(activeCollapse,toggle);
if ( correspondingCollapse.split('#')[1] !== collapse.id ) { addClass(toggle,collapsed); }
else { removeClass(toggle,collapsed); }
}
}
if ( !collapse[isAnimating] || activeCollapse && !activeCollapse[isAnimating] ) {
if ( activeElement && activeCollapse !== collapse ) {
closeAction(activeCollapse,activeElement);
addClass(activeElement,collapsed);
}
openAction(collapse,element);
removeClass(element,collapsed);
}
};
// init
@ -5308,7 +5288,6 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
on(element, clickEvent, self.toggle);
}
collapse = getTarget();
collapse[isAnimating] = false; // when true it will prevent click handlers
accordion = queryElement(options.parent) || accordionData && getClosest(element, accordionData);
element[stringCollapse] = self;
};
@ -5466,7 +5445,6 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
var btnCheck = element[getAttribute](dataTarget)||element[getAttribute]('href'),
checkModal = queryElement( btnCheck ),
modal = hasClass(element,'modal') ? element : checkModal,
overlayDelay,
// strings
component = 'modal',
@ -5500,13 +5478,13 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
return globalObject[innerWidth] || (htmlRect[right] - Math.abs(htmlRect[left]));
},
setScrollbar = function () {
var bodyStyle = globalObject[getComputedStyle](DOC[body]),
var bodyStyle = globalObject.getComputedStyle(DOC[body]),
bodyPad = parseInt((bodyStyle[paddingRight]), 10), itemPad;
if (bodyIsOverflowing) {
DOC[body][style][paddingRight] = (bodyPad + scrollbarWidth) + 'px';
if (fixedItems[length]){
for (var i = 0; i < fixedItems[length]; i++) {
itemPad = globalObject[getComputedStyle](fixedItems[i])[paddingRight];
itemPad = globalObject.getComputedStyle(fixedItems[i])[paddingRight];
fixedItems[i][style][paddingRight] = ( parseInt(itemPad) + scrollbarWidth) + 'px';
}
}
@ -5648,7 +5626,6 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
if ( overlay && modalOverlay && !hasClass(overlay,showClass)) {
overlay[offsetWidth]; // force reflow to enable trasition
overlayDelay = getTransitionDurationFromElement(overlay);
addClass(overlay, showClass);
}
@ -5668,19 +5645,18 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
keydownHandlerToggle();
hasClass(modal,'fade') ? emulateTransitionEnd(modal, triggerShow) : triggerShow();
}, supportTransitions && overlay ? overlayDelay : 0);
}, supportTransitions ? 150 : 0);
};
this.hide = function() {
bootstrapCustomEvent.call(modal, hideEvent, component);
overlay = queryElement('.'+modalBackdropString);
overlayDelay = overlay && getTransitionDurationFromElement(overlay);
removeClass(modal,showClass);
modal[setAttribute](ariaHidden, true);
setTimeout(function(){
(function(){
hasClass(modal,'fade') ? emulateTransitionEnd(modal, triggerHide) : triggerHide();
}, supportTransitions && overlay ? overlayDelay : 0);
}());
};
this.setContent = function( content ) {
queryElement('.'+component+'-content',modal)[innerHTML] = content;
@ -6036,7 +6012,7 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
tabsContentContainer[style][height] = nextHeight + 'px'; // height animation
tabsContentContainer[offsetWidth];
emulateTransitionEnd(tabsContentContainer, triggerEnd);
},50);
},1);
}
} else {
tabs[isAnimating] = false;
@ -6468,7 +6444,6 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
ns.emojiVersion = '3.1'; // you can [optionally] modify this to load alternate emoji versions. see readme for backwards compatibility and version options
ns.emojiSize = '32';
ns.greedyMatch = false; // set to true for greedy unicode matching
ns.blacklistChars = '';
ns.imagePathPNG = 'https://cdn.jsdelivr.net/emojione/assets/' + ns.emojiVersion + '/png/';
ns.defaultPathPNG = ns.imagePathPNG;
ns.imageTitleTag = true; // set to false to remove title attribute from img tag
@ -6482,7 +6457,7 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
ns.regAscii = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|((\\s|^)"+ns.asciiRegexp+"(?=\\s|$|[!,.?]))", "gi");
ns.regAsciiRisky = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(()"+ns.asciiRegexp+"())", "gi");
ns.regUnicode = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(?:\uD83C\uDFF3)\uFE0F?\u200D?(?:\uD83C\uDF08)|(?:\uD83D\uDC41)\uFE0F?\u200D?(?:\uD83D\uDDE8)\uFE0F?|[#-9]\uFE0F?\u20E3|(?:(?:\uD83C\uDFF4)(?:\uDB40[\uDC60-\uDCFF]){1,6})|(?:\uD83C[\uDDE0-\uDDFF]){2}|(?:(?:\uD83D[\uDC68\uDC69]))\uFE0F?(?:\uD83C[\uDFFA-\uDFFF])?\u200D?(?:[\u2695\u2696\u2708]|\uD83C[\uDF3E-\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83D[\uDC68\uDC69]|\uD83E[\uDDD0-\uDDDF])(?:\uD83C[\uDFFA-\uDFFF])?\u200D?[\u2640\u2642\u2695\u2696\u2708]?\uFE0F?|(?:(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])[\u200D\uFE0F]{0,2})|(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])|(?:(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])\uFE0F?)|(?:\uD83D[\uDC68\uDC69\uDC6E\uDC71-\uDC87\uDD75\uDE45-\uDE4E]|\uD83E[\uDD26\uDD37]|\uD83C[\uDFC3-\uDFCC]|\uD83E[\uDD38-\uDD3E]|\uD83D[\uDEA3-\uDEB6]|\u26f9|\uD83D\uDC6F)\uFE0F?(?:\uD83C[\uDFFB-\uDFFF])?\u200D?[\u2640\u2642]?\uFE0F?|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85-\uDFCC]|\uD83D[\uDC42-\uDCAA\uDD74-\uDD96\uDE45-\uDE4F\uDEA3-\uDECC]|\uD83E[\uDD18-\uDD3E])\uFE0F?(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u2194-\u2199\u21a9-\u21aa]\uFE0F?|[\u0023\u002a]|[\u3030\u303d]\uFE0F?|(?:\ud83c[\udd70-\udd71]|\ud83c\udd8e|\ud83c[\udd91-\udd9a])\uFE0F?|\u24c2\uFE0F?|[\u3297\u3299]\uFE0F?|(?:\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51])\uFE0F?|[\u203c\u2049]\uFE0F?|[\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe]\uFE0F?|[\u00a9\u00ae]\uFE0F?|[\u2122\u2139]\uFE0F?|\ud83c\udc04\uFE0F?|[\u2b05-\u2b07\u2b1b-\u2b1c\u2b50\u2b55]\uFE0F?|[\u231a-\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa]\uFE0F?|\ud83c\udccf|[\u2934\u2935]\uFE0F?)|[\u2700-\u27bf]\uFE0F?|[\ud800-\udbff][\udc00-\udfff]\uFE0F?|[\u2600-\u26FF]\uFE0F?|[\u0030-\u0039]\uFE0F", "g");
ns.regUnicode = new RegExp("<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(?:\uD83C\uDFF3)\uFE0F?\u200D?(?:\uD83C\uDF08)|(?:\uD83D\uDC41)\uFE0F?\u200D?(?:\uD83D\uDDE8)\uFE0F?|[#-9]\uFE0F?\u20E3|(?:(?:\uD83C\uDFF4)(?:\uDB40[\uDC60-\uDCFF]){1,6})|(?:\uD83C[\uDDE0-\uDDFF]){2}|(?:(?:\uD83D[\uDC68\uDC69]))\uFE0F?(?:\uD83C[\uDFFA-\uDFFF])?\u200D?(?:[\u2695\u2696\u2708]|\uD83C[\uDF3E-\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83D[\uDC68\uDC69]|\uD83E[\uDDD0-\uDDDF])(?:\uD83C[\uDFFA-\uDFFF])?\u200D?[\u2640\u2642\u2695\u2696\u2708]?\uFE0F?|(?:(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])[\u200D\uFE0F]{0,2}){1,3}(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])|(?:(?:\u2764|\uD83D[\uDC66-\uDC69\uDC8B])\uFE0F?){2,4}|(?:\uD83D[\uDC68\uDC69\uDC6E\uDC71-\uDC87\uDD75\uDE45-\uDE4E]|\uD83E[\uDD26\uDD37]|\uD83C[\uDFC3-\uDFCC]|\uD83E[\uDD38-\uDD3E]|\uD83D[\uDEA3-\uDEB6]|\u26f9|\uD83D\uDC6F)\uFE0F?(?:\uD83C[\uDFFB-\uDFFF])?\u200D?[\u2640\u2642]?\uFE0F?|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85-\uDFCC]|\uD83D[\uDC42-\uDCAA\uDD74-\uDD96\uDE45-\uDE4F\uDEA3-\uDECC]|\uD83E[\uDD18-\uDD3E])\uFE0F?(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u2194-\u2199\u21a9-\u21aa]\uFE0F?|[\u0023\u002a]|[\u3030\u303d]\uFE0F?|(?:\ud83c[\udd70-\udd71]|\ud83c\udd8e|\ud83c[\udd91-\udd9a])\uFE0F?|\u24c2\uFE0F?|[\u3297\u3299]\uFE0F?|(?:\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51])\uFE0F?|[\u203c\u2049]\uFE0F?|[\u25aa-\u25ab\u25b6\u25c0\u25fb-\u25fe]\uFE0F?|[\u00a9\u00ae]\uFE0F?|[\u2122\u2139]\uFE0F?|\ud83c\udc04\uFE0F?|[\u2b05-\u2b07\u2b1b-\u2b1c\u2b50\u2b55]\uFE0F?|[\u231a-\u231b\u2328\u23cf\u23e9-\u23f3\u23f8-\u23fa]\uFE0F?|\ud83c\udccf|[\u2934\u2935]\uFE0F?)|[\u2700-\u27bf]\uFE0F?|[\ud800-\udbff][\udc00-\udfff]\uFE0F?|[\u2600-\u26FF]\uFE0F?|[\u0030-\u0039]\uFE0F", "g");
ns.toImage = function(str) {
str = ns.unicodeToImage(str);
@ -6643,17 +6618,16 @@ backbone.nativeview = __webpack_require__(/*! backbone.nativeview */ "./node_mod
var replaceWith,unicode,short,fname,alt,category,title,size,ePath;
var mappedUnicode = ns.mapUnicodeToShort();
var eList = ns.emojioneList;
var bList = ns.blacklistChars.split(',');
str = str.replace(ns.regUnicode, function(unicodeChar) {
if( (typeof unicodeChar === 'undefined') || (unicodeChar === '') )
{
return unicodeChar;
}
else if ( unicodeChar in ns.jsEscapeMap && bList.indexOf(unicodeChar) === -1 )
else if ( unicodeChar in ns.jsEscapeMap )
{
fname = ns.jsEscapeMap[unicodeChar];
}
else if ( ns.greedyMatch && unicodeChar in ns.jsEscapeMapGreedy && bList.indexOf(unicodeChar) === -1 )
else if ( ns.greedyMatch && unicodeChar in ns.jsEscapeMapGreedy )
{
fname = ns.jsEscapeMapGreedy[unicodeChar];
}
@ -33105,12 +33079,13 @@ var map = {
function webpackContext(req) {
var id = webpackContextResolve(req);
return __webpack_require__(id);
var module = __webpack_require__(id);
return module;
}
function webpackContextResolve(req) {
var id = map[req];
if(!(id + 1)) { // check for number or string
var e = new Error("Cannot find module '" + req + "'");
var e = new Error('Cannot find module "' + req + '".');
e.code = 'MODULE_NOT_FOUND';
throw e;
}
@ -52266,6 +52241,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
//# sourceMappingURL=pluggable.js.map
/***/ }),
/***/ "./node_modules/process/browser.js":
@ -70187,7 +70163,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
keyPressed(ev) {
/* Event handler for when a key is pressed in a chat box textarea.
*/
if (ev.keyCode === KEY.ENTER) {
if (ev.keyCode === KEY.ENTER && !ev.shiftKey) {
this.onFormSubmitted(ev);
} else if (ev.keyCode !== KEY.FORWARD_SLASH && this.model.get('chat_state') !== _converse.COMPOSING) {
// Set chat state to composing if keyCode is not a forward-slash
@ -74594,7 +74570,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
text = xss.filterXSS(text, {
'whiteList': {}
});
msg_content.innerHTML = _.flow(_.partial(u.geoUriToHttp, _, _converse.geouri_replacement), u.addHyperlinks, _.partial(u.addEmoji, _converse, emojione, _))(text);
msg_content.innerHTML = _.flow(_.partial(u.geoUriToHttp, _, _converse.geouri_replacement), u.addHyperlinks, u.renderNewLines, _.partial(u.addEmoji, _converse, emojione, _))(text);
}
u.renderImageURLs(_converse, msg_content).then(() => {
@ -86967,6 +86943,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
});
};
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.
*/

View File

@ -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\nHave 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\nHave 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\nHave you heard\nthe 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(

View File

@ -145,6 +145,7 @@
msg_content.innerHTML = _.flow(
_.partial(u.geoUriToHttp, _, _converse.geouri_replacement),
u.addHyperlinks,
u.renderNewLines,
_.partial(u.addEmoji, _converse, emojione, _)
)(text);
}

View File

@ -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.
*/