@cocreate/cursors
Advanced tools
Comparing version 1.23.5 to 1.24.0
{ | ||
"name": "@cocreate/cursors", | ||
"version": "1.23.5", | ||
"version": "1.24.0", | ||
"description": "Collaborative user cursor position for inputs, textarea's and contenteditable elements.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -107,2 +107,4 @@ /******************************************************************************** | ||
let domTextEditor = element; | ||
if (element.hasAttribute('contenteditable')) { | ||
@@ -114,6 +116,23 @@ contenteditable = true | ||
// if (frameClientId == selection.socketId) continue; | ||
element = element.contentDocument.documentElement; | ||
domTextEditor = element = element.contentDocument.documentElement; | ||
let pos = getElementPosition(domTextEditor.htmlString, start, end); | ||
if (pos.path) { | ||
element = element.querySelector(pos.path); | ||
if (pos.start) { | ||
let endPos = end - start; | ||
if (endPos > 0) | ||
end = pos.start + endPos; | ||
else | ||
end = pos.start; | ||
start = pos.start; | ||
} | ||
} | ||
} | ||
if (!element.htmlString) | ||
if (!domTextEditor.htmlString) | ||
continue | ||
// let pos = getElementPosition(domTextEditor.htmlString, start, end); | ||
@@ -147,3 +166,6 @@ | ||
mirrorDiv.element = element; | ||
element.insertAdjacentElement('afterend', mirrorDiv); | ||
if (element.tagName === "HTML") | ||
element.insertAdjacentElement('beforeend', mirrorDiv); | ||
else | ||
element.insertAdjacentElement('afterend', mirrorDiv); | ||
// let parent = element.parentElement; | ||
@@ -186,3 +208,3 @@ // let parentComputed = getComputedStyle(parent); | ||
if (element.parentElement.style['display'] == 'inline') { | ||
if (element.parentElement && element.parentElement.style['display'] == 'inline') { | ||
style.top = element.clientTop + 'px'; | ||
@@ -237,3 +259,3 @@ style.left = element.clientLeft + 'px'; | ||
if (contenteditable) { | ||
selectionElement = getElementPosition(element.htmlString, start, end); | ||
selectionElement = getElementPosition(domTextEditor.htmlString, selection.start, selection.end); | ||
} | ||
@@ -244,3 +266,4 @@ | ||
lastChildElement = selection_user.lastElementChild; | ||
lastChildTagName = lastChildElement.tagName.toLowerCase() | ||
if (lastChildElement) | ||
lastChildTagName = lastChildElement.tagName.toLowerCase() | ||
} | ||
@@ -470,3 +493,3 @@ | ||
observe: ['addedNodes'], | ||
target: '[array][object][key]', | ||
selector: '[array][object][key]', | ||
callback: function (mutation) { | ||
@@ -473,0 +496,0 @@ initElement(mutation.target); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172616
17
618