Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
<fix> update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
flaming-cl committed Jan 22, 2023
1 parent 0098324 commit 4f3132b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ class Color {

newWrapper.appendChild(selectedText);
range.insertNode(newWrapper);

if (this.pluginType === 'marker') {
this.wrapMarker(newWrapper);
} else {
this.wrapTextColor(newWrapper);
}

this.api.selection.expandToTag(newWrapper);
}

Expand Down Expand Up @@ -216,6 +218,11 @@ class Color {
sel.addRange(range)
}

/**
* update color without create a new tag
*
* @param {Range} termWrapper - parent of selected fragment
*/
updateWrapper(termWrapper) {
if (this.pluginType === 'marker') {
termWrapper.style.backgroundColor = this.color;
Expand All @@ -224,6 +231,11 @@ class Color {
}
}

/**
* remove wrapper
*
* @param {Range} termWrapper - parent of selected fragment
*/
removeWrapper(termWrapper) {
termWrapper.parentNode.removeChild(termWrapper);
}
Expand Down

0 comments on commit 4f3132b

Please sign in to comment.