diff --git a/public/javascripts/application.js b/public/javascripts/application.js index a61b0c5cb..e9f806e33 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1023,7 +1023,7 @@ $(function () { }); }); -function inlineAutoComplete(element) { +function inlineAutoCompleteIssueId(element) { 'use strict'; // do not attach if Tribute is already initialized if (element.dataset.tribute === 'true') {return;} @@ -1072,6 +1072,29 @@ function inlineAutoComplete(element) { tribute.attach(element); } +function inlineAutoCompleteWikiSyntax(element) { + const tribute = new Tribute({ + trigger: '{{', + values: [ + {name: 'collapse', value: '{{collapse\nThis is a block of text that is collapsed by default.\n}}'}, + {name: 'child_pages', value: '{{child_pages}}'}, + {name: 'include', value: '{{include(WikiPageName)}}'}, + {name: 'thumbnail', value: '{{thumbnail(image.png, size=300, title=Thumbnail)}}'}, + {name: 'issue', value: '{{issue(123, subject=true, project=true)}}'} + ], + lookup: 'name', + fillAttr: 'value', + requireLeadingSpace: true, + selectTemplate: function(item) { + return item.original.value; + }, + noMatchTemplate: function () { + return ''; + } + }); + tribute.attach(element); +} + $(document).ready(setupAjaxIndicator); $(document).ready(hideOnLoad); @@ -1081,5 +1104,8 @@ $(document).ready(setupAttachmentDetail); $(document).ready(setupTabs); $(document).ready(setupFilePreviewNavigation); $(document).on('focus', '[data-auto-complete=true]', function(event) { - inlineAutoComplete(event.target); + inlineAutoCompleteIssueId(event.target); +}); +$(document).on('focus', '.jstEditor [data-auto-complete=true]', function(event) { + inlineAutoCompleteWikiSyntax(event.target); });