Skip to content

Commit

Permalink
Update docs an prepare v3.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
IDisposable committed Sep 12, 2024
1 parent ad2bb59 commit 0b43df1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,28 +170,34 @@ on the root node.

#### adjustClonedNode

A function that will be invoked on each node as they are cloned. Useful to adjust nodes in any way needed before the conversion.
Note that this be invoked before the onclone callback.
The handler gets the original node, the cloned node, and a boolean that says if we've cloned the children already (so you can handle either before or after)
A function that will be invoked on each node as they are cloned. Useful to adjust nodes in
any way needed before the conversion. Note that this be invoked before the onclone
callback. The handler gets the original node, the cloned node, and a boolean that says if
we've cloned the children already (so you can handle either before or after)

Sample use:

```const adjustClone = (node, clone, after) => {
if (!after && clone.id === 'element') {
clone.style.transform = 'translateY(100px)';
}
return clone;
return clone;
}
```

const wrapper = document.getElementById('wrapper');
const blob = domtoimage.toBlob(wrapper, { adjustClonedNode: adjustClone});
const wrapper = document.getElementById('wrapper'); const blob =
domtoimage.toBlob(wrapper, { adjustClonedNode: adjustClone});

#### onclone

A function taking the cloned and modified DOM node as argument. It allows to make final adjustements to the elements before rendering, on the whole clone, after all elements have been individually cloned. Note that this will be invoked after all the onclone callbacks have been fired.
A function taking the cloned and modified DOM node as argument. It allows to make final
adjustements to the elements before rendering, on the whole clone, after all elements have
been individually cloned. Note that this will be invoked after all the onclone callbacks
have been fired.

The cloned DOM might differ a lot from the original DOM, for example canvas will be replaced with image tags, some class might have changed, the style are inlined. It can be useful to log the clone to get a better senses of the transformations.
The cloned DOM might differ a lot from the original DOM, for example canvas will be
replaced with image tags, some class might have changed, the style are inlined. It can be
useful to log the clone to get a better senses of the transformations.

#### bgcolor

Expand Down Expand Up @@ -386,7 +392,8 @@ DOLCIMASCOLO (packaging), Zee (ZM) @zm-cttae (many major updates), Joshua Walsh
@nstuyvesant (fixes), King Wang @eachmawzw (CORS image proxy), TMM Schmit @tmmschmit
(useCredentialsFilters), Aravind @codesculpture (fix overridden props), Shi Wenyu @cWenyu
(shadow slot fix), David Burns @davidburns573 and Yujia Cheng @YujiaCheng1996 (font copy
optional), Julien Dorra @juliendorra (documentation)
optional), Julien Dorra @juliendorra (documentation), Sean Zhang @SeanZhang-eaton (regex
fixes)

## License

Expand Down
2 changes: 1 addition & 1 deletion dist/dom-to-image-more.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dom-to-image-more.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dom-to-image-more",
"version": "3.4.5-beta.0",
"version": "3.4.5",
"description": "Generates an image from a DOM node using HTML5 canvas and SVG",
"main": "dist/dom-to-image-more.min.js",
"devDependencies": {
Expand Down Expand Up @@ -69,7 +69,8 @@
"Shi Wenyu @cWenyu",
"David Burns @davidburns573",
"Yujia Cheng @YujiaCheng1996",
"Julien Dorra @juliendorra"
"Julien Dorra @juliendorra",
"Sean Zhang @SeanZhang-eaton"
],
"license": "MIT",
"bugs": {
Expand Down
5 changes: 3 additions & 2 deletions src/dom-to-image-more.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@

function isInShadowRoot(value) {
// not calling the method, getting the method
if (value === null || value === undefined || value.getRootNode === undefined) return false;
if (value === null || value === undefined || value.getRootNode === undefined)
return false;
return isShadowRoot(value.getRootNode());
}

Expand Down Expand Up @@ -950,7 +951,7 @@
}

function escapeRegEx(string) {
return string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
return string.replace(/([.*+?^${}()|[\]/\\])/g, '\\$1');
}

function delay(ms) {
Expand Down

0 comments on commit 0b43df1

Please sign in to comment.