Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Fix and refactor `getCaretPosition` (#1782)
Davidac19d649a45e
diff --git a/webroot/js/utils/chat.js b/webroot/js/utils/chat.jsindex 51e44348f0..d793803cb2 100644--- a/webroot/js/utils/chat.js+++ b/webroot/js/utils/chat.js@@ -6,16 +6,21 @@ import {// Taken from https://stackoverflow.com/a/46902361export function getCaretPosition(node) {- var range = window.getSelection().getRangeAt(0),- preCaretRange = range.cloneRange(),- caretPosition,- tmp = document.createElement('div');+ const selection = window.getSelection();++ if (selection.rangeCount === 0) {+ return 0;+ }++ const range = selection.getRangeAt(0);+ const preCaretRange = range.cloneRange();+ const tempElement = document.createElement('div');preCaretRange.selectNodeContents(node);preCaretRange.setEnd(range.endContainer, range.endOffset);- tmp.appendChild(preCaretRange.cloneContents());- caretPosition = tmp.innerHTML.length;- return caretPosition;+ tempElement.appendChild(preCaretRange.cloneContents());++ return tempElement.innerHTML.length;}// Might not need this anymore