Fix Scribe mobile issues
- Fix Scribe replace on mobile when opened from menu bar (to be complete this fix needs this PR https://github.com/Enough-Software/enough_html_editor/pull/37) - Ensure all mobile editor call are awaited - Do not clear text if a selection has been restored (which mean we replace a selection) - Avoid collapseToEnd crash
This commit is contained in:
@@ -197,7 +197,7 @@ class HtmlUtils {
|
||||
script: '''
|
||||
(() => {
|
||||
const selection = window.getSelection();
|
||||
if (selection) {
|
||||
if (selection && selection.rangeCount > 0) {
|
||||
selection.collapseToEnd()
|
||||
}
|
||||
})();''',
|
||||
@@ -220,9 +220,10 @@ class HtmlUtils {
|
||||
const selection = window.getSelection();
|
||||
if (selection && selection.rangeCount > 0) {
|
||||
window._savedRange = selection.getRangeAt(0).cloneRange();
|
||||
return true;
|
||||
return selection.toString();
|
||||
}
|
||||
return false;
|
||||
delete window._savedRange;
|
||||
return "";
|
||||
})();''',
|
||||
name: 'saveSelection');
|
||||
|
||||
@@ -234,10 +235,10 @@ class HtmlUtils {
|
||||
if (selection) {
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(window._savedRange);
|
||||
return true;
|
||||
return selection.toString();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return "";
|
||||
})();''',
|
||||
name: 'restoreSelection');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user