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