-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,25 +29,25 @@ | |
|
||
declare function CodeMirror (el: Element, config: any): void; | ||
|
||
function loadScript(url: string): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const script = document.createElement('script'); | ||
script.src = url; | ||
script.onload = () => resolve(); | ||
script.onerror = () => reject(new Error(`Script load error for ${url}`)); | ||
document.head.appendChild(script); | ||
}); | ||
function loadScript (url: string): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const script = document.createElement('script'); | ||
script.src = url; | ||
script.onload = () => resolve(); | ||
script.onerror = () => reject(new Error(`Script load error for ${url}`)); | ||
document.head.appendChild(script); | ||
}); | ||
} | ||
|
||
function loadCss(url: string): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const link = document.createElement('link'); | ||
link.href = url; | ||
link.rel = 'stylesheet'; | ||
link.onload = () => resolve(); | ||
link.onerror = () => reject(new Error(`CSS load error for ${url}`)); | ||
document.head.appendChild(link); | ||
}); | ||
function loadCss (url: string): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
const link = document.createElement('link'); | ||
link.href = url; | ||
link.rel = 'stylesheet'; | ||
link.onload = () => resolve(); | ||
link.onerror = () => reject(new Error(`CSS load error for ${url}`)); | ||
document.head.appendChild(link); | ||
}); | ||
} | ||
|
||
export class SpinePlayerEditor { | ||
|
@@ -82,7 +82,7 @@ body { margin: 0px; } | |
this.load(); | ||
} | ||
|
||
private async load() { | ||
private async load () { | ||
await Promise.all([loadScript("https://www.unpkg.com/[email protected]/lib/codemirror.js"), loadCss("https://www.unpkg.com/[email protected]/lib/codemirror.css")]); | ||
this.render(this.parent); | ||
} | ||
|