antigravity-rtl-patcher 3.0.7 → 3.0.8
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 +20 -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,19 @@ win.webContents.on('dom-ready', () => {
|
|
|
105
47
|
-webkit-font-smoothing: antialiased !important;
|
|
106
48
|
}
|
|
107
49
|
|
|
108
|
-
/* RTL
|
|
109
|
-
body.rtl-active [dir="rtl"] {
|
|
110
|
-
direction: rtl !important;
|
|
111
|
-
text-align: right !important;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/* Keep paragraphs and headings with proper bidi */
|
|
50
|
+
/* RTL ALL text content - but NOT layout */
|
|
115
51
|
body.rtl-active p,
|
|
116
52
|
body.rtl-active h1, body.rtl-active h2, body.rtl-active h3,
|
|
117
|
-
body.rtl-active h4, body.rtl-active h5, body.rtl-active h6
|
|
118
|
-
|
|
119
|
-
|
|
53
|
+
body.rtl-active h4, body.rtl-active h5, body.rtl-active h6,
|
|
54
|
+
body.rtl-active li, body.rtl-active span:not(.rtl-ui),
|
|
55
|
+
body.rtl-active div:not(#rtl-panel):not(.rtl-ui):not([class*="button"]):not([class*="icon"]):not([class*="toolbar"]) > *:not(button):not(input):not(select) {
|
|
56
|
+
direction: rtl !important;
|
|
57
|
+
text-align: right !important;
|
|
120
58
|
}
|
|
121
59
|
|
|
122
|
-
/* Lists
|
|
123
|
-
body.rtl-active
|
|
124
|
-
body.rtl-active
|
|
60
|
+
/* Lists */
|
|
61
|
+
body.rtl-active ul,
|
|
62
|
+
body.rtl-active ol {
|
|
125
63
|
padding-left: 0 !important;
|
|
126
64
|
padding-right: 2rem !important;
|
|
127
65
|
}
|
|
@@ -136,6 +74,17 @@ win.webContents.on('dom-ready', () => {
|
|
|
136
74
|
font-family: 'Courier New', Consolas, Monaco, monospace !important;
|
|
137
75
|
}
|
|
138
76
|
|
|
77
|
+
/* Keep UI elements LTR */
|
|
78
|
+
body.rtl-active button,
|
|
79
|
+
body.rtl-active input,
|
|
80
|
+
body.rtl-active select,
|
|
81
|
+
body.rtl-active [role="button"],
|
|
82
|
+
body.rtl-active [class*="toolbar"],
|
|
83
|
+
body.rtl-active [class*="menu"] {
|
|
84
|
+
direction: ltr !important;
|
|
85
|
+
text-align: left !important;
|
|
86
|
+
}
|
|
87
|
+
|
|
139
88
|
/* Panel Container */
|
|
140
89
|
#rtl-trigger {
|
|
141
90
|
position: fixed;
|
|
@@ -368,14 +317,8 @@ win.webContents.on('dom-ready', () => {
|
|
|
368
317
|
|
|
369
318
|
if (rtlEnabled) {
|
|
370
319
|
document.body.classList.add('rtl-active');
|
|
371
|
-
applyRTLToContent();
|
|
372
320
|
} else {
|
|
373
321
|
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
322
|
}
|
|
380
323
|
|
|
381
324
|
console.log('RTL_CONFIG_SAVE:' + JSON.stringify({ enabled: rtlEnabled }));
|