mirror of
https://github.com/wassname/nvatom.git
synced 2026-08-12 12:10:23 +08:00
Apply the interlink extended grammar only on valid notes
To do so, we need to activate the package on Atom startup.
This commit is contained in:
@@ -7,6 +7,9 @@ class Interlink
|
||||
constructor: ->
|
||||
@subscriptions = new CompositeDisposable
|
||||
@subscriptions.add atom.commands.add 'atom-workspace', 'nvatom:openInterlink': => Interlink.openInterlink()
|
||||
@subscriptions.add atom.workspace.observeTextEditors (editor) ->
|
||||
if Utility.isNote(editor.getPath())
|
||||
editor.setGrammar(atom.grammars.grammarForScopeName('source.gfm.nvatom'))
|
||||
|
||||
destroy: ->
|
||||
@subscriptions.dispose()
|
||||
|
||||
@@ -24,16 +24,12 @@ module.exports =
|
||||
type: 'boolean'
|
||||
default: true
|
||||
|
||||
notationalVelocityView: null
|
||||
|
||||
activate: (state) ->
|
||||
@rootDirectory = @ensureNoteDirectory()
|
||||
|
||||
# Events subscribed to in atom's system can be easily cleaned up with a
|
||||
# CompositeDisposable
|
||||
@subscriptions = new CompositeDisposable
|
||||
|
||||
# Register command that toggles this view
|
||||
@subscriptions.add atom.commands.add 'atom-workspace',
|
||||
'nvatom:toggle': => @createView(state).toggle()
|
||||
|
||||
@@ -55,11 +51,11 @@ module.exports =
|
||||
|
||||
deactivate: ->
|
||||
@subscriptions.dispose()
|
||||
@interlnk.destroy()
|
||||
@notationalVelocityView.destroy()
|
||||
@interlnk?.destroy()
|
||||
@notationalVelocityView?.destroy()
|
||||
|
||||
serialize: ->
|
||||
notationalVelocityViewState: @notationalVelocityView.serialize()
|
||||
notationalVelocityViewState: @notationalVelocityView?.serialize()
|
||||
|
||||
createView: (state, docQuery) ->
|
||||
unless @notationalVelocityView?
|
||||
|
||||
Reference in New Issue
Block a user