@mintplex-labs/advanced-selection-hook 1.0.2 → 1.0.3

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/index.d.ts CHANGED
@@ -321,6 +321,15 @@ declare class SelectionHook extends EventEmitter {
321
321
  */
322
322
  readFromClipboard(): string | null;
323
323
 
324
+ /**
325
+ * Replace the last selected text with new text (Windows only).
326
+ * Uses UI Automation ValuePattern.SetValue so the highlighted range is replaced
327
+ * without focus/clipboard. Only works when the last selection was via UIA in an editable control.
328
+ * @param replacementText - UTF-8 text to insert in place of the selection
329
+ * @returns true if replacement was applied, false otherwise
330
+ */
331
+ replaceSelectedText(replacementText: string): boolean;
332
+
324
333
  /**
325
334
  * Check if the process is trusted for accessibility (macOS only)
326
335
  *
package/index.js CHANGED
@@ -422,6 +422,29 @@ class SelectionHook extends EventEmitter {
422
422
  }
423
423
  }
424
424
 
425
+ /**
426
+ * Replace the last selected text with new text (Windows only).
427
+ * Uses UI Automation ValuePattern.SetValue to push text into the highlighted range
428
+ * without relying on focus/clipboard. Only works when the last selection was obtained
429
+ * via UI Automation in an editable control.
430
+ * @param {string} replacementText - UTF-8 text to insert in place of the selection
431
+ * @returns {boolean} true if replacement was applied, false otherwise
432
+ */
433
+ replaceSelectedText(replacementText) {
434
+ if (typeof replacementText !== "string") {
435
+ this.#handleError("replaceSelectedText requires a string", new Error("Invalid argument"));
436
+ return false;
437
+ }
438
+ if (!this.#instance) return false;
439
+
440
+ try {
441
+ return this.#instance.replaceSelectedText(replacementText);
442
+ } catch (err) {
443
+ this.#handleError("Failed to replace selected text", err);
444
+ return false;
445
+ }
446
+ }
447
+
425
448
  /**
426
449
  * Check if the process is trusted for accessibility (macOS only)
427
450
  * @returns {boolean} True if the process is trusted for accessibility, false otherwise
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplex-labs/advanced-selection-hook",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Text selection monitoring of native Node.js module with N-API across applications",
5
5
  "author": "@mintplex-labs",
6
6
  "repository": {