summaryrefslogtreecommitdiff
path: root/ext/fg/js/source.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/source.js')
-rw-r--r--ext/fg/js/source.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index 664dbec7..cd8f63fd 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -16,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// \u200c (Zero-width non-joiner) appears on Google Docs from Chrome 76 onwards
+const IGNORE_TEXT_PATTERN = /\u200c/g;
+
/*
* TextSourceRange
@@ -32,7 +35,13 @@ class TextSourceRange {
}
text() {
- return this.content;
+ let strippedIndices = [];
+ const text = this.content.replace(IGNORE_TEXT_PATTERN, (match, offset) => {
+ strippedIndices.push(offset);
+ return '';
+ });
+
+ return {text, strippedIndices};
}
setEndOffset(length) {
@@ -195,7 +204,13 @@ class TextSourceElement {
}
text() {
- return this.content;
+ let strippedIndices = [];
+ const text = this.content.replace(IGNORE_TEXT_PATTERN, (match, offset) => {
+ strippedIndices.push(offset);
+ return '';
+ });
+
+ return {text, strippedIndices};
}
setEndOffset(length) {