-
Notifications
You must be signed in to change notification settings - Fork 9
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
Multiple editors in a page throws error #11
Comments
Hello @maheshstms |
Using Promise to check when first editor is loaded to avoid collision when using multiple editors on same page closes #11
The functionality did not work, only one editor is shown. The console error is now gone. <md-tab label="app code">
<td-code-editor style="height: 200px" theme="vs" flex language="javascript" [(ngModel)]='frontEndJSCode' id="js"></td-code-editor>
</md-tab>
<md-tab label="HTML">
<td-code-editor style="height: 200px" theme="vs" flex language="HTML" [(ngModel)]='frontEndHTMLCode' id="html"></td-code-editor>
</md-tab>
<md-tab label="CSS">
<td-code-editor style="height: 200px" theme="vs" flex language="css" [(ngModel)]='frontEndCSSCode' id="css"></td-code-editor>
</md-tab> |
Exposing automaticLayout method that via setInterval that constantly probes for the container's size. Also a layout() method that manually instructs the editor to remeasure its container closes #11
@maheshstms So what I added to covalent-code-editor is the automaticLayout input that is in the monaco editor. When you set this it will on an interval check the container of the editor and resize it accordingly. I also added a layout() method that you can call directly (maybe on an event or something) and it will cause the editor to resize itself. Changes are located here: PR: #13 I tested these two use cases with the following and it works: <md-tab-group>
<md-tab label="app code">
<td-code-editor automaticLayout="true" style="height: 200px" theme="vs" flex language="javascript" [(ngModel)]='frontEndJSCode' id="js"></td-code-editor>
</md-tab>
<md-tab label="HTML">
<td-code-editor automaticLayout="true" style="height: 200px" theme="vs" flex language="HTML" [(ngModel)]='frontEndHTMLCode' id="html"></td-code-editor>
</md-tab>
<md-tab label="CSS">
<td-code-editor #editor style="height: 200px" theme="vs" flex language="css" [(ngModel)]='frontEndCSSCode' id="css"></td-code-editor>
</md-tab>
</md-tab-group>
<button md-raised-button color="accent" (click)="editor.layout()" class="text-upper">SetLayout</button> |
Thanks for taking it Jeremy. |
@maheshstms you should be able to try this out now |
@maheshstms I am not seeing this issue. Maybe you can give me some more info, like code snippets, what browser you are using, etc. I am doing this in Chrome and see no problem. I noticed you are using the Covalent Quickstart so I tried it in there as well. Here is what I did: package.json
.angular-cli.json
app.module.ts
dashboard.component.ts
dashboard.component.html
|
Thanks Jermy, I am using Chome version 59.0.3071.115. Still have problem :( Have shared the code with you by mail. Please help. Thanks |
I see you are missing the automaticLayout attribute
You need to add that or use the layout method whenever you want to manually update the editor size:
|
Sorry Jeremy I missed it. It works fine now |
👍 |
@maheshstms what was the issue / solution? I am having this same problem with @monaco-editor/react and can't find anything about it. I have 2 monaco editors in separate components (one in my react app and one in an NPM package I wrote and linked) and only one of them loads at a time. I tried the layout options mentioned above but nothing works. Any help would be greatly appreciated. |
Hi,
When I try loading multiple editors in a tab view, the second editor throws error.
error
How to solve this problem, please help
The text was updated successfully, but these errors were encountered: