Hide keyboard and selection icons when Scribe mobile modal opened

When opening Scribe mobile modal, we now unfocus the composer to hide the keyboard and the selection start and end icons from the OS.

Add new methods to save, restore, and clear text selection in HTML editor. These methods allow preserving and restoring user selection state when opening the Scribe mobile modal so that the "replace" action still works.
This commit is contained in:
Théo Poizat
2026-01-12 11:08:13 +01:00
committed by Dat H. Pham
parent 09fe002d3c
commit 84176cb113
5 changed files with 135 additions and 4 deletions
+34
View File
@@ -214,6 +214,40 @@ class HtmlUtils {
})();''',
name: 'deleteSelectionContent');
static const saveSelection = (
script: '''
(() => {
const selection = window.getSelection();
if (selection && selection.rangeCount > 0) {
window._savedRange = selection.getRangeAt(0).cloneRange();
return true;
}
return false;
})();''',
name: 'saveSelection');
static const restoreSelection = (
script: '''
(() => {
if (window._savedRange) {
const selection = window.getSelection();
if (selection) {
selection.removeAllRanges();
selection.addRange(window._savedRange);
return true;
}
}
return false;
})();''',
name: 'restoreSelection');
static const clearSavedSelection = (
script: '''
(() => {
delete window._savedRange;
})();''',
name: 'clearSavedSelection');
static recalculateEditorHeight({double? maxHeight}) => (
script: '''
const editable = document.querySelector('.note-editable');