ekkolon / ngx-gist Goto Github PK
View Code? Open in Web Editor NEWEmbedding GitHub Gists in Angular apps made easy
License: MIT License
Embedding GitHub Gists in Angular apps made easy
License: MIT License
There is no need to sanitize the initially created and empty element.
Library consumers should have the ability to configure the gist component, such that it can be eagerly or lazy loaded. This would improve page loading performance, especially in cases where more than one gist component is present in the HTML.
Library consumers should be able to select and/or switch between different themes - in particular, a light and a dark theme.
Describe the bug
When trying to render a gist containing multiple files in seperate ngx-gist
components,
the iframes are just partially rendered.
For example:
// example-page.component.ts
@Component({
templateUrl: './example-page.component.html'
})
export class ExamplePage {
gistId = "05151ac90b51a5d3a0c3e85cb942a456"
}
// example-page.component.html
<div class="ngx-gist-embed-single-file">
<ngx-gist [gistId]="gistId" file="ngx_gist_embed_example_2.py"></ngx-gist>
</div>
<div class="ngx-gist-embed-all-files">
<ngx-gist [gistId]="gistId"></ngx-gist>
</div>
Expected behavior
Expected both iframes to render the whole content while automatically adjusting the iframe's height.
Screenshots
Traceback
This layout error may be caused by using the same iframe id for both ngx-gist
components
when the component computes property bindings:
ngx-gist/projects/ngx-gist/src/lib/ngx-gist.component.ts
Lines 55 to 61 in a0b7133
Since each fragment of a gist varies in size/height, iframe-resizer
cannot calculate each individual component's height properly. This is because each iframe's height is calculated per id, resulting in stopping calculating other iframes with the same id.
Possible solution
To get around this issue, we need to append the filename (if provided) to the generated iframeId.
For example:
...
/**
* The file to display. If not specified, the first file in the gist will be displayed.
*/
@Input() file?: string;
/**
* The id of the gist to display.
*/
@Input() set gistId(id: string) {
this._gistId = id;
const fileId = this.file ? `-file=${this.file}` : ''`
this._iframeId = `gist-${id}${fileId}`;
}
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.