mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 22:36:14 +08:00
Improve persisting of last clicked demo tab
This commit is contained in:
parent
3c1f04bfe7
commit
fc5757a857
@ -120,12 +120,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
currentTab(newCurrentTab) {
|
||||
localStorage.tab = newCurrentTab
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
showTabs() {
|
||||
return this.sortedTabs.length > 1
|
||||
@ -173,10 +167,14 @@ export default {
|
||||
return name.split('.').pop()
|
||||
},
|
||||
|
||||
setTab(name) {
|
||||
setTab(name, persist = true) {
|
||||
this.currentTab = name
|
||||
this.sources = {}
|
||||
this.currentFile = null
|
||||
|
||||
if (persist) {
|
||||
localStorage.tab = name
|
||||
}
|
||||
},
|
||||
|
||||
setFile(name) {
|
||||
@ -232,8 +230,8 @@ export default {
|
||||
|
||||
mounted() {
|
||||
// TODO: load language from url params
|
||||
const intitialTab = localStorage.tab && this.sources[localStorage.tab] ? localStorage.tab : this.sortedTabs[0]?.name
|
||||
this.setTab(intitialTab)
|
||||
const intitialTab = localStorage.tab && this.tabs.some(tab => tab.name === localStorage.tab) ? localStorage.tab : this.sortedTabs[0]?.name
|
||||
this.setTab(intitialTab, false)
|
||||
|
||||
window.document.addEventListener('editor', this.onEditor, false)
|
||||
window.document.addEventListener('source', this.onSource, false)
|
||||
|
Loading…
Reference in New Issue
Block a user