mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-26 03:35:19 +00:00
* dashboard: fix modal position on rtl pages, fixes #2495 * Align text to the right on right-to-left pages * core: fix default text alignment on right-to-left pages * dashboard: fix margin in provider browser on right-to-left pages * dashboard: use direction-aware offset properties * provider-views: use logical offset CSS properties * status-bar: use logical offset CSS properties * dashboard: fix addMore icon margin on RTL pages * dashboard: some more logical properties * build: compile logical properties to old CSS * dashboard: set dir attribute if page did not provide one * status-bar: set fallback text direction if not provided * support direction option for inline and modal dashboard * use companion.uppy.io on deploy previews * provider-views: fix RTL alignment of file icons * put the dir attribute on a wrapper div * fix icon alignment in RTL provider views * informer: fix ? alignment in RTL mode
21 lines
767 B
JavaScript
21 lines
767 B
JavaScript
/**
|
|
* Get the declared text direction for an element.
|
|
*
|
|
* @param {Node} element
|
|
* @returns {string|undefined}
|
|
*/
|
|
|
|
function getTextDirection (element) {
|
|
// There is another way to determine text direction using getComputedStyle(), as done here:
|
|
// https://github.com/pencil-js/text-direction/blob/2a235ce95089b3185acec3b51313cbba921b3811/text-direction.js
|
|
//
|
|
// We do not use that approach because we are interested specifically in the _declared_ text direction.
|
|
// If no text direction is declared, we have to provide our own explicit text direction so our
|
|
// bidirectional CSS style sheets work.
|
|
while (element && !element.dir) {
|
|
element = element.parentNode
|
|
}
|
|
return element ? element.dir : undefined
|
|
}
|
|
|
|
module.exports = getTextDirection
|