mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-03 12:41:45 +02:00
add search with editor selection
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -604,7 +604,7 @@ function getNodeBg(element) {
|
||||
}
|
||||
|
||||
let selectionTimer = null;
|
||||
function selectchange() {
|
||||
function selectchange(requestvalue) {
|
||||
clearTimeout(selectionTimer);
|
||||
selectionTimer = null;
|
||||
selectionTimer = setTimeout(function () {
|
||||
@@ -631,9 +631,13 @@ function selectchange() {
|
||||
|
||||
currentFormats.current = {
|
||||
index: range.startOffset,
|
||||
length: range.endOffset - range.startOffset
|
||||
length: range.endOffset - range.startOffset,
|
||||
};
|
||||
|
||||
if (requestvalue) {
|
||||
currentFormats.current.value = editor.selection.getContent()
|
||||
}
|
||||
|
||||
currentFormats.fontsize = editor.selection.getNode().style.fontSize;
|
||||
|
||||
if (currentFormats.fontsize === '') {
|
||||
@@ -684,5 +688,5 @@ function selectchange() {
|
||||
}
|
||||
currentFormats.node = editor.selection.getNode().nodeName;
|
||||
reactNativeEventHandler('selectionchange', currentFormats);
|
||||
}, 50);
|
||||
},requestvalue ? 0 : 50);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {useTracked} from '../../../../provider';
|
||||
import {useSettingStore} from '../../../../provider/stores';
|
||||
import {showTooltip, TOOLTIP_POSITIONS} from '../../../../utils';
|
||||
import {SIZE} from '../../../../utils/SizeUtils';
|
||||
import { sleep } from '../../../../utils/TimeUtils';
|
||||
import {EditorWebView} from '../../Functions';
|
||||
import tiny from '../tiny';
|
||||
import {endSearch} from './commands';
|
||||
@@ -28,9 +29,18 @@ const SearcReplace = () => {
|
||||
replace: null
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
async function searchWithSelection() {
|
||||
tiny.call(EditorWebView,`selectchange(true)`);
|
||||
await sleep(100);
|
||||
values.current.find = properties.selection?.current?.value;
|
||||
findRef.current?.setNativeProps({
|
||||
text:values.current.find
|
||||
})
|
||||
find();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
searchWithSelection();
|
||||
setTimeout(() => {
|
||||
findRef.current?.focus();
|
||||
}, 300);
|
||||
|
||||
Reference in New Issue
Block a user