antigravity-rtl-patcher 3.0.7 → 3.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/utils-inject.js +64 -77
package/package.json
CHANGED
package/payload/utils-inject.js
CHANGED
|
@@ -38,64 +38,6 @@ win.webContents.on('dom-ready', () => {
|
|
|
38
38
|
let rtlEnabled = ${rtlConfig.enabled};
|
|
39
39
|
let panelVisible = false;
|
|
40
40
|
|
|
41
|
-
// RTL Detection Function
|
|
42
|
-
function isRTLText(text) {
|
|
43
|
-
if (!text || typeof text !== 'string') return false;
|
|
44
|
-
const rtlChars = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
|
|
45
|
-
const cleanText = text.trim();
|
|
46
|
-
if (cleanText.length === 0) return false;
|
|
47
|
-
|
|
48
|
-
// Check first non-whitespace character
|
|
49
|
-
for (let char of cleanText) {
|
|
50
|
-
if (char.trim()) {
|
|
51
|
-
return rtlChars.test(char);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Apply RTL to text elements dynamically
|
|
58
|
-
function applyRTLToContent() {
|
|
59
|
-
if (!rtlEnabled) return;
|
|
60
|
-
|
|
61
|
-
// Target message containers and paragraphs
|
|
62
|
-
const textElements = document.querySelectorAll('p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th');
|
|
63
|
-
|
|
64
|
-
textElements.forEach(el => {
|
|
65
|
-
// Skip if already processed or is UI element
|
|
66
|
-
if (el.classList.contains('rtl-ui') || el.classList.contains('rtl-processed')) return;
|
|
67
|
-
|
|
68
|
-
// Skip code blocks
|
|
69
|
-
if (el.closest('pre, code')) return;
|
|
70
|
-
|
|
71
|
-
const text = el.textContent;
|
|
72
|
-
if (isRTLText(text)) {
|
|
73
|
-
el.setAttribute('dir', 'rtl');
|
|
74
|
-
el.classList.add('rtl-processed');
|
|
75
|
-
} else if (el.hasAttribute('dir') && el.getAttribute('dir') === 'rtl') {
|
|
76
|
-
el.removeAttribute('dir');
|
|
77
|
-
el.classList.remove('rtl-processed');
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Observe DOM changes
|
|
83
|
-
const observer = new MutationObserver((mutations) => {
|
|
84
|
-
if (rtlEnabled) {
|
|
85
|
-
applyRTLToContent();
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// Start observing after a short delay
|
|
90
|
-
setTimeout(() => {
|
|
91
|
-
observer.observe(document.body, {
|
|
92
|
-
childList: true,
|
|
93
|
-
subtree: true,
|
|
94
|
-
characterData: true
|
|
95
|
-
});
|
|
96
|
-
applyRTLToContent();
|
|
97
|
-
}, 500);
|
|
98
|
-
|
|
99
41
|
const CSS = \`
|
|
100
42
|
/* Persian/Arabic Font Stack */
|
|
101
43
|
body.rtl-active {
|
|
@@ -105,23 +47,65 @@ win.webContents.on('dom-ready', () => {
|
|
|
105
47
|
-webkit-font-smoothing: antialiased !important;
|
|
106
48
|
}
|
|
107
49
|
|
|
108
|
-
/*
|
|
109
|
-
body.rtl-active [
|
|
110
|
-
|
|
111
|
-
|
|
50
|
+
/* Keep sidebars, navigation, and main layout LTR */
|
|
51
|
+
body.rtl-active [class*="sidebar"],
|
|
52
|
+
body.rtl-active [class*="nav"],
|
|
53
|
+
body.rtl-active [class*="menu"],
|
|
54
|
+
body.rtl-active [class*="toolbar"],
|
|
55
|
+
body.rtl-active [class*="panel"],
|
|
56
|
+
body.rtl-active [class*="list"],
|
|
57
|
+
body.rtl-active aside,
|
|
58
|
+
body.rtl-active nav {
|
|
59
|
+
direction: ltr !important;
|
|
60
|
+
text-align: left !important;
|
|
112
61
|
}
|
|
113
62
|
|
|
114
|
-
/*
|
|
115
|
-
body.rtl-active p,
|
|
116
|
-
body.rtl-active h1,
|
|
117
|
-
body.rtl-active
|
|
118
|
-
|
|
119
|
-
|
|
63
|
+
/* RTL only for message/chat content area */
|
|
64
|
+
body.rtl-active [class*="message"] p,
|
|
65
|
+
body.rtl-active [class*="message"] h1,
|
|
66
|
+
body.rtl-active [class*="message"] h2,
|
|
67
|
+
body.rtl-active [class*="message"] h3,
|
|
68
|
+
body.rtl-active [class*="message"] h4,
|
|
69
|
+
body.rtl-active [class*="message"] h5,
|
|
70
|
+
body.rtl-active [class*="message"] h6,
|
|
71
|
+
body.rtl-active [class*="message"] li,
|
|
72
|
+
body.rtl-active [class*="chat"] p,
|
|
73
|
+
body.rtl-active [class*="chat"] h1,
|
|
74
|
+
body.rtl-active [class*="chat"] h2,
|
|
75
|
+
body.rtl-active [class*="chat"] h3,
|
|
76
|
+
body.rtl-active [class*="chat"] h4,
|
|
77
|
+
body.rtl-active [class*="chat"] h5,
|
|
78
|
+
body.rtl-active [class*="chat"] h6,
|
|
79
|
+
body.rtl-active [class*="chat"] li,
|
|
80
|
+
body.rtl-active [class*="content"] p,
|
|
81
|
+
body.rtl-active [class*="content"] h1,
|
|
82
|
+
body.rtl-active [class*="content"] h2,
|
|
83
|
+
body.rtl-active [class*="content"] h3,
|
|
84
|
+
body.rtl-active [class*="content"] h4,
|
|
85
|
+
body.rtl-active [class*="content"] h5,
|
|
86
|
+
body.rtl-active [class*="content"] h6,
|
|
87
|
+
body.rtl-active [class*="content"] li,
|
|
88
|
+
body.rtl-active main p,
|
|
89
|
+
body.rtl-active main h1,
|
|
90
|
+
body.rtl-active main h2,
|
|
91
|
+
body.rtl-active main h3,
|
|
92
|
+
body.rtl-active main h4,
|
|
93
|
+
body.rtl-active main h5,
|
|
94
|
+
body.rtl-active main h6,
|
|
95
|
+
body.rtl-active main li {
|
|
96
|
+
direction: rtl !important;
|
|
97
|
+
text-align: right !important;
|
|
120
98
|
}
|
|
121
99
|
|
|
122
|
-
/* Lists
|
|
123
|
-
body.rtl-active [
|
|
124
|
-
body.rtl-active [
|
|
100
|
+
/* Lists */
|
|
101
|
+
body.rtl-active [class*="message"] ul,
|
|
102
|
+
body.rtl-active [class*="message"] ol,
|
|
103
|
+
body.rtl-active [class*="chat"] ul,
|
|
104
|
+
body.rtl-active [class*="chat"] ol,
|
|
105
|
+
body.rtl-active [class*="content"] ul,
|
|
106
|
+
body.rtl-active [class*="content"] ol,
|
|
107
|
+
body.rtl-active main ul,
|
|
108
|
+
body.rtl-active main ol {
|
|
125
109
|
padding-left: 0 !important;
|
|
126
110
|
padding-right: 2rem !important;
|
|
127
111
|
}
|
|
@@ -136,6 +120,15 @@ win.webContents.on('dom-ready', () => {
|
|
|
136
120
|
font-family: 'Courier New', Consolas, Monaco, monospace !important;
|
|
137
121
|
}
|
|
138
122
|
|
|
123
|
+
/* Keep UI elements LTR */
|
|
124
|
+
body.rtl-active button,
|
|
125
|
+
body.rtl-active input,
|
|
126
|
+
body.rtl-active select,
|
|
127
|
+
body.rtl-active [role="button"] {
|
|
128
|
+
direction: ltr !important;
|
|
129
|
+
text-align: left !important;
|
|
130
|
+
}
|
|
131
|
+
|
|
139
132
|
/* Panel Container */
|
|
140
133
|
#rtl-trigger {
|
|
141
134
|
position: fixed;
|
|
@@ -368,14 +361,8 @@ win.webContents.on('dom-ready', () => {
|
|
|
368
361
|
|
|
369
362
|
if (rtlEnabled) {
|
|
370
363
|
document.body.classList.add('rtl-active');
|
|
371
|
-
applyRTLToContent();
|
|
372
364
|
} else {
|
|
373
365
|
document.body.classList.remove('rtl-active');
|
|
374
|
-
// Remove all dir attributes when disabled
|
|
375
|
-
document.querySelectorAll('[dir="rtl"].rtl-processed').forEach(el => {
|
|
376
|
-
el.removeAttribute('dir');
|
|
377
|
-
el.classList.remove('rtl-processed');
|
|
378
|
-
});
|
|
379
366
|
}
|
|
380
367
|
|
|
381
368
|
console.log('RTL_CONFIG_SAVE:' + JSON.stringify({ enabled: rtlEnabled }));
|