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

Merge pull request #7 from victorsoares96/fix/should-able-to-update-annotation-attributes

🩹 fix: should be able to update annotation attributes
This commit is contained in:
João Victor Moreira Soares 2024-03-24 18:18:53 -03:00 committed by GitHub
commit 9119f09b90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 128 additions and 68 deletions

View file

@ -8,4 +8,7 @@
"modules": "auto" "modules": "auto"
}] }]
], ],
"plugins": [
"@babel/plugin-proposal-optional-chaining", "@babel/plugin-proposal-nullish-coalescing-operator"
]
} }

View file

@ -115,11 +115,10 @@
// Apply a class to selected text // Apply a class to selected text
rendition.on("selected", function(cfiRange, contents) { rendition.on("selected", function(cfiRange, contents) {
rendition.annotations.highlight(cfiRange, {}, (e) => { const annotation = rendition.annotations.highlight(cfiRange, { john: 'doe' }, (e) => {
console.log("highlight clicked", e.target); console.log("highlight clicked", e.target);
}); });
contents.window.getSelection().removeAllRanges(); contents.window.getSelection().removeAllRanges();
}); });
this.rendition.themes.default({ this.rendition.themes.default({
@ -134,12 +133,18 @@
// Illustration of how to get text from a saved cfiRange // Illustration of how to get text from a saved cfiRange
var highlights = document.getElementById('highlights'); var highlights = document.getElementById('highlights');
const redrawAnnotations = () =>
rendition.views().forEach(view => view.pane ? view.pane.render() : null)
rendition.on('rendered', redrawAnnotations);
rendition.on("selected", function(cfiRange) { rendition.on("selected", function(cfiRange) {
book.getRange(cfiRange).then(function (range) { book.getRange(cfiRange).then(function (range) {
var text; var text;
var li = document.createElement('li'); var li = document.createElement('li');
var a = document.createElement('a'); var a = document.createElement('a');
var update = document.createElement('a');
var remove = document.createElement('a'); var remove = document.createElement('a');
var textNode; var textNode;
@ -160,8 +165,21 @@
return false; return false;
}; };
update.textContent = "update to red color";
update.href = "#" + cfiRange;
update.onclick = function () {
const annotations = Object.values(rendition.annotations._annotations);
annotations.forEach(annotation => {
annotation.update({}, { 'fill': 'red', 'fill-opacity': 0.5 });
});
rendition.views().forEach(view => view.pane ? view.pane.render() : null);
return false;
};
li.appendChild(a); li.appendChild(a);
li.appendChild(textNode); li.appendChild(textNode);
li.appendChild(update);
li.appendChild(remove); li.appendChild(remove);
highlights.appendChild(li); highlights.appendChild(li);
} }

131
package-lock.json generated
View file

@ -1,16 +1,16 @@
{ {
"name": "@victorsoares96/epubjs", "name": "@victorsoares96/epubjs",
"version": "0.3.95", "version": "0.3.96",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@victorsoares96/epubjs", "name": "@victorsoares96/epubjs",
"version": "0.3.95", "version": "0.3.96",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"dependencies": { "dependencies": {
"@types/localforage": "0.0.34", "@types/localforage": "0.0.34",
"@victorsoares96/marks-pane": "^1.0.12", "@victorsoares96/marks-pane": "^1.0.13",
"@xmldom/xmldom": "^0.7.5", "@xmldom/xmldom": "^0.7.5",
"core-js": "^3.18.3", "core-js": "^3.18.3",
"event-emitter": "^0.3.5", "event-emitter": "^0.3.5",
@ -24,6 +24,8 @@
"@babel/core": "^7.15.8", "@babel/core": "^7.15.8",
"@babel/plugin-proposal-export-default-from": "^7.14.5", "@babel/plugin-proposal-export-default-from": "^7.14.5",
"@babel/plugin-proposal-export-namespace-from": "^7.14.5", "@babel/plugin-proposal-export-namespace-from": "^7.14.5",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/preset-env": "^7.15.8", "@babel/preset-env": "^7.15.8",
"@babel/runtime": "^7.15.4", "@babel/runtime": "^7.15.4",
"babel-loader": "^8.2.3", "babel-loader": "^8.2.3",
@ -528,9 +530,9 @@
} }
}, },
"node_modules/@babel/helper-plugin-utils": { "node_modules/@babel/helper-plugin-utils": {
"version": "7.14.5", "version": "7.24.0",
"resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.14.5.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.0.tgz",
"integrity": "sha512-/37qQCE3K0vvZKwoK4XU/irIJQdIfCJuhU5eKnNxpFDsOkgFaUAwbv+RYw6eYgsC0E4hS7r5KqGULUogqui0fQ==", "integrity": "sha512-9cUznXMG0+FxRuJfvL82QlTqIzhVW9sL0KjMPHhAOOvpQGL8QtdxnBKILjBqxlHyliz0yCa1G903ZXI/FuHy2w==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
@ -578,12 +580,12 @@
} }
}, },
"node_modules/@babel/helper-skip-transparent-expression-wrappers": { "node_modules/@babel/helper-skip-transparent-expression-wrappers": {
"version": "7.15.4", "version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.15.4.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz",
"integrity": "sha512-BMRLsdh+D1/aap19TycS4eD1qELGrCBJwzaY9IE8LrpJtJb+H7rQkPIdsfgnMtLBA6DJls7X9z93Z4U8h7xw0A==", "integrity": "sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/types": "^7.15.4" "@babel/types": "^7.22.5"
}, },
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
@ -601,10 +603,19 @@
"node": ">=6.9.0" "node": ">=6.9.0"
} }
}, },
"node_modules/@babel/helper-string-parser": {
"version": "7.24.1",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz",
"integrity": "sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==",
"dev": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": { "node_modules/@babel/helper-validator-identifier": {
"version": "7.15.7", "version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
"integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
@ -848,12 +859,13 @@
} }
}, },
"node_modules/@babel/plugin-proposal-nullish-coalescing-operator": { "node_modules/@babel/plugin-proposal-nullish-coalescing-operator": {
"version": "7.14.5", "version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.14.5.tgz", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz",
"integrity": "sha512-gun/SOnMqjSb98Nkaq2rTKMwervfdAoz6NphdY0vTfuzMfryj+tDGb2n6UkDKwez+Y8PZDhE3D143v6Gepp4Hg==", "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==",
"deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/helper-plugin-utils": "^7.14.5", "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
}, },
"engines": { "engines": {
@ -915,13 +927,14 @@
} }
}, },
"node_modules/@babel/plugin-proposal-optional-chaining": { "node_modules/@babel/plugin-proposal-optional-chaining": {
"version": "7.14.5", "version": "7.21.0",
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.14.5.tgz", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz",
"integrity": "sha512-ycz+VOzo2UbWNI1rQXxIuMOzrDdHGrI23fRiz/Si2R4kv2XZQ1BK8ccdHwehMKBlcH/joGW/tzrUmo67gbJHlQ==", "integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==",
"deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/helper-plugin-utils": "^7.14.5", "@babel/helper-plugin-utils": "^7.20.2",
"@babel/helper-skip-transparent-expression-wrappers": "^7.14.5", "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0",
"@babel/plugin-syntax-optional-chaining": "^7.8.3" "@babel/plugin-syntax-optional-chaining": "^7.8.3"
}, },
"engines": { "engines": {
@ -1868,12 +1881,13 @@
"dev": true "dev": true
}, },
"node_modules/@babel/types": { "node_modules/@babel/types": {
"version": "7.15.6", "version": "7.24.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.15.6.tgz", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz",
"integrity": "sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==", "integrity": "sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@babel/helper-validator-identifier": "^7.14.9", "@babel/helper-string-parser": "^7.23.4",
"@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0" "to-fast-properties": "^2.0.0"
}, },
"engines": { "engines": {
@ -2122,9 +2136,9 @@
"dev": true "dev": true
}, },
"node_modules/@victorsoares96/marks-pane": { "node_modules/@victorsoares96/marks-pane": {
"version": "1.0.12", "version": "1.0.13",
"resolved": "https://registry.npmjs.org/@victorsoares96/marks-pane/-/marks-pane-1.0.12.tgz", "resolved": "https://registry.npmjs.org/@victorsoares96/marks-pane/-/marks-pane-1.0.13.tgz",
"integrity": "sha512-eXjgjCUhYjlphKvETG1/Fa0SFE2UrQf4j9W+8spHmxU0zrpIx+f3iWkNtY71WR4R1k30tCL0e5ZAM4UowihYUA==" "integrity": "sha512-E9scUrrve2TRC1yAEqwB73Ae0wk3Pv7N4qu9gyCXVZQ1qe9mrIirW9ivW+cd0wnEBcMZzdCZfumYt8f14KZEwA=="
}, },
"node_modules/@vue/compiler-core": { "node_modules/@vue/compiler-core": {
"version": "3.2.20", "version": "3.2.20",
@ -21226,9 +21240,9 @@
} }
}, },
"@babel/helper-plugin-utils": { "@babel/helper-plugin-utils": {
"version": "7.14.5", "version": "7.24.0",
"resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.14.5.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.0.tgz",
"integrity": "sha512-/37qQCE3K0vvZKwoK4XU/irIJQdIfCJuhU5eKnNxpFDsOkgFaUAwbv+RYw6eYgsC0E4hS7r5KqGULUogqui0fQ==", "integrity": "sha512-9cUznXMG0+FxRuJfvL82QlTqIzhVW9sL0KjMPHhAOOvpQGL8QtdxnBKILjBqxlHyliz0yCa1G903ZXI/FuHy2w==",
"dev": true "dev": true
}, },
"@babel/helper-remap-async-to-generator": { "@babel/helper-remap-async-to-generator": {
@ -21264,12 +21278,12 @@
} }
}, },
"@babel/helper-skip-transparent-expression-wrappers": { "@babel/helper-skip-transparent-expression-wrappers": {
"version": "7.15.4", "version": "7.22.5",
"resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.15.4.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz",
"integrity": "sha512-BMRLsdh+D1/aap19TycS4eD1qELGrCBJwzaY9IE8LrpJtJb+H7rQkPIdsfgnMtLBA6DJls7X9z93Z4U8h7xw0A==", "integrity": "sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/types": "^7.15.4" "@babel/types": "^7.22.5"
} }
}, },
"@babel/helper-split-export-declaration": { "@babel/helper-split-export-declaration": {
@ -21281,10 +21295,16 @@
"@babel/types": "^7.15.4" "@babel/types": "^7.15.4"
} }
}, },
"@babel/helper-string-parser": {
"version": "7.24.1",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz",
"integrity": "sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==",
"dev": true
},
"@babel/helper-validator-identifier": { "@babel/helper-validator-identifier": {
"version": "7.15.7", "version": "7.22.20",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
"integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
"dev": true "dev": true
}, },
"@babel/helper-validator-option": { "@babel/helper-validator-option": {
@ -21449,12 +21469,12 @@
} }
}, },
"@babel/plugin-proposal-nullish-coalescing-operator": { "@babel/plugin-proposal-nullish-coalescing-operator": {
"version": "7.14.5", "version": "7.18.6",
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.14.5.tgz", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz",
"integrity": "sha512-gun/SOnMqjSb98Nkaq2rTKMwervfdAoz6NphdY0vTfuzMfryj+tDGb2n6UkDKwez+Y8PZDhE3D143v6Gepp4Hg==", "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/helper-plugin-utils": "^7.14.5", "@babel/helper-plugin-utils": "^7.18.6",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3"
} }
}, },
@ -21492,13 +21512,13 @@
} }
}, },
"@babel/plugin-proposal-optional-chaining": { "@babel/plugin-proposal-optional-chaining": {
"version": "7.14.5", "version": "7.21.0",
"resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.14.5.tgz", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz",
"integrity": "sha512-ycz+VOzo2UbWNI1rQXxIuMOzrDdHGrI23fRiz/Si2R4kv2XZQ1BK8ccdHwehMKBlcH/joGW/tzrUmo67gbJHlQ==", "integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/helper-plugin-utils": "^7.14.5", "@babel/helper-plugin-utils": "^7.20.2",
"@babel/helper-skip-transparent-expression-wrappers": "^7.14.5", "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0",
"@babel/plugin-syntax-optional-chaining": "^7.8.3" "@babel/plugin-syntax-optional-chaining": "^7.8.3"
} }
}, },
@ -22152,12 +22172,13 @@
} }
}, },
"@babel/types": { "@babel/types": {
"version": "7.15.6", "version": "7.24.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.15.6.tgz", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz",
"integrity": "sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==", "integrity": "sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/helper-validator-identifier": "^7.14.9", "@babel/helper-string-parser": "^7.23.4",
"@babel/helper-validator-identifier": "^7.22.20",
"to-fast-properties": "^2.0.0" "to-fast-properties": "^2.0.0"
} }
}, },
@ -22357,9 +22378,9 @@
"dev": true "dev": true
}, },
"@victorsoares96/marks-pane": { "@victorsoares96/marks-pane": {
"version": "1.0.12", "version": "1.0.13",
"resolved": "https://registry.npmjs.org/@victorsoares96/marks-pane/-/marks-pane-1.0.12.tgz", "resolved": "https://registry.npmjs.org/@victorsoares96/marks-pane/-/marks-pane-1.0.13.tgz",
"integrity": "sha512-eXjgjCUhYjlphKvETG1/Fa0SFE2UrQf4j9W+8spHmxU0zrpIx+f3iWkNtY71WR4R1k30tCL0e5ZAM4UowihYUA==" "integrity": "sha512-E9scUrrve2TRC1yAEqwB73Ae0wk3Pv7N4qu9gyCXVZQ1qe9mrIirW9ivW+cd0wnEBcMZzdCZfumYt8f14KZEwA=="
}, },
"@vue/compiler-core": { "@vue/compiler-core": {
"version": "3.2.20", "version": "3.2.20",

View file

@ -1,6 +1,6 @@
{ {
"name": "@victorsoares96/epubjs", "name": "@victorsoares96/epubjs",
"version": "0.3.95", "version": "0.3.96",
"description": "Parse and Render Epubs", "description": "Parse and Render Epubs",
"main": "lib/index.js", "main": "lib/index.js",
"module": "src/index.js", "module": "src/index.js",
@ -35,6 +35,8 @@
"@babel/core": "^7.15.8", "@babel/core": "^7.15.8",
"@babel/plugin-proposal-export-default-from": "^7.14.5", "@babel/plugin-proposal-export-default-from": "^7.14.5",
"@babel/plugin-proposal-export-namespace-from": "^7.14.5", "@babel/plugin-proposal-export-namespace-from": "^7.14.5",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/preset-env": "^7.15.8", "@babel/preset-env": "^7.15.8",
"@babel/runtime": "^7.15.4", "@babel/runtime": "^7.15.4",
"babel-loader": "^8.2.3", "babel-loader": "^8.2.3",
@ -60,13 +62,13 @@
}, },
"dependencies": { "dependencies": {
"@types/localforage": "0.0.34", "@types/localforage": "0.0.34",
"@victorsoares96/marks-pane": "^1.0.13",
"@xmldom/xmldom": "^0.7.5", "@xmldom/xmldom": "^0.7.5",
"core-js": "^3.18.3", "core-js": "^3.18.3",
"event-emitter": "^0.3.5", "event-emitter": "^0.3.5",
"jszip": "^3.7.1", "jszip": "^3.7.1",
"localforage": "^1.10.0", "localforage": "^1.10.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"@victorsoares96/marks-pane": "^1.0.12",
"path-webpack": "0.0.3" "path-webpack": "0.0.3"
} }
} }

View file

@ -239,16 +239,32 @@ class Annotation {
*/ */
update (data = {}, styles = {}) { update (data = {}, styles = {}) {
if (this.data) this.data = data; if (this.data) this.data = data;
if (this.styles) { if (!this.styles) this.styles = {};
this.mark.attributes = {
...this.mark.attributes,
...styles,
};
this.mark.styles = { if (styles?.stroke) {
...this.mark.styles, this.mark.attributes.stroke = styles.stroke;
...styles, this.styles.stroke = styles.stroke;
}; }
if (styles?.["stroke-opacity"]) {
this.mark.attributes["stroke-opacity"] = styles["stroke-opacity"];
this.styles["stroke-opacity"] = styles["stroke-opacity"];
}
if (styles?.["stroke-width"]) {
this.mark.attributes["stroke-width"] = styles["stroke-width"];
this.styles["stroke-width"] = styles["stroke-width"];
}
if (styles?.fill) {
this.mark.attributes.fill = styles.fill;
this.mark.attributes.background = "red";
this.styles.fill = styles.fill;
}
if (styles?.["fill-opacity"]) {
this.mark.attributes["fill-opacity"] = styles["fill-opacity"];
this.styles["fill-opacity"] = styles["fill-opacity"];
} }
} }