Editor does not close #1096
Unanswered
danielo515
asked this question in
Errors
Replies: 2 comments 4 replies
-
|
By the way, I finally made the previewer of the editor to work, and it is almost exactly the same thing as the one I was using manually, except that it seems to have less control? Or you can return any html just like what you do with widgets? Can I position it? |
Beta Was this translation helpful? Give feedback.
2 replies
-
|
For unknown reasons to me the way the widget handles state is kind of weird. I'll shortly explain, as soon as you implement everything the same, but remove the widget it will work and close normally. Now I've found a weird way around that. // await copy(regex)
await setSelectedText(regex)// Name: make vim regex
import '@johnlindquist/kit';
function transformToVimRegex(text: string) {
const replaced = text.replaceAll(/[\n]+/g, '\\_s+');
return `:%s/\\v${replaced}`
}
const content = await clipboard.readText();
const previewer = await widget(`
<h1 class="text-2xl p-5 whitespace-nowrap ">
{{content}}
</h1>`, {
transparent: true,
draggable: true,
hasShadow: true,
alwaysOnTop: true,
});
let regex = "";
const _ = await editor({
value: content,
preview: (() => Promise.resolve(regex) ) as any,
hasPreview: true,
onInput(value) {
regex = transformToVimRegex(value || "");
previewer.setState({content: regex});
},
});
// await copy(regex);
await setSelectedText(regex)
previewer.close(); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
I am building a little utility to make writting search and replace in vim easier, but I'm facing a little problem (that was not happening in my first iteration of the script).
For some reason, after submitting the editor will not close.
It shows what looks like a loading bar and keeps open. It performs all the expected actions, it is just that does notk close. There are no errors on the global or scripts logs.
By the way, in case of running errors, there is no popup or anything, I had to run the script in a browser to find an error related to string.replaceAll.
Here is the script:
Beta Was this translation helpful? Give feedback.
All reactions