mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-07 00:05:55 +02:00
(refs #1241) Filter CompletionProposalProvider by the completion context
This commit is contained in:
@@ -9,6 +9,7 @@ trait CompletionProposalProvider {
|
||||
val prefix: String
|
||||
val suffix: String = " "
|
||||
val values: Seq[String]
|
||||
val context: Seq[String]
|
||||
|
||||
def template(implicit context: Context): String = "value"
|
||||
def additionalScript(implicit context: Context): String = ""
|
||||
@@ -19,6 +20,7 @@ class EmojiCompletionProposalProvider extends CompletionProposalProvider {
|
||||
override val values: Seq[String] = EmojiUtil.emojis.toSeq
|
||||
override val prefix: String = ":"
|
||||
override val suffix: String = ": "
|
||||
override val context: Seq[String] = Seq("wiki", "issues")
|
||||
override def template(implicit context: Context): String =
|
||||
s"""'<img src=\"${context.path}/assets/common/images/emojis/' + value + '.png\" class=\"emoji\"></img>' + value"""
|
||||
}
|
||||
@@ -27,6 +29,7 @@ class UserCompletionProposalProvider extends CompletionProposalProvider {
|
||||
override val id: String = "user"
|
||||
override val values: Seq[String] = Nil
|
||||
override val prefix: String = "@"
|
||||
override val context: Seq[String] = Seq("issues")
|
||||
override def template(implicit context: Context): String = "'@' + value"
|
||||
override def additionalScript(implicit context: Context): String =
|
||||
s"""$$.get('${context.path}/_user/proposals', { query: '' }, function (data) { user = data.options; });"""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@(owner: String, repository: String, completion: Seq[String], generateScript: Boolean = true)(textarea: Html)(implicit context: gitbucket.core.controller.Context)
|
||||
@(owner: String, repository: String, completionContext: String, generateScript: Boolean = true)(textarea: Html)(implicit context: gitbucket.core.controller.Context)
|
||||
@import gitbucket.core.util.{FileUtil, EmojiUtil}
|
||||
@import gitbucket.core.view.helpers
|
||||
<div class="muted attachable">
|
||||
@@ -9,14 +9,14 @@
|
||||
<script>
|
||||
$(function(){
|
||||
@gitbucket.core.plugin.PluginRegistry().getCompletionProposalProviders.map { provider =>
|
||||
@if(completion.contains(provider.id)){ // TODO Filter by context
|
||||
@if(provider.context.contains(completionContext)){
|
||||
var @provider.id = @Html(helpers.json(provider.values));
|
||||
@Html(provider.additionalScript)
|
||||
}
|
||||
}
|
||||
$('#@textareaId').textcomplete([
|
||||
@gitbucket.core.plugin.PluginRegistry().getCompletionProposalProviders.map { provider =>
|
||||
@if(completion.contains(provider.id)){ // TODO Filter by context
|
||||
@if(provider.context.contains(completionContext)){
|
||||
{
|
||||
id: '@{provider.id}',
|
||||
match: /\B@{provider.prefix}([\-+\w]*)$/,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
enableLineBreaks: Boolean,
|
||||
enableTaskList: Boolean,
|
||||
hasWritePermission: Boolean,
|
||||
completion: Seq[String],
|
||||
completionContext: String,
|
||||
style: String = "",
|
||||
styleClass: String = "",
|
||||
placeholder: String = "Leave a comment",
|
||||
@@ -28,10 +28,10 @@
|
||||
@if(styleClass.nonEmpty){ class="@styleClass" }>@content</textarea>
|
||||
}
|
||||
@gitbucket.core.helper.html.attached(
|
||||
owner = repository.owner,
|
||||
repository = repository.name,
|
||||
completion = completion,
|
||||
generateScript = enableWikiLink
|
||||
owner = repository.owner,
|
||||
repository = repository.name,
|
||||
completionContext = completionContext,
|
||||
generateScript = enableWikiLink
|
||||
)(textarea)
|
||||
</div>
|
||||
<div class="tab-pane" id="tab@(uid+1)">
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
enableLineBreaks = true,
|
||||
enableTaskList = true,
|
||||
hasWritePermission = hasWritePermission,
|
||||
completion = Seq("emoji", "user"),
|
||||
completionContext = "issues",
|
||||
style = "",
|
||||
elastic = true,
|
||||
tabIndex = 1
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
enableLineBreaks = true,
|
||||
enableTaskList = true,
|
||||
hasWritePermission = hasWritePermission,
|
||||
completion = Seq("emoji", "user"),
|
||||
completionContext = "issues",
|
||||
style = "height: 200px; max-height: 250px;",
|
||||
elastic = true
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@(content: String, commentId: Int, owner: String, repository: String)(implicit context: gitbucket.core.controller.Context)
|
||||
<span id="error-edit-content-@commentId" class="error"></span>
|
||||
@gitbucket.core.helper.html.attached(owner, repository, completion = Seq("emoji", "user")){
|
||||
@gitbucket.core.helper.html.attached(owner, repository, "issues"){
|
||||
<textarea id="edit-content-@commentId" class="form-control">@content</textarea>
|
||||
}
|
||||
<div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@(content: Option[String], issueId: Int, owner: String, repository: String)(implicit context: gitbucket.core.controller.Context)
|
||||
@gitbucket.core.helper.html.attached(owner, repository, Seq("emoji", "user")){
|
||||
@gitbucket.core.helper.html.attached(owner, repository, "issues"){
|
||||
<textarea id="edit-content" class="form-control">@content.getOrElse("")</textarea>
|
||||
}
|
||||
<div>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
enableLineBreaks = true,
|
||||
enableTaskList = true,
|
||||
hasWritePermission = true,
|
||||
completion = Seq("emoji", "user"),
|
||||
completionContext = "issues",
|
||||
style = "height: 200px;"
|
||||
)
|
||||
<input type="hidden" name="targetUserName" value="@originRepository.owner"/>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
enableLineBreaks = true,
|
||||
enableTaskList = true,
|
||||
hasWritePermission = hasWritePermission,
|
||||
completion = Seq("emoji", "user"),
|
||||
completionContext = "issues",
|
||||
style = "height: 100px; max-height: 150px;",
|
||||
elastic = true
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@(content: String, commentId: Int, owner: String, repository: String)(implicit context: gitbucket.core.controller.Context)
|
||||
<span class="error-edit-content-@commentId error"></span>
|
||||
@gitbucket.core.helper.html.attached(owner, repository, Seq("emoji", "user")){
|
||||
@gitbucket.core.helper.html.attached(owner, repository, "issues"){
|
||||
<textarea style="height: 100px;" id="edit-content-@commentId" class="form-control">@content</textarea>
|
||||
}
|
||||
<div>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
enableLineBreaks = false,
|
||||
enableTaskList = false,
|
||||
hasWritePermission = false,
|
||||
completion = Seq("emoji"),
|
||||
completionContext = "wiki",
|
||||
style = "height: 400px;",
|
||||
styleClass = "monospace",
|
||||
placeholder = "",
|
||||
|
||||
Reference in New Issue
Block a user