mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-06 10:17:37 +02:00
Mention completion for issue editor. (#3136)
* new issue mention * Mention completion on new issue and view issue page. * Code format. * Require tribute in pull request page.
This commit is contained in:
1 parent
f2e20c81b6
commit
03ec35ed79
7 files changed
+76
No files matched your search
@@ -570,6 +570,7 @@ function initRepository() {
|
||||
if ($editContentZone.html().length == 0) {
|
||||
$editContentZone.html($('#edit-content-form').html());
|
||||
$textarea = $segment.find('textarea');
|
||||
issuesTribute.attach($textarea.get());
|
||||
|
||||
// Give new write/preview data-tab name to distinguish from others
|
||||
var $editContentForm = $editContentZone.find('.ui.comment.form');
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
.tribute-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: auto;
|
||||
max-height: 300px;
|
||||
max-width: 500px;
|
||||
overflow: auto;
|
||||
display: block;
|
||||
box-shadow: 0px 1px 3px 1px #c7c7c7;
|
||||
z-index: 999999; }
|
||||
.tribute-container ul {
|
||||
margin: 0;
|
||||
margin-top: 2px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
background: #ffffff; }
|
||||
.tribute-container li {
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #dcdcdc;
|
||||
cursor: pointer; }
|
||||
.tribute-container li.highlight, .tribute-container li:hover {
|
||||
background: #2185D0;
|
||||
color: #ffffff;}
|
||||
.tribute-container li img {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
width: 28px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.tribute-container li span {
|
||||
font-weight: bold; }
|
||||
.tribute-container li span.fullname {
|
||||
font-weight: normal;
|
||||
font-size: 0.8rem;
|
||||
margin-left: 3px;}
|
||||
.tribute-container li.no-match {
|
||||
cursor: default; }
|
||||
.tribute-container .menu-highlighted {
|
||||
font-weight: bold; }
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Tribute=e()}}(function(){return function e(t,n,i){function r(u,l){if(!n[u]){if(!t[u]){var a="function"==typeof require&&require;if(!l&&a)return a(u,!0);if(o)return o(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var s=n[u]={exports:{}};t[u][0].call(s.exports,function(e){var n=t[u][1][e];return r(n?n:e)},s,s.exports,e,t,n,i)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u<i.length;u++)r(i[u]);return r}({1:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),u=e("./utils"),l=(i(u),e("./TributeEvents")),a=i(l),c=e("./TributeMenuEvents"),s=i(c),d=e("./TributeRange"),f=i(d),h=e("./TributeSearch"),v=i(h),p=function(){function e(t){var n=this,i=t.values,o=void 0===i?null:i,u=t.iframe,l=void 0===u?null:u,c=t.selectClass,d=void 0===c?"highlight":c,h=t.trigger,p=void 0===h?"@":h,g=t.selectTemplate,m=void 0===g?null:g,b=t.menuItemTemplate,y=void 0===b?null:b,w=t.lookup,T=void 0===w?"key":w,E=t.fillAttr,S=void 0===E?"value":E,k=t.collection,x=void 0===k?null:k,C=t.menuContainer,A=void 0===C?null:C,N=t.noMatchTemplate,M=void 0===N?null:N,I=t.requireLeadingSpace,P=void 0===I||I,L=t.allowSpaces,D=void 0!==L&&L,O=t.replaceTextSuffix,R=void 0===O?null:O;if(r(this,e),this.menuSelected=0,this.current={},this.inputEvent=!1,this.isActive=!1,this.menuContainer=A,this.allowSpaces=D,this.replaceTextSuffix=R,o)this.collection=[{trigger:p,iframe:l,selectClass:d,selectTemplate:(m||e.defaultSelectTemplate).bind(this),menuItemTemplate:(y||e.defaultMenuItemTemplate).bind(this),noMatchTemplate:function(e){return"function"==typeof e?e.bind(n):function(){return'<li class="no-match">No match!</li>'}.bind(n)}(M),lookup:T,fillAttr:S,values:o,requireLeadingSpace:P}];else{if(!x)throw new Error("[Tribute] No collection specified.");this.collection=x.map(function(t){return{trigger:t.trigger||p,iframe:t.iframe||l,selectClass:t.selectClass||d,selectTemplate:(t.selectTemplate||e.defaultSelectTemplate).bind(n),menuItemTemplate:(t.menuItemTemplate||e.defaultMenuItemTemplate).bind(n),noMatchTemplate:function(e){return"function"==typeof e?e.bind(n):null}(M),lookup:t.lookup||T,fillAttr:t.fillAttr||S,values:t.values,requireLeadingSpace:t.requireLeadingSpace}})}new f.default(this),new a.default(this),new s.default(this),new v.default(this)}return o(e,[{key:"triggers",value:function(){return this.collection.map(function(e){return e.trigger})}},{key:"attach",value:function(e){if(!e)throw new Error("[Tribute] Must pass in a DOM node or NodeList.");if("undefined"!=typeof jQuery&&e instanceof jQuery&&(e=e.get()),e.constructor===NodeList||e.constructor===HTMLCollection||e.constructor===Array)for(var t=e.length,n=0;n<t;++n)this._attach(e[n]);else this._attach(e)}},{key:"_attach",value:function(e){e.hasAttribute("data-tribute")&&console.warn("Tribute was already bound to "+e.nodeName),this.ensureEditable(e),this.events.bind(e),e.setAttribute("data-tribute",!0)}},{key:"ensureEditable",value:function(t){if(e.inputTypes().indexOf(t.nodeName)===-1){if(!t.contentEditable)throw new Error("[Tribute] Cannot bind to "+t.nodeName);t.contentEditable=!0}}},{key:"createMenu",value:function(){var e=this.range.getDocument().createElement("div"),t=this.range.getDocument().createElement("ul");return e.className="tribute-container",e.appendChild(t),this.menuContainer?this.menuContainer.appendChild(e):this.range.getDocument().body.appendChild(e)}},{key:"showMenuFor",value:function(e,t){var n=this;if(!this.isActive||this.current.element!==e||this.current.mentionText!==this.currentMentionTextSnapshot){this.currentMentionTextSnapshot=this.current.mentionText,this.menu||(this.menu=this.createMenu(),this.menuEvents.bind(this.menu)),this.isActive=!0,this.menuSelected=0,this.current.mentionText||(this.current.mentionText="");var i=function(e){if(n.isActive){var i=n.search.filter(n.current.mentionText,e,{pre:"<span>",post:"</span>",extract:function(e){if("string"==typeof n.current.collection.lookup)return e[n.current.collection.lookup];if("function"==typeof n.current.collection.lookup)return n.current.collection.lookup(e);throw new Error("Invalid lookup attribute, lookup must be string or function.")}});n.current.filteredItems=i;var r=n.menu.querySelector("ul");if(n.range.positionMenuAtCaret(t),!i.length){var o=new CustomEvent("tribute-no-match",{detail:nLine truncated
|
||||
//# sourceMappingURL=tribute.min.js.map
|
||||
Reference in new issue
Block a user