fix: mscoreWindow
This commit is contained in:
parent
3b43957cee
commit
297387b2b4
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
import { ScoreInfo } from './scoreinfo'
|
||||||
import { loadMscore, WebMscore } from './mscore'
|
import { loadMscore, WebMscore } from './mscore'
|
||||||
import { useTimeout, windowOpen, console, _Element } from './utils'
|
import { useTimeout, windowOpen, console, _Element } from './utils'
|
||||||
import i18n from './i18n'
|
import i18n from './i18n'
|
||||||
|
@ -192,7 +193,7 @@ export namespace BtnAction {
|
||||||
}, fallback, timeout)
|
}, fallback, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mscoreWindow = (fn: (w: Window, score: WebMscore, processingTextEl: ChildNode) => any): BtnAction => {
|
export const mscoreWindow = (scoreinfo: ScoreInfo, fn: (w: Window, score: WebMscore, processingTextEl: ChildNode) => any): BtnAction => {
|
||||||
return async (btnName, btn, setText) => {
|
return async (btnName, btn, setText) => {
|
||||||
const _onclick = btn.onclick
|
const _onclick = btn.onclick
|
||||||
btn.onclick = null
|
btn.onclick = null
|
||||||
|
@ -217,7 +218,7 @@ export namespace BtnAction {
|
||||||
btn.onclick = _onclick
|
btn.onclick = _onclick
|
||||||
})
|
})
|
||||||
|
|
||||||
score = await loadMscore(w)
|
score = await loadMscore(scoreinfo, w)
|
||||||
|
|
||||||
fn(w, score, txt)
|
fn(w, score, txt)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ const main = (): void => {
|
||||||
|
|
||||||
btnList.add({
|
btnList.add({
|
||||||
name: i18n('DOWNLOAD')('MusicXML'),
|
name: i18n('DOWNLOAD')('MusicXML'),
|
||||||
action: BtnAction.mscoreWindow(async (w, score) => {
|
action: BtnAction.mscoreWindow(scoreinfo, async (w, score) => {
|
||||||
const mxl = await score.saveMxl()
|
const mxl = await score.saveMxl()
|
||||||
const data = new Blob([mxl])
|
const data = new Blob([mxl])
|
||||||
saveAs(data, `${fileName}.mxl`)
|
saveAs(data, `${fileName}.mxl`)
|
||||||
|
@ -53,7 +53,7 @@ const main = (): void => {
|
||||||
indvPartBtn = btnList.add({
|
indvPartBtn = btnList.add({
|
||||||
name: i18n('IND_PARTS')(),
|
name: i18n('IND_PARTS')(),
|
||||||
tooltip: i18n('IND_PARTS_TOOLTIP')(),
|
tooltip: i18n('IND_PARTS_TOOLTIP')(),
|
||||||
action: BtnAction.mscoreWindow(async (w, score, txt) => {
|
action: BtnAction.mscoreWindow(scoreinfo, async (w, score, txt) => {
|
||||||
const metadata = await score.metadata()
|
const metadata = await score.metadata()
|
||||||
console.log('score metadata loaded by webmscore', metadata)
|
console.log('score metadata loaded by webmscore', metadata)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue