-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
API to hide parts of the code #45
Comments
Sorry for the late reply, there is a non-API way (might get removed in the future):
|
Thank you, In addition i solved to hide parts of the code by calling:
But for that to work I had to overwrite the FoldingController, it also handles the hidden Areas and was overriding mine. Would be great to have a build in way to hide Areas in combination with the Folding controller. |
👍 we plan at one point to make |
any update on this issue? |
Any update on this issue ? |
now it's called |
Never mind, I can do this :)
However, the use case is that I would need to is to colorize using |
I noticed that, although being a user feature request, Please consider re-including a It is useful in education and/or alongside code-generation; use cases where the user isn't intended to edit all of the source file. |
+1 on including |
If you are using typescript, you can use
to achieve similar effect. Now |
And it is better use like this import Space, { env as EnvClass } from 'vpt';
declare global {
const space: Space;
const env: typeof EnvClass;
} |
Can we hide parts of the code instead of folding it or making it read only? |
Any update on this one ? |
Any update? |
So I made a solution, at least for some cases. I've made the first and last line uneditable. If what you want to achieve is doable with
|
Is there any update on this API? Or any available workarounds to disable a bunch of lines for editing in monaco? |
I have the same requirement, where ideally I would have a few lines hidden before and after the user code, this way the user wouldn't have to worry about boilerplate code and at the same time VSCode would still validate the code as if the boilerplate was wrapping the user code. For instance on my case i would like the user to edit: myEvent: (data) => {
// do something
},
anotherEvent: (data) => {
// do something
}, And before validating I would like to wrap it all in |
Would be greatt for my case, too. I would like the user to write code that contains the await keyword without exposing him to the async function around. So basically I would like to wrap the user code inside this:
Without exposing this wrapper function to my user. |
I need this functionality also. I'm currently working out a way to approximate the behaviour perhaps by intercepting and cancelling edits in "read only" ranges. Ideas:
|
I would like to add one more idea, if we undo the values entered in the areas which we marked as read-only, then user wont feel like that area is editable, and we can show it as a boilerplate code for the users |
Any update on this? |
The internal
I'd like to propose to maintainers that this api become public, this is a useful feature. |
How do you expose the API? |
Looking for this as well. |
[clojure] Improve Clojure syntax highlighting.
One way is to extend the interface and then cast your instance to that interface and call the method: interface IMyStandaloneCodeEditor extends monaco.editor.IStandaloneCodeEditor {
setHiddenAreas(range: monaco.IRange[]): void;
}
...
const casted = editor as IMyStandaloneCodeEditor;
const range = new monaco.Range(1, 0, 1, 0);
casted.setHiddenAreas([range]); |
Hi @alexdima. It looks like |
it will appear as though its not there, you just have to The current published version 0.34.1 this still works. here it is in the playground |
Thanks, @RickeyWard. I've been doing it wrong. I was trying to The editor I'm trying to modify its values is not created by me, I am making use of |
@Gbahdeyboh |
In case of using
content from lines 1, 4, 8 still searchable 🤔 Many thanks! |
All this is useless shit as there are tons of drawbacks besides just search issues and content being editable outside of the currently visible lines. A fresh approach I've discovered is inspired by Civet's VSCode extension, basically you create a custom language that uses TS tokenizer, and steals QuickInfo, model markers, and completions from a regular TS Model that has your wrappers added, and you adjust positions according to your wrappers. This loses Ctrl+Click discoverability across files, but is fine in my case. (A game engine.) Inline error checks, documentation and completions are all working. I don't have a ready-made example for TypeScript yet, but I do have a working implementation of Civet language in Monaco, with custom wrappers for function descriptor and additional local variables. A seeking mind will be able to simplify it back to be just TypeScript but with wrappers. Civet compiles to TypeScript so I additionally use sourcemaps to go from TypeScript back to user's Civet code. HoverProvider, diagnostics conversion, and completions converter: https://github.com/ct-js/ct-js/blob/16e926544192ce334953e1fdbefe119a7f6ab194/src/node_requires/civetLanguageFeatures.ts I then use this to init the language features: const coffeescriptTokenizer = require('src/node_requires/coffeescriptTokenizer.js').language;
const {CivetHoverProvider, completionsProvider, provideMarkers} = require('src/node_requires/civetLanguageFeatures.ts/');
const ts = monaco.languages.typescript;
monaco.languages.register({
id: 'civet'
});
// Workaround for an ancient bug that ignores custom providers
monaco.editor.create(document.createElement('textarea'), {
language: 'civet',
value: ':)'
});
setTimeout(() => {
monaco.languages.setMonarchTokensProvider('civet', coffeescriptTokenizer);
monaco.languages.registerCompletionItemProvider('civet', completionsProvider);
ts.getTypeScriptWorker()
.then(client => {
monaco.languages.registerHoverProvider('civet', new CivetHoverProvider(client));
});
}, 1000); And on your custom languages' editors, call |
Hi,
we use the monaco editor for a project and we need to hide some parts of the code from the user, because there is a Header and a Footer generated, and only a part between which should be editable by the user. We need the whole file in the background, to have a running code completion.
The user should only be able to edit the code between the two comments.
Is it possible to hide the other parts from the user, or disable them in any way?
Thanks,
Achim
The text was updated successfully, but these errors were encountered: