Skip to content

Commit

Permalink
Merge pull request #3618 from omnivore-app/feature/text-direction-ext…
Browse files Browse the repository at this point in the history
…ension

Allow web extension to get the content text direction and save
  • Loading branch information
sywhb authored Mar 5, 2024
2 parents 62bfbd5 + 7cd69da commit 9b64d47
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/extension/src/scripts/content/prepare-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
contentCopyEl.style.left = '-2000px'
contentCopyEl.style.zIndex = '-2000'
contentCopyEl.innerHTML = document.body.innerHTML
const dir = document.dir

// Appending copy of the content to the DOM to enable computed styles capturing ability
// Without adding that copy to the DOM the `window.getComputedStyle` method will always return undefined.
Expand All @@ -149,7 +150,7 @@
* capture them separately and concatenate them here with head and body tags
* preserved.
*/
const contentCopyHtml = `<html><head>${document.head.innerHTML}</head><body>${contentCopyEl.innerHTML}</body></html>`
const contentCopyHtml = `<html ${dir.toLowerCase() === 'rtl' ? 'dir="rtl"': ''}><head>${document.head.innerHTML}</head><body>${contentCopyEl.innerHTML}</body></html>`
// Cleaning up the copy element
contentCopyEl.remove()
return contentCopyHtml
Expand Down

0 comments on commit 9b64d47

Please sign in to comment.