Add some documentation
This commit is contained in:
24
service.js
24
service.js
@@ -701,6 +701,9 @@ class BesCKService extends BesService {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Grammar checking service for textarea element
|
||||
///
|
||||
class BesTAService {
|
||||
constructor(textAreaEl) {
|
||||
this.textAreaEl = textAreaEl
|
||||
@@ -714,6 +717,12 @@ class BesTAService {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clone div element for the textarea element
|
||||
*
|
||||
* @param {Node} textAreaEl
|
||||
* @returns {Node} Clone div element
|
||||
*/
|
||||
createCloneDiv(textAreaEl) {
|
||||
const cloneDiv = document.createElement('div')
|
||||
const textAreaRect = textAreaEl.getBoundingClientRect()
|
||||
@@ -738,6 +747,9 @@ class BesTAService {
|
||||
return cloneDiv
|
||||
}
|
||||
|
||||
/**
|
||||
* This function copies the text from the textarea to the clone div
|
||||
*/
|
||||
handleInput() {
|
||||
const customEvent = new InputEvent('beforeinput')
|
||||
|
||||
@@ -751,6 +763,11 @@ class BesTAService {
|
||||
this.cloneDiv.dispatchEvent(customEvent)
|
||||
}
|
||||
|
||||
/**
|
||||
* This function handles the click event on the textarea element and finds the deepest div at the click position
|
||||
*
|
||||
* @param {Event} e Click event
|
||||
*/
|
||||
handleTAClick(e) {
|
||||
//TODO: Consider adding some kind of proofing?
|
||||
this.textAreaEl.style.visibility = 'hidden'
|
||||
@@ -767,8 +784,13 @@ class BesTAService {
|
||||
this.cloneDiv.dispatchEvent(clickEvent)
|
||||
}
|
||||
|
||||
// TODO: think of a way to reposition the cursor after the replacement
|
||||
/**
|
||||
* This function handles the replacement of the text in the textarea element
|
||||
*
|
||||
* @param {HTMLElement} el Element to replace the text in
|
||||
*/
|
||||
handleReplacement(el) {
|
||||
// TODO: think of a way to reposition the cursor after the replacement
|
||||
this.textAreaEl.value = el.outerText
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user