Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]Change/suggest #48

Closed
wants to merge 9 commits into from
64 changes: 30 additions & 34 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,31 @@ const supportExtraTags = [
}
}
]

const supportIcons = [
{
text: 'icon:comment[]',
search: 'icon'
},
{
text: 'icon:file[]',
search: 'icon'
},
{
text: 'icon:fire[]',
search: 'icon'
},
{
text: 'icon:tags[]',
search: 'icon'
},
{
text: 'icon:heart[]',
search: 'icon'
}

]

const statusType = {
connected: {
msg: 'CONNECTED',
Expand Down Expand Up @@ -3164,38 +3189,6 @@ function matchInContainer (text) {

$(editor.getInputField())
.textcomplete([
{ // emoji strategy
match: /(^|\n|\s)\B:([-+\w]*)$/,
search: function (term, callback) {
var line = editor.getLine(editor.getCursor().line)
term = line.match(this.match)[2]
var list = []
$.map(window.emojify.emojiNames, function (emoji) {
if (emoji.indexOf(term) === 0) { // match at first character
list.push(emoji)
}
})
$.map(window.emojify.emojiNames, function (emoji) {
if (emoji.indexOf(term) !== -1) { // match inside the word
list.push(emoji)
}
})
callback(list)
},
template: function (value) {
return '<img class="emoji" src="' + serverurl + '/build/emojify.js/dist/images/basic/' + value + '.png"></img> ' + value
},
replace: function (value) {
return '$1:' + value + ': '
},
index: 1,
context: function (text) {
checkInCode()
checkInContainer()
checkInContainerSyntax()
return !isInCode && !isInContainerSyntax
}
},
{ // Code block language strategy
langs: supportCodeModes,
charts: supportCharts,
Expand Down Expand Up @@ -3334,11 +3327,14 @@ $(editor.getInputField())
return !isInCode
}
},
{ // externals
match: /(^|\n|\s)\{\}(\w*)$/,
{ // externals and icons
match: /(^|\n|\s)(\w+)$/,
search: function (term, callback) {
callback($.map(supportExternals, function (external) {
return external.search.indexOf(term) === 0 ? external.text : null
})),
callback($.map(supportIcons, function (icons){
return icons.search.indexOf(term) === 0 ? icons.text : null
}))
},
replace: function (value) {
Expand Down