|
|
|
|
@ -1,14 +1,11 @@
|
|
|
|
|
export class FileGroup extends HTMLElement {
|
|
|
|
|
textEn = {
|
|
|
|
|
addFile: 'Add File',
|
|
|
|
|
}
|
|
|
|
|
textEn = {}
|
|
|
|
|
|
|
|
|
|
textEs = {
|
|
|
|
|
addFile: 'Añadir archivo',
|
|
|
|
|
}
|
|
|
|
|
textEs = {}
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super()
|
|
|
|
|
this.fileCount = {value: 0}
|
|
|
|
|
this.language = navigator.language
|
|
|
|
|
this.attachShadow({mode: 'open'})
|
|
|
|
|
this.headerEl = document.createElement('div')
|
|
|
|
|
@ -20,15 +17,6 @@ export class FileGroup extends HTMLElement {
|
|
|
|
|
const bGroup = document.createElement(
|
|
|
|
|
'm-forms-button-group'
|
|
|
|
|
)
|
|
|
|
|
bGroup.addPrimary(this.text.addFile, () => {
|
|
|
|
|
this.addFile()
|
|
|
|
|
const btn = bGroup.primary
|
|
|
|
|
if (btn.scrollIntoViewIfNeeded) {
|
|
|
|
|
btn.scrollIntoViewIfNeeded()
|
|
|
|
|
} else {
|
|
|
|
|
btn.scrollIntoView()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.shadowRoot.appendChild(bGroup)
|
|
|
|
|
this.contentEl.addEventListener(
|
|
|
|
|
'click-add-above',
|
|
|
|
|
@ -36,10 +24,12 @@ export class FileGroup extends HTMLElement {
|
|
|
|
|
const el = document.createElement(
|
|
|
|
|
'm-editor-file-view'
|
|
|
|
|
)
|
|
|
|
|
el.fileCount = this.fileCount
|
|
|
|
|
el.codeMirror = this.codeMirror
|
|
|
|
|
e.target.insertAdjacentElement(
|
|
|
|
|
'beforebegin', el
|
|
|
|
|
)
|
|
|
|
|
this.fileCount.value += 1
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
this.contentEl.addEventListener(
|
|
|
|
|
@ -48,10 +38,12 @@ export class FileGroup extends HTMLElement {
|
|
|
|
|
const el = document.createElement(
|
|
|
|
|
'm-editor-file-view'
|
|
|
|
|
)
|
|
|
|
|
el.fileCount = this.fileCount
|
|
|
|
|
el.codeMirror = this.codeMirror
|
|
|
|
|
e.target.insertAdjacentElement(
|
|
|
|
|
'afterend', el
|
|
|
|
|
)
|
|
|
|
|
this.fileCount.value += 1
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
@ -83,6 +75,7 @@ export class FileGroup extends HTMLElement {
|
|
|
|
|
|
|
|
|
|
addFile({name, data, collapsed} = {}) {
|
|
|
|
|
const el = document.createElement('m-editor-file-view')
|
|
|
|
|
el.fileCount = this.fileCount
|
|
|
|
|
el.codeMirror = this.codeMirror
|
|
|
|
|
if (name !== undefined) {
|
|
|
|
|
el.name = name
|
|
|
|
|
@ -94,6 +87,7 @@ export class FileGroup extends HTMLElement {
|
|
|
|
|
el.collapsed = collapsed
|
|
|
|
|
}
|
|
|
|
|
this.contentEl.appendChild(el)
|
|
|
|
|
this.fileCount.value += 1
|
|
|
|
|
return el
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|