Tokens expand when holding CTRL and double clicking (Yay!)
This commit is contained in:
parent
357475c992
commit
8c07bfea15
|
|
@ -439,7 +439,8 @@
|
|||
function addTokenExpanderToEditor(pane, $form) {
|
||||
var group = $('[data-field-name=markup]', pane),
|
||||
editor = $('[data-control=codeeditor]', group),
|
||||
toolbar = editor.codeEditor('getToolbar')
|
||||
toolbar = editor.codeEditor('getToolbar'),
|
||||
canExpand = false
|
||||
|
||||
if (editor.data('oc.tokenexpander'))
|
||||
return
|
||||
|
|
@ -453,19 +454,34 @@
|
|||
)
|
||||
|
||||
breakButton.hide().on('click', function(){
|
||||
editor.tokenExpander('expandToken', function(token, value){
|
||||
return $form.request('onExpandMarkupToken', {
|
||||
data: { tokenType: token, tokenName: value }
|
||||
})
|
||||
})
|
||||
handleExpandToken(editor, $form)
|
||||
return false
|
||||
})
|
||||
|
||||
$('ul:first', toolbar).prepend(breakButton)
|
||||
|
||||
editor
|
||||
.on('show.oc.tokenexpander', function(){ breakButton.show() })
|
||||
.on('hide.oc.tokenexpander', function(){ breakButton.hide() })
|
||||
.on('show.oc.tokenexpander', function(){
|
||||
canExpand = true
|
||||
breakButton.show()
|
||||
})
|
||||
.on('hide.oc.tokenexpander', function(){
|
||||
canExpand = false
|
||||
breakButton.hide()
|
||||
})
|
||||
.on('dblclick', function(e){
|
||||
if ((e.metaKey || e.ctrlKey) && canExpand) {
|
||||
handleExpandToken(editor, $form)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleExpandToken(editor, $form) {
|
||||
editor.tokenExpander('expandToken', function(token, value){
|
||||
return $form.request('onExpandMarkupToken', {
|
||||
data: { tokenType: token, tokenName: value }
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function handleMtimeMismatch(form) {
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ class Index extends Controller
|
|||
if (!$alias = post('tokenName'))
|
||||
throw new ApplicationException(trans('cms::lang.component.no_records'));
|
||||
|
||||
// Can only break apart components at this stage
|
||||
// Can only expand components at this stage
|
||||
if ((!$type = post('tokenType')) && $type != 'component')
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue