mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
added support for inserting snippets by shift+click
This commit is contained in:
parent
86eea93e2f
commit
50517431db
2 changed files with 11 additions and 0 deletions
|
@ -71,6 +71,9 @@ module.exports = class SpellPaletteEntryView extends CocoView
|
|||
Backbone.Mediator.publish 'tome:palette-pin-toggled', entry: @, pinned: @popoverPinned
|
||||
|
||||
onClick: (e) =>
|
||||
if key.shift
|
||||
Backbone.Mediator.publish 'tome:insert-snippet', doc: @options.doc, language: @options.language
|
||||
return
|
||||
@togglePinned()
|
||||
Backbone.Mediator.publish 'tome:palette-clicked', thang: @thang, prop: @doc.name, entry: @
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ module.exports = class SpellView extends CocoView
|
|||
'tome:change-language': 'onChangeLanguage'
|
||||
'tome:change-config': 'onChangeEditorConfig'
|
||||
'tome:update-snippets': 'addZatannaSnippets'
|
||||
'tome:insert-snippet': 'onInsertSnippet'
|
||||
'spell-beautify': 'onSpellBeautify'
|
||||
|
||||
events:
|
||||
|
@ -661,6 +662,13 @@ module.exports = class SpellView extends CocoView
|
|||
@spell.setLanguage e.language
|
||||
@reloadCode true if wasDefault
|
||||
|
||||
onInsertSnippet: (e) ->
|
||||
console.log 'doc', e.doc
|
||||
return unless e.doc.snippets?[e.language]?.code
|
||||
snippetManager = ace.require('ace/snippets').snippetManager
|
||||
snippetManager.insertSnippet @ace, e.doc.snippets[e.language].code
|
||||
return
|
||||
|
||||
dismiss: ->
|
||||
@spell.hasChangedSignificantly @getSource(), null, (hasChanged) =>
|
||||
@recompile() if hasChanged
|
||||
|
|
Loading…
Reference in a new issue