Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix link input ux

ammarahm-ed051bf6dae594
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/item.js b/apps/mobile/src/screens/editor/tiny/toolbar/item.js
index 2690bdd9a..5c6ba9807 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/item.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/item.js
@@ -239,12 +239,9 @@ const ToolbarItem = ({
return;
}
- if (
- (format === 'link' && properties.selection.current?.length === 0) ||
- !properties.selection
- ) {
+ if (!properties.selection) {
ToastEvent.show({
- heading: 'No selection',
+ heading: 'No text selected',
message: 'Select some text before adding a link.',
type: 'error'
});
diff --git a/apps/mobile/src/screens/editor/tiny/toolbar/linkinput.js b/apps/mobile/src/screens/editor/tiny/toolbar/linkinput.js
index 4bb8aca75..4e71b3ba6 100644
--- a/apps/mobile/src/screens/editor/tiny/toolbar/linkinput.js
+++ b/apps/mobile/src/screens/editor/tiny/toolbar/linkinput.js
@@ -54,11 +54,6 @@ const ToolbarLinkInput = ({ format, value, setVisible }) => {
}, 1000);
}
}
-
- return () => {
- tiny.call(EditorWebView, tiny.restoreRange);
- tiny.call(EditorWebView, tiny.clearRange);
- };
}, [mode]);
const onChangeText = value => {
@@ -87,19 +82,28 @@ const ToolbarLinkInput = ({ format, value, setVisible }) => {
}
console.log('format:', format, 'value:', inputValue);
properties.userBlur = true;
- tiny.call(EditorWebView, tiny.restoreRange);
- tiny.call(EditorWebView, tiny.clearRange);
+ console.log('set range on submit');
formatSelection(execCommands[format](inputValue));
+ tiny.call(EditorWebView, tiny.clearRange);
}
editing.tooltip = null;
- setMode(INPUT_MODE.NO_EDIT);
+
+ if (inputValue) {
+ properties.pauseSelectionChange = true;
+ eSendEvent('showTooltip', {
+ data: null,
+ value: inputValue,
+ type: 'link'
+ });
+ }
focusEditor(format, false);
properties.userBlur = false;
};
const onBlur = async () => {
+ console.log('clear range on blur');
tiny.call(EditorWebView, tiny.clearRange);
formatSelection(`current_selection_range = null`);
if (properties.userBlur) return;