Skip to content

Commit 04bb740

Browse files
committed
fix: space and tab compatibility with PowerPoint
1 parent 42f409d commit 04bb740

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/js/events/listeners.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ function registerEditListeners() {
8282
}
8383
}
8484
this.setSelectionRange(newStart, Math.max(newStart, newEnd));
85+
}).on("paste", function (e) {
86+
e.preventDefault();
87+
// This is a bug when copying from PowerPoint, where '\n' is
88+
// replaced with '\v' (vertical tab) and ' ' is replaced with '\xa0' (non-breaking space)
89+
const text = e.originalEvent.clipboardData.getData("text")
90+
.replaceAll(String.fromCharCode(11), "\n")
91+
.replaceAll(String.fromCharCode(160), " ");
92+
document.execCommand("insertText", false, text);
8593
});
8694
}
8795

src/version.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
{
1515
"title": "Fixes",
1616
"items": [
17-
"Tab key will no longer clear input history"
17+
"Tab key will no longer clear input history",
18+
"Compatibility issue with Microsoft PowerPoint"
1819
]
1920
}
2021
]

0 commit comments

Comments
 (0)