-
-
Notifications
You must be signed in to change notification settings - Fork 603
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
How to add snippets manually without brace? #742
Comments
bump |
i have the same issue here |
Also having this issue. Tried just testing with the included python snippet and it did not work.
|
That's one thing, it is unclear how to add custom snippets
pon., 23 mar 2020, 21:22 użytkownik Jesse Chua <notifications@github.com>
napisał:
… Also having this issue. Tried just testing with the included python
snippet and it did not work.
import React, {Component} from "react";
import AceEditor from "react-ace";
import "ace-builds/src-noconflict/ext-language_tools";
import "ace-builds/src-noconflict/mode-python";
import "ace-builds/src-noconflict/snippets/python";
import "ace-builds/src-noconflict/theme-monokai";
<AceEditor
mode="python"
theme="monokai"
onChange={this.onChange}
name="editor"
enableSnippets={true}
editorProps={{ $blockScrolling: true }}
/>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#742 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABK7F6NVYNF3TFKAEWD3OE3RI7AIXANCNFSM4JNTXATQ>
.
|
I got how to add snippets I will send the code sample once I open my pc. |
I made a codesandbox demo for you on how to add Snippets : |
Tell me if it was helpful. |
If u get an error like unexpected token < . in code sandbox. |
Hey @mohsinxx365 your demo doesn't seem to be working on refresh. Closing the unexpected token window just reveals an empty editor. |
I don't know why the problem occurs.for me it worked . |
I will try to fix the codesandbox issue. So that anyone who has the problem can refer to it . |
Try typing double underscore (__) in the editor u will see a snippet named info. It will work . |
Then just press enter |
Let me know if it worked |
It looks like it works now after completing the double underscore! Is there a way to automatically show the snippet without having to autocomplete the double underscores? |
You can just change the snippet prefix to not use (__). |
So did it work ? |
Hello I tried to go to the codesandbox link but it seems that the link is not working anymore? |
It's a problem with codesandbox . Just copy the code and try it will work. |
No I didn't see any codes. I clicked the link and get the message "Not Found |
I will send a new link soon |
Is there some update about it? |
Looking forward to see this issue solved. |
Done . This is the link to the codesandbox with the demo and some documentation : |
If it shows Unexpected token '<' |
Tell me if it helped you |
@orzzt nice |
This is my previous code modification. I don't know what will happen |
I used the previous code to modify it and found it can be used, but I don't know if there will be other problems |
I recommend you to use the approach I provided because it is more consice (Short). And understandable. |
You can remove your previous code |
I don’t think it will cause any problem |
ok.Thank you very much. |
np |
@mohsinxx365 what about snippets with code with placeholders like:
|
There is some mechanism for that as well, as far as I remember |
I will check and tell soon |
@mohsinxx365 any update on this? |
@danilafrolov @piotrkochan using the implementation described above you can use placeholders like this (example of lua function):
|
i am now using @mohsinxx365 setup like this const completions: any[] = [
{
caption: "demo",
snippet: `This is Another Snippet \${1:name}`,
type: "snippet",
meta: "test",
},
{
caption: "demo2",
snippet: `This is Another Snippet 2`,
type: "snippet",
meta: "test",
},
];
setCompleters([
{
getCompletions: (editor: any, session: any, pos: any, prefix: any, callback: any) => {
completions.forEach((i) => {
completions.push({
caption: i.caption,
snippet: i.snippet,
type: i.type,
meta: i.meta,
docHTML: null,
});
});
callback(null, completions);
},
getDocTooltip: function (item: any) {
if (item.type === "snippet" && !item.docHTML) {
item.docHTML = ["<b>", item.caption, "</b>", "<hr></hr>", item.snippet].join("");
}
},
},
]); The getDocTooltip function will even make the tooltips reapear. I was missing those. |
Hi, I want to add my own snippets to
AceEditor
.I found this: https://github.com/denvash/react-json-snippet-editor . But, I've read, that Brace is no longer supported for React Ace.
How should I add them now?
My component
The text was updated successfully, but these errors were encountered: