fix(pdfjs-annotation-viewer): initialize konvaClientRect dimensions and add HASH_PARAMS implementation
Updated the pdfjs-annotation-extension-testdata.json to set default dimensions for konvaClientRect to zero. Added a HASH_PARAMS implementation in viewer.html to handle hash parsing, ensuring compatibility with the pdfjs-annotation-extension bundle and preventing runtime errors.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -34,6 +34,27 @@ See https://github.com/adobe-type-tools/cmap-resources
|
||||
<link rel="stylesheet" href="viewer.css">
|
||||
|
||||
<script src="viewer.mjs" type="module"></script>
|
||||
<script>
|
||||
// Provide a minimal HASH_PARAMS implementation expected by the
|
||||
// pdfjs-annotation-extension bundle. It mirrors the core viewer's
|
||||
// hash parsing behaviour enough to avoid runtime errors.
|
||||
(function () {
|
||||
if (window.HASH_PARAMS) {
|
||||
return;
|
||||
}
|
||||
const hash = window.location.hash || "";
|
||||
const raw = hash.startsWith("#") ? hash.slice(1) : hash;
|
||||
const params = new URLSearchParams(raw);
|
||||
window.HASH_PARAMS = {
|
||||
get(name) {
|
||||
// Always return a string to avoid null/undefined consumers
|
||||
// calling .slice()/etc. on a non-string value.
|
||||
const v = params.get(name);
|
||||
return v == null ? "" : String(v);
|
||||
},
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
<script src="./pdfjs-annotation-extension/pdfjs-annotation-extension.js" type="module"></script>
|
||||
</head>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user