marathi_typing 0.2.0 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f9141d8b16760161d8c02f9611f2b28faf4c51430bf02dc4c9ea958cd5aa2c6
4
- data.tar.gz: d080cc2cdc1cd09aac409e3dee8d069205f3582950aefe0828787f96c08071ee
3
+ metadata.gz: bea1ae0ad19188d8d72b79dd93e2458edcb7815de0b9a2eef7a068467cae9ad2
4
+ data.tar.gz: 0df203a4cc8a8d1e6b5a62684c38b116ccaa657b80c8cc1419b6b88c5d1d3e4d
5
5
  SHA512:
6
- metadata.gz: d0cbb74bb7d19520fdd564cc6eeaecca4504d96cbcf0638e4c50f9c13f94cb627bb600d7afa5e13dd28e69790dc6a765dbf81dfe6fd3db79e964101b8d7ba4ed
7
- data.tar.gz: 37d6525b0e2d1e04152d79e710666f18fd5feb208e18852e0de93dd9c55a0b46f44437ea475974f0b03cbc6b470b61e3748c96810ce905231ea50cab9b4e48f1
6
+ metadata.gz: dc082fc3eaaac92ecee8282cda4fb7adbdc8264ab33594f7888bef997f6968e074c207015f12ad918f70685481563ea2113d1f668e57c130583811b021ba8d75
7
+ data.tar.gz: b24417a8cfc3a182135f0f37144d074f4d8adb43ccd648595e761f532f75c4a01c684f7cf5ab5c6b115ac89168b21846a255f65b93dafdc69a14f2fdb9823132
@@ -5,7 +5,6 @@ export default class extends Controller {
5
5
 
6
6
  timeout = null
7
7
 
8
-
9
8
  connect() {
10
9
 
11
10
  this.apiUrl = "https://inputtools.google.com/request"
@@ -50,8 +49,6 @@ export default class extends Controller {
50
49
  console.log("currentWord: ", currentWord)
51
50
 
52
51
  if (!currentWord || !/^[a-zA-Z]+$/.test(currentWord)) return;
53
- // if (!currentWord) return;
54
-
55
52
 
56
53
  fetch(`${this.apiUrl}?text=${currentWord}&itc=mr-t-i0-und&num=5&cp=0&cs=1&ie=utf-8&oe=utf-8&app=demopage`)
57
54
  .then(res => res.json())
@@ -65,27 +62,33 @@ export default class extends Controller {
65
62
  }
66
63
 
67
64
  buildSuggestionsBox() {
68
-
69
- const box = document.createElement("div")
65
+ const box = document.createElement("div");
70
66
  box.className = "marathi-suggestions";
71
67
  box.style.position = "absolute";
72
- box.style.background = "#808080";
68
+ box.style.background = "rgb(239 238 236)";
73
69
  box.style.border = "0px solid #ccc";
74
70
  box.style.zIndex = "9999";
75
71
  box.style.padding = "0px";
76
72
  box.style.color = "black";
77
73
 
74
+ // Get the input's position relative to the viewport
78
75
  const rect = this.inputTarget.getBoundingClientRect();
79
- const scrollOffset = window.scrollY || window.pageYOffset;
80
76
 
81
- box.style.top = `${rect.bottom + scrollOffset}px`;
82
- box.style.left = `${rect.left}px`; //
77
+ // Calculate position relative to the document
78
+ const scrollTop = window.scrollY || window.pageYOffset;
79
+ const scrollLeft = window.scrollX || window.pageXOffset;
83
80
 
84
- this.element.parentElement.appendChild(box)
81
+ // Set position just below the input
82
+ box.style.top = `${rect.bottom + scrollTop}px`;
83
+ box.style.left = `${rect.left + scrollLeft}px`;
85
84
 
86
- return box
85
+ // Append to body to avoid being affected by parent positioning
86
+ document.body.appendChild(box);
87
+
88
+ return box;
87
89
  }
88
90
 
91
+
89
92
  showSuggestions(suggestions, lastWord) {
90
93
  this.showSuggestionsBox();
91
94
 
@@ -106,8 +109,6 @@ export default class extends Controller {
106
109
  this.suggestionsTarget.appendChild(originalOption);
107
110
  }
108
111
 
109
-
110
-
111
112
  selectFirstSuggestion() {
112
113
  if (!this.suggestionsTarget || this.suggestionsTarget.children.length === 0) return;
113
114
 
@@ -125,12 +126,8 @@ export default class extends Controller {
125
126
  currentWord = words[words.length - 1] || "";
126
127
  }
127
128
 
128
-
129
129
  if (!currentWord) return;
130
130
 
131
- console.log("currentWord:", currentWord, " suggestion:", suggestion);
132
-
133
-
134
131
  this.selectSuggestion(suggestion, currentWord);
135
132
  }
136
133
  }
@@ -200,8 +197,6 @@ export default class extends Controller {
200
197
  return { word, wordStart, wordEnd };
201
198
  }
202
199
 
203
-
204
-
205
200
  hideSuggestions() {
206
201
  this.suggestionsTarget.innerHTML = "";
207
202
  this.suggestionsTarget.style.border = "0";
@@ -209,9 +204,20 @@ export default class extends Controller {
209
204
  }
210
205
 
211
206
  showSuggestionsBox() {
207
+
208
+ const rect = this.inputTarget.getBoundingClientRect();
209
+
210
+ // Calculate position relative to the document
211
+ const scrollTop = window.scrollY || window.pageYOffset;
212
+ const scrollLeft = window.scrollX || window.pageXOffset;
213
+
214
+ // Set position just below the input
215
+ this.suggestionsTarget.style.top = `${rect.bottom + scrollTop}px`;
216
+ this.suggestionsTarget.style.left = `${rect.left + scrollLeft}px`;
217
+
212
218
  this.suggestionsTarget.innerHTML = "";
213
219
  this.suggestionsTarget.style.border = "1px solid #0a0a0a";
214
220
  this.suggestionsTarget.style.padding = "4px";
215
221
  }
216
222
 
217
- }
223
+ }
@@ -1,3 +1,3 @@
1
1
  module MarathiTyping
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marathi_typing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ajit Dhanje
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-15 00:00:00.000000000 Z
11
+ date: 2025-04-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: