Fix more Scribe mobile issues

- Add getSavedSelection to check saved selection without consuming it
- Distinguish between setText (replace all) and insertText (at cursor) operations
- Fix replace callback to use setText when no selection exists
- Clean up saved selection state after restoration in HTML utils
- Move mobile editor focus and selection restore to appropriate callbacks
This commit is contained in:
Théo Poizat
2026-01-21 16:19:04 +01:00
committed by Dat H. Pham
parent be7f28f270
commit b5606626f4
2 changed files with 71 additions and 23 deletions
+12
View File
@@ -235,6 +235,7 @@ class HtmlUtils {
if (selection) {
selection.removeAllRanges();
selection.addRange(window._savedRange);
delete window._savedRange;
return selection.toString();
}
}
@@ -242,6 +243,17 @@ class HtmlUtils {
})();''',
name: 'restoreSelection');
static const getSavedSelection = (
script: '''
(() => {
if(window._savedRange) {
return window._savedRange.toString();
} else {
return "";
}
})();''',
name: 'getSavedSelection');
static const clearSavedSelection = (
script: '''
(() => {