Skip to content

Build your personal knowledge base with Trilium Notes

feat(split): add right to left support

Elian Doran68033580a5c3
diff --git a/packages/splitjs/index.d.ts b/packages/splitjs/index.d.ts
index a39df01b09..d4ad55cde6 100644
--- a/packages/splitjs/index.d.ts
+++ b/packages/splitjs/index.d.ts
@@ -44,6 +44,9 @@ declare namespace Split {
// Direction to split: horizontal or vertical.
direction?: 'horizontal' | 'vertical'
+ // If the UI is right-to-left. Affects the drag direction.
+ rtl?: boolean
+
// Cursor to display while dragging.
cursor?: string
diff --git a/packages/splitjs/src/split.js b/packages/splitjs/src/split.js
index 6e1871c3e9..3f8f9dc9cd 100644
--- a/packages/splitjs/src/split.js
+++ b/packages/splitjs/src/split.js
@@ -182,6 +182,7 @@ const Split = (idsOption, options = {}) => {
defaultElementStyleFn,
)
const gutterStyle = getOption(options, 'gutterStyle', defaultGutterStyleFn)
+ const rtl = getOption(options, 'rtl', false)
// 2. Initialize a bunch of strings based on the direction we're splitting.
// A lot of the behavior in the rest of the library is paramatized down to
@@ -621,6 +622,7 @@ const Split = (idsOption, options = {}) => {
// if the parent has a reverse flex-direction, switch the pair elements.
if (
+ (direction === HORIZONTAL && rtl) ||
parentFlexDirection === 'row-reverse' ||
parentFlexDirection === 'column-reverse'
) {