MCPcopy Create free account
hub / github.com/dailydotdev/apps / getSelectedString

Function getSelectedString

packages/shared/src/lib/textarea.ts:7–15  ·  view source on GitHub ↗
(textarea: HTMLTextAreaElement)

Source from the content-addressed store, hash-verified

5 !value || value === ' ' || value === '\n';
6
7const getSelectedString = (textarea: HTMLTextAreaElement) => {
8 const [start, end] = [textarea.selectionStart, textarea.selectionEnd];
9 const last = start === end ? start + 1 : end;
10 const text = textarea.value.substring(start, last);
11 const trailing = textarea.value[start - 1];
12 const leading = textarea.value[start - 1];
13
14 return [text, trailing, leading];
15};
16
17const splitString = (value: string, [start, end]: number[]) => {
18 const left = value.substring(0, start);

Callers 2

getCursorTypeFunction · 0.85
TextareaCommandClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected