mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -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
|
Backbone.Mediator.publish 'tome:palette-pin-toggled', entry: @, pinned: @popoverPinned
|
||||||
|
|
||||||
onClick: (e) =>
|
onClick: (e) =>
|
||||||
|
if key.shift
|
||||||
|
Backbone.Mediator.publish 'tome:insert-snippet', doc: @options.doc, language: @options.language
|
||||||
|
return
|
||||||
@togglePinned()
|
@togglePinned()
|
||||||
Backbone.Mediator.publish 'tome:palette-clicked', thang: @thang, prop: @doc.name, entry: @
|
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-language': 'onChangeLanguage'
|
||||||
'tome:change-config': 'onChangeEditorConfig'
|
'tome:change-config': 'onChangeEditorConfig'
|
||||||
'tome:update-snippets': 'addZatannaSnippets'
|
'tome:update-snippets': 'addZatannaSnippets'
|
||||||
|
'tome:insert-snippet': 'onInsertSnippet'
|
||||||
'spell-beautify': 'onSpellBeautify'
|
'spell-beautify': 'onSpellBeautify'
|
||||||
|
|
||||||
events:
|
events:
|
||||||
|
@ -661,6 +662,13 @@ module.exports = class SpellView extends CocoView
|
||||||
@spell.setLanguage e.language
|
@spell.setLanguage e.language
|
||||||
@reloadCode true if wasDefault
|
@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: ->
|
dismiss: ->
|
||||||
@spell.hasChangedSignificantly @getSource(), null, (hasChanged) =>
|
@spell.hasChangedSignificantly @getSource(), null, (hasChanged) =>
|
||||||
@recompile() if hasChanged
|
@recompile() if hasChanged
|
||||||
|
|
Loading…
Reference in a new issue