1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

fix: fix annotation cannot be removed issue; update highlights example

This commit is contained in:
hsqStephenZhang 2024-03-06 00:03:48 +08:00
parent f09089cf77
commit 8ca344d4ec

View file

@ -1,5 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -50,9 +51,9 @@
cursor: pointer; cursor: pointer;
margin-left: 0; margin-left: 0;
} }
</style> </style>
</head> </head>
<body> <body>
<div id="frame"> <div id="frame">
<div id="viewer" class="spreads"></div> <div id="viewer" class="spreads"></div>
@ -138,6 +139,7 @@
book.getRange(cfiRange).then(function (range) { book.getRange(cfiRange).then(function (range) {
var text; var text;
var div = document.createElement("div");
var li = document.createElement('li'); var li = document.createElement('li');
var a = document.createElement('a'); var a = document.createElement('a');
var remove = document.createElement('a'); var remove = document.createElement('a');
@ -156,13 +158,16 @@
remove.textContent = "remove"; remove.textContent = "remove";
remove.href = "#" + cfiRange; remove.href = "#" + cfiRange;
remove.onclick = function () { remove.onclick = function () {
rendition.annotations.remove(cfiRange); rendition.annotations.remove(cfiRange, "highlight");
li.removeChild(div);
return false; return false;
}; };
li.appendChild(a); div.appendChild(a);
li.appendChild(textNode); div.appendChild(textNode);
li.appendChild(remove); div.appendChild(remove);
li.appendChild(div);
highlights.appendChild(li); highlights.appendChild(li);
} }
@ -173,4 +178,5 @@
</script> </script>
</body> </body>
</html> </html>