-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there are way to access EditorState? #19
Comments
Hello, If I remember correctly, you never have to instanciate the |
Ah ok, thanks. I'll have another look. Do you know what this might happen to look like? I'm guessing maybe something like this now? <script>
function myCompletions(context) {
let word = context.matchBefore(/\w*/)
if (word.from == word.to && !context.explicit) {
return null
}
return {
from: word.from,
options: [
{label: "match", type: "keyword"},
{label: "hello", type: "variable", info: "(World)"},
{label: "magic", type: "text", apply: "⠁⭒*.✩.*⭒⠁", detail: "macro"}
]
}
}
</script>
<CodeMirror
bind:value={value}
lang={javascript().data.of({
autocomplete: myCompletions
})}
extensions={[autocomplete()]}
/> |
Sorry for my late response. Did it work for you? |
For information, PR #31 allows you to get access to |
Hi. Thanks for letting me know about this. The code I proposed didn't work unfortunately so I created an instance from scratch. When I get chance I'll try the new event. Thanks you! |
@gavinmcfarland could you please share the code if you could get that to work. |
Sure, I created it from scratch. Maybe it'll help you. https://github.com/gavinmcfarland/figma-vite-svelte-codemirror-example/blob/main/src/App.svelte |
Thanks a lot Gavin, really appreciate it. |
Firstly. Thank you for sharing this Svelte component. It makes it a lot easier to use CodeMirror out of the box.
I'm trying to add my own autocomplete suggestions but I'm struggling to understand CodeMirror's documentation. If I understand it correctly, EditorState is needed to pass through as a CompletionContext. If this is correct is there a way to get the EditorState from svelte-codemirror-editor?
https://codemirror.net/docs/ref/#autocomplete.CompletionContext
The text was updated successfully, but these errors were encountered: