From 4f3132b71fbd4948cdbbe9fcd152e4a259b1a07b Mon Sep 17 00:00:00 2001 From: flaming-cl Date: Sun, 22 Jan 2023 14:51:25 -0500 Subject: [PATCH] update comments --- src/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/index.js b/src/index.js index 3d1f4d2..47a49de 100644 --- a/src/index.js +++ b/src/index.js @@ -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); } @@ -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; @@ -224,6 +231,11 @@ class Color { } } + /** + * remove wrapper + * + * @param {Range} termWrapper - parent of selected fragment + */ removeWrapper(termWrapper) { termWrapper.parentNode.removeChild(termWrapper); }