feat: Added localization to editor-codeblock
This commit is contained in:
parent
31c3cbe265
commit
2aaebb3ce0
@ -7,11 +7,14 @@
|
|||||||
transition(name='modal-content')
|
transition(name='modal-content')
|
||||||
.modal-content.is-expanded(v-show='isShown')
|
.modal-content.is-expanded(v-show='isShown')
|
||||||
header.is-green
|
header.is-green
|
||||||
span Insert Code Block
|
span {{ $t('editor.codeblocktitle') }}
|
||||||
|
p.modal-notify(v-bind:class='{ "is-active": isLoading }')
|
||||||
|
span {{ $t('editor.codeblockloading', { name: modeSelected }) }}
|
||||||
|
i
|
||||||
section.is-gapless
|
section.is-gapless
|
||||||
.columns.is-stretched
|
.columns.is-stretched
|
||||||
.column.is-one-quarter.modal-sidebar.is-green(style={'max-width':'350px'})
|
.column.is-one-quarter.modal-sidebar.is-green(style={'max-width':'350px'})
|
||||||
.model-sidebar-header Language
|
.model-sidebar-header {{ $t('editor.codeblocklanguage') }}
|
||||||
.model-sidebar-content
|
.model-sidebar-content
|
||||||
p.control.is-fullwidth
|
p.control.is-fullwidth
|
||||||
select(v-model='modeSelected')
|
select(v-model='modeSelected')
|
||||||
@ -19,8 +22,8 @@
|
|||||||
.column.ace-container
|
.column.ace-container
|
||||||
#codeblock-editor
|
#codeblock-editor
|
||||||
footer
|
footer
|
||||||
a.button.is-grey.is-outlined(v-on:click='cancel') Discard
|
a.button.is-grey.is-outlined(v-on:click='cancel') {{ $t('editor.discard') }}
|
||||||
a.button.is-green(v-on:click='insertCode') Insert Code Block
|
a.button.is-green(v-on:click='insertCode') {{ $t('editor.codeblockinsert') }}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -33,7 +36,8 @@
|
|||||||
return {
|
return {
|
||||||
modes: [],
|
modes: [],
|
||||||
modeSelected: 'text',
|
modeSelected: 'text',
|
||||||
modelistLoaded: []
|
modelistLoaded: [],
|
||||||
|
isLoading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -72,13 +76,27 @@
|
|||||||
if (self._.includes(self.modelistLoaded, m)) {
|
if (self._.includes(self.modelistLoaded, m)) {
|
||||||
codeEditor.getSession().setMode('ace/mode/' + m)
|
codeEditor.getSession().setMode('ace/mode/' + m)
|
||||||
} else {
|
} else {
|
||||||
|
self.isLoading = true
|
||||||
self.$http.get('/js/ace/mode-' + m + '.js').then(resp => {
|
self.$http.get('/js/ace/mode-' + m + '.js').then(resp => {
|
||||||
if(resp.ok) {
|
if(resp.ok) {
|
||||||
eval(resp.bodyText)
|
eval(resp.bodyText)
|
||||||
self.modelistLoaded.push(m)
|
self.modelistLoaded.push(m)
|
||||||
ace.acequire('ace/mode/' + m)
|
ace.acequire('ace/mode/' + m)
|
||||||
codeEditor.getSession().setMode('ace/mode/' + m)
|
codeEditor.getSession().setMode('ace/mode/' + m)
|
||||||
|
self._.delay(() => { self.isLoading = false }, 500)
|
||||||
|
} else {
|
||||||
|
this.$store.dispatch('alert', {
|
||||||
|
style: 'red',
|
||||||
|
icon: 'square-cross',
|
||||||
|
msg: 'Error: Unable to load language syntax.'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
his.$store.dispatch('alert', {
|
||||||
|
style: 'red',
|
||||||
|
icon: 'square-cross',
|
||||||
|
msg: 'Error: ' + err.body.msg
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"editor": {
|
||||||
|
"discard": "Discard",
|
||||||
|
"codeblocktitle": "Insert Code Block",
|
||||||
|
"codeblockinsert": "Insert Code Block",
|
||||||
|
"codeblocklanguage": "Language",
|
||||||
|
"codeblockloading": "Loading code syntax for {{name}}"
|
||||||
|
},
|
||||||
"nav": {
|
"nav": {
|
||||||
"home": "Home"
|
"home": "Home"
|
||||||
},
|
},
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
.modal#modal-editor-codeblock
|
|
||||||
.modal-background
|
|
||||||
.modal-container
|
|
||||||
.modal-content.is-expanded
|
|
||||||
|
|
||||||
header.is-green
|
|
||||||
span Insert Code Block
|
|
||||||
|
|
||||||
section.is-gapless
|
|
||||||
.columns.is-stretched
|
|
||||||
.column.is-one-quarter.modal-sidebar.is-green(style={'max-width':'350px'})
|
|
||||||
.model-sidebar-header Language
|
|
||||||
.model-sidebar-content
|
|
||||||
p.control.is-fullwidth
|
|
||||||
select(v-model='modeSelected')
|
|
||||||
option(v-for='mode in modes', v-bind:value='mode.name') {{ mode.caption }}
|
|
||||||
.column.ace-container
|
|
||||||
#codeblock-editor
|
|
||||||
|
|
||||||
footer
|
|
||||||
a.button.is-grey.is-outlined(v-on:click='cancel') Discard
|
|
||||||
a.button.is-green(v-on:click='insertCode') Insert Code Block
|
|
@ -18,7 +18,7 @@ block rootNavRight
|
|||||||
a.button.is-outlined(href='/source/' + pageData.meta.path)
|
a.button.is-outlined(href='/source/' + pageData.meta.path)
|
||||||
i.icon-loader
|
i.icon-loader
|
||||||
span= t('nav.source')
|
span= t('nav.source')
|
||||||
a.button.is-outlined(href='/hist/' + pageData.meta.path)
|
//- a.button.is-outlined(href='/hist/' + pageData.meta.path)
|
||||||
i.icon-clock
|
i.icon-clock
|
||||||
span= t('nav.history')
|
span= t('nav.history')
|
||||||
if rights.write
|
if rights.write
|
||||||
|
Loading…
Reference in New Issue
Block a user