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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user