fix pdf.js可以复制,限制复制的数量

This commit is contained in:
赵霄
2024-03-04 11:30:57 +08:00
parent cfd503df23
commit f74c9c81a0
+14 -1
View File
@@ -38,7 +38,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</head>
<body tabindex="1">
<div id="outerContainer" style="user-select: none">
<div id="outerContainer">
<div id="sidebarContainer">
<div id="toolbarSidebar">
@@ -581,4 +581,17 @@ See https://github.com/adobe-type-tools/cmap-resources
<input type="file" id="fileInput" class="hidden">
</body>
<script>
const previewDom = document.getElementById('viewerContainer')
const handleSelectionChange = (event) => {
const windowSelection = window.getSelection()
const selectionText = windowSelection ? window.getSelection().toString() : document.selection.createRange().text
if (selectionText.length > 500) {
alert('超出可复制长度')
windowSelection ? window.getSelection().removeAllRanges() : document.selection.empty()
}
}
document.addEventListener('selectionchange', handleSelectionChange)
</script>
</html>