antigravity-rtl-patcher 3.0.3 → 3.0.5

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.3",
3
+ "version": "3.0.5",
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,32 +38,109 @@ 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
+
41
99
  const CSS = \`
42
- /* RTL Styles */
43
- body.rtl-active p,
44
- body.rtl-active h1, body.rtl-active h2, body.rtl-active h3,
45
- body.rtl-active h4, body.rtl-active h5, body.rtl-active h6,
46
- body.rtl-active ul, body.rtl-active ol, body.rtl-active li,
47
- body.rtl-active div:not(#rtl-panel):not(.rtl-ui),
48
- body.rtl-active span:not(.rtl-ui) {
100
+ /* Vazirmatn Font */
101
+ @font-face {
102
+ font-family: 'Vazirmatn';
103
+ src: url('./Vazirmatn-Variable.woff2') format('woff2');
104
+ font-weight: 100 900;
105
+ font-display: swap;
106
+ }
107
+
108
+ /* Apply Vazirmatn to all text when RTL is active */
109
+ body.rtl-active {
110
+ font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
111
+ }
112
+
113
+ /* RTL Styles - Only for message content */
114
+ body.rtl-active [dir="rtl"] {
49
115
  direction: rtl !important;
50
116
  text-align: right !important;
117
+ unicode-bidi: isolate !important;
118
+ }
119
+
120
+ /* Keep paragraphs and headings with proper bidi */
121
+ body.rtl-active p,
122
+ body.rtl-active h1, body.rtl-active h2, body.rtl-active h3,
123
+ body.rtl-active h4, body.rtl-active h5, body.rtl-active h6 {
51
124
  unicode-bidi: plaintext !important;
125
+ text-align: start !important;
52
126
  }
53
127
 
54
- body.rtl-active [dir="rtl"] ul,
128
+ /* Lists in RTL context */
129
+ body.rtl-active [dir="rtl"] ul,
55
130
  body.rtl-active [dir="rtl"] ol {
56
131
  padding-left: 0 !important;
57
- padding-right: 1.5rem !important;
132
+ padding-right: 2rem !important;
58
133
  }
59
134
 
60
- body.rtl-active pre,
61
- body.rtl-active code,
62
- body.rtl-active pre *,
135
+ /* Code blocks always LTR */
136
+ body.rtl-active pre,
137
+ body.rtl-active code,
138
+ body.rtl-active pre *,
63
139
  body.rtl-active code * {
64
140
  direction: ltr !important;
65
141
  text-align: left !important;
66
142
  unicode-bidi: isolate !important;
143
+ font-family: 'Courier New', Consolas, Monaco, monospace !important;
67
144
  }
68
145
 
69
146
  /* Panel Container */
@@ -298,8 +375,14 @@ win.webContents.on('dom-ready', () => {
298
375
 
299
376
  if (rtlEnabled) {
300
377
  document.body.classList.add('rtl-active');
378
+ applyRTLToContent();
301
379
  } else {
302
380
  document.body.classList.remove('rtl-active');
381
+ // Remove all dir attributes when disabled
382
+ document.querySelectorAll('[dir="rtl"].rtl-processed').forEach(el => {
383
+ el.removeAttribute('dir');
384
+ el.classList.remove('rtl-processed');
385
+ });
303
386
  }
304
387
 
305
388
  console.log('RTL_CONFIG_SAVE:' + JSON.stringify({ enabled: rtlEnabled }));