antigravity-rtl-patcher 3.0.6 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antigravity-rtl-patcher",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "Advanced RTL and Persian/Arabic typography patcher for Antigravity with customizable UI",
5
5
  "main": "src/patcher.js",
6
6
  "bin": {
Binary file
@@ -38,91 +38,28 @@ 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
- /* Vazirmatn Font from CDN */
101
- @import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');
102
-
103
- /* Apply Vazirmatn to all text when RTL is active */
42
+ /* Persian/Arabic Font Stack */
104
43
  body.rtl-active {
105
- font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
106
- }
107
-
108
- /* RTL Styles - Only for message content */
109
- body.rtl-active [dir="rtl"] {
110
- direction: rtl !important;
111
- text-align: right !important;
112
- unicode-bidi: isolate !important;
44
+ font-family: 'Segoe UI', Tahoma, Arial, 'Helvetica Neue', sans-serif !important;
45
+ font-feature-settings: 'liga' 1, 'calt' 1 !important;
46
+ text-rendering: optimizeLegibility !important;
47
+ -webkit-font-smoothing: antialiased !important;
113
48
  }
114
49
 
115
- /* Keep paragraphs and headings with proper bidi */
50
+ /* RTL ALL text content - but NOT layout */
116
51
  body.rtl-active p,
117
52
  body.rtl-active h1, body.rtl-active h2, body.rtl-active h3,
118
- body.rtl-active h4, body.rtl-active h5, body.rtl-active h6 {
119
- unicode-bidi: plaintext !important;
120
- text-align: start !important;
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;
121
58
  }
122
59
 
123
- /* Lists in RTL context */
124
- body.rtl-active [dir="rtl"] ul,
125
- body.rtl-active [dir="rtl"] ol {
60
+ /* Lists */
61
+ body.rtl-active ul,
62
+ body.rtl-active ol {
126
63
  padding-left: 0 !important;
127
64
  padding-right: 2rem !important;
128
65
  }
@@ -134,10 +71,20 @@ win.webContents.on('dom-ready', () => {
134
71
  body.rtl-active code * {
135
72
  direction: ltr !important;
136
73
  text-align: left !important;
137
- unicode-bidi: isolate !important;
138
74
  font-family: 'Courier New', Consolas, Monaco, monospace !important;
139
75
  }
140
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
+
141
88
  /* Panel Container */
142
89
  #rtl-trigger {
143
90
  position: fixed;
@@ -370,14 +317,8 @@ win.webContents.on('dom-ready', () => {
370
317
 
371
318
  if (rtlEnabled) {
372
319
  document.body.classList.add('rtl-active');
373
- applyRTLToContent();
374
320
  } else {
375
321
  document.body.classList.remove('rtl-active');
376
- // Remove all dir attributes when disabled
377
- document.querySelectorAll('[dir="rtl"].rtl-processed').forEach(el => {
378
- el.removeAttribute('dir');
379
- el.classList.remove('rtl-processed');
380
- });
381
322
  }
382
323
 
383
324
  console.log('RTL_CONFIG_SAVE:' + JSON.stringify({ enabled: rtlEnabled }));