Comments (11)
@hanspagel I check #1340 issue but still I am getting problem.
I already add screenshot.
from scalar.
Alright I tested it and you are correct, even with the new events we still can't get it working in angular due to attaching the references to the body instead of the dom element inside the view. I think we should just make an angular integration at some point. I will open a ticket
from scalar.
Great you‘ve found a workaround! 🙌 As a general solution for our published version I’d still take the approach mentioned above:
from scalar.
Thanks for bringing this up!
Related issue: #1340
from scalar.
Sure! Just wanted to cross link both issues.
We’re using vite-plugin-css-injected-by-js
to inject the styles. I think we could use styleId
and a custom injectCode
function to make sure the style tag is only added once:
from scalar.
@hanspagel @jatingajera31 there is a fix possible for this now with the new events. Just place the script tag outside of the page so it only gets loaded once, then you can trigger the custom event when you navigate to the page to reload the references
document.dispatchEvent(new Event('scalar:reload-references'))
but yes we should also only load the js and styles once
from scalar.
@jatingajera31 if you want to put up a minimal reproduction or just your code in general I can try and help
from scalar.
@amritk here is the code
angular component file
`import { AfterViewInit, Component, OnDestroy, OnInit, Renderer2 } from '@angular/core';
@component({
selector: 'app-api-list',
standalone: true,
imports: [],
templateUrl: './api-list.component.html',
styleUrls: ['./api-list.component.scss'],
})
export class ApiListComponent implements OnInit, AfterViewInit, OnDestroy {
constructor() { }
ngOnInit(): void {
this.loadScript('https://cdn.jsdelivr.net/npm/@scalar/api-reference').then((res: any) => {
console.log('res:', res);
}).catch(error => {
console.error('Error loading script:', error);
});
}
ngOnDestroy(): void {
}
ngAfterViewInit(): void {
}
private loadScript(url: string): Promise {
return new Promise((resolve, reject) => {
const scriptElement = document.createElement('script');
scriptElement.src = url;
scriptElement.onload = () => resolve();
scriptElement.onerror = (error) => reject(error);
document.body.appendChild(scriptElement);
});
}
}`
html code file
<div id="api-reference" data-url="https://petstore3.swagger.io/api/v3/openapi.json" data-proxy-url="https://api.scalar.com/request-proxy"></div>
from scalar.
You can track the work here
from scalar.
@amritk Thank you for ticket.
I have fix that issue by removing (text/css) appending node from cdn link. I use this ( n.parentNode.removeChild(n))
Is this okay?
from scalar.
not sure, @hanspagel what do yo think
from scalar.
Related Issues (20)
- Store authorization data in local storage (optional)
- Array enum with exactly 1 enum does not render as a enum
- Docusaurus: don't add routes automatically to the navbar HOT 1
- generate examples for nested objects
- improve search result quality HOT 1
- Use a callback to prefill authentication
- Wrong HTTP header for security schema HOT 1
- configure default client library
- Input text color for keplar theme dark mode HOT 1
- Side bar scroll when we scroll api documentation HOT 1
- Missing styling on markdown content HOT 6
- Wrong example response for array with items that use allOf HOT 9
- Nuxt: `css` is unknown file extension HOT 7
- Test request always uses default value even if another value is provided HOT 1
- In Hono Scalar pageTitle and JWT token are not set HOT 1
- docusaurus: doesn’t use full height HOT 2
- OpenAPI 3.1 webhooks are not displayed if x-tagGroups are used HOT 2
- Items in "More" dropdown aren't visible in dark mode
- Schema with anyOf section that contains two objects is rendered invalid
- Module not found: Missing "./entities/workspace/security" specifier in "@scalar/oas-utils" package HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scalar.