mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-17 09:28:54 +00:00
Add a skeleton of a custom insertMatch function
This commit is contained in:
parent
b73b78e570
commit
7ecadb14f6
1 changed files with 20 additions and 0 deletions
|
@ -5,6 +5,7 @@ define [
|
|||
"ace/ext-language_tools"
|
||||
], (SuggestionManager, SnippetManager) ->
|
||||
Range = ace.require("ace/range").Range
|
||||
aceSnippetManager = ace.require('ace/snippets').snippetManager
|
||||
|
||||
getLastCommandFragment = (lineUpToCursor) ->
|
||||
if m = lineUpToCursor.match(/(\\[^\\]+)$/)
|
||||
|
@ -154,6 +155,25 @@ define [
|
|||
if this.completions.filterText.match(/^\\begin\{/) and nextChar == "}"
|
||||
editor.session.remove(range)
|
||||
|
||||
if !data?
|
||||
completions = this.completions
|
||||
popup = editor.completer.popup
|
||||
data = popup.getData(popup.getRow())
|
||||
data.completer =
|
||||
insertMatch: (editor, matchData) ->
|
||||
console.log ">> custom insertMatch"
|
||||
console.log ">> data", data
|
||||
ranges = editor.selection.getAllRanges()
|
||||
for range in ranges
|
||||
range.start.column -= completions.filterText.length;
|
||||
editor.session.remove(range);
|
||||
if matchData.snippet
|
||||
console.log ">> snippet"
|
||||
aceSnippetManager.insertSnippet(editor, matchData.snippet);
|
||||
else
|
||||
console.log ">> string", matchData
|
||||
editor.execCommand("insertstring", matchData.value || matchData);
|
||||
|
||||
Autocomplete::_insertMatch.call this, data
|
||||
|
||||
# Overwrite this to set autoInsert = false and set font size
|
||||
|
|
Loading…
Add table
Reference in a new issue