Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Dec 9, 2024
1 parent fc517ed commit 9f6519a
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/ui/src/builder/settings/BuilderTemplateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,14 @@ function _get(object: object, path: string[]) {
const handleComplete = (selectedText: string) => {
let newValue = input.value?.value ?? "";
const { selectionStart, selectionEnd } = input.value?.getSelection() ?? {};
console.log({ selectionStart, selectionEnd });
const text = newValue.slice(0, selectionStart);
const full = getPath(text);
if (full === null) return;
const keyword = full.at(-1);
const regexKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "$"; // escape the keyword to handle properly on a regex
const replaced = text.replace(new RegExp(regexKeyword), selectedText);
// TODO: fix autocomplete
console.log("handleComplete old", input.value.value);
newValue = replaced + newValue.slice(selectionEnd);
emit("input", { target: { value: newValue } });
console.log("handleComplete new", newValue);
emit("update:value", newValue);
autocompleteOptions.value = [];
input.value.focus();
Expand Down

0 comments on commit 9f6519a

Please sign in to comment.