youssefreda9 commited on
Commit
252b187
·
1 Parent(s): bf8500f

fix: add undo support for autocomplete suggestions

Browse files
Files changed (1) hide show
  1. src/js/autocomplete.js +3 -0
src/js/autocomplete.js CHANGED
@@ -360,6 +360,9 @@
360
  // Build the text to insert: [optional space] + word + space
361
  var textToInsert = (needsSpaceBefore ? ' ' : '') + word + ' ';
362
 
 
 
 
363
  // Use execCommand for reliable insertion in contenteditable
364
  // This preserves undo history and handles cursor position correctly
365
  document.execCommand('insertText', false, textToInsert);
 
360
  // Build the text to insert: [optional space] + word + space
361
  var textToInsert = (needsSpaceBefore ? ' ' : '') + word + ' ';
362
 
363
+ // Save undo state before inserting
364
+ if (typeof pushUndoState === 'function') pushUndoState();
365
+
366
  // Use execCommand for reliable insertion in contenteditable
367
  // This preserves undo history and handles cursor position correctly
368
  document.execCommand('insertText', false, textToInsert);