0

So we currently have Jira in our workplace and no Jira Administrator. I'm feeling up to the task and would like to know if Jira has the functionality I'm looking for.

So when you have comments in Jira or even in the body of a Jira ticket. You can italicize the text from the comment ribbon JiraComment

As you can see I am interested in being able to have the same functionality as bold or italicize or underline but I want to be able to highlight some code that i insert in a ticket comment and click a button and make it into a code block. Or add curly brackets and make it a quote... Exactly like how StackOverflow does it.

Anyone know how I can accomplish this?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hituptony
  • 2,740
  • 3
  • 22
  • 44

2 Answers2

1

This is quite old question but it might help someone else looking for an answer later...

If you're familiar with JavaScript, simply inject a button via JS onto the toolbar. I've done this for a couple of custom fields. Such JS can be included in the custom field's description.

Example

In my case, I've added two buttons on two custom fields to copy original content from Summary/Description. You can adjust the code to do a whatever action on any custom field or comment field.

Screenshot

enter image description here

Code

Code to be included in the custom field's description. Adjust your code to place the JS into appropriate elements.

<script>
var cfAltDescription = 14705;
var elAltDescription = AJS.$("#customfield_" + cfAltDescription);

function addDescriptionButton() {
    var buttonHTML = ' <button type="button" class="aui-button" style="font-size: 11px;padding: 1px 5px;" title="Paste original description into this field" onclick="copyDescription()">&lt; Description</button>';
    AJS.$(".jira-wikifield[field-id=customfield_" + cfAltDescription + "] ~ .wiki-button-bar").append(buttonHTML);
}

function copyDescription() {
    var origDescription = AJS.$("#description").attr("value");
    elAltDescription.attr("value", origDescription);
    // set focus in the input box after copying...
    elAltDescription.focus()[0].setSelectionRange(0, 0);
    elAltDescription.scrollTop(0);
}

addDescriptionButton();
</script>

For comments, you cannot inject JS into the custom field description (comments are not a custom field). You will need to include your JS either via Announcement Banner (this would be global JS for any Jira page). Alternatively, you can utilize simple yet powerful JsIncluder add-on to inject your own JS code only for certain project/issuetype or globally and/or for edit/transition screens only.

CraZ
  • 1,669
  • 15
  • 24
0

I think you can use plugin for this. jeditor plugin gives you more options in text editors. all information you need is provided in above link.after installing this plugin you can change the text renderer as "JEditor Renderer". Marketplace: https://marketplace.atlassian.com/plugins/com.jiraeditor.jeditor

or you can use.....

Note:-I guess this is not the exact answer you need but I think you can use macros inside the comment field. ex:if you want to add panel in inside of comment you can simply use

{panel}Some text{panel}
{panel:title=My Title}Some text with a title{panel}
{panel:title=My Title| borderStyle=dashed| borderColor=#ccc| titleBGColor=#F7D6C1| bgColor=#FFFFCE}
a block of text surrounded with a *panel*
yet _another_ line
{panel} 

and if you want to add code you can use...

--- Java example ---
{code:title=Bar.java|borderStyle=solid}
// Some comments here
public String getFoo()
{
    return foo;
}
{code}
*--- XML example ---*
{code:xml}
<test>
  <another tag="attribute"/>
</test>
{code}

here is a example screenshot..

enter image description here

follow this link for more information..

UPDATE with the plugin you can get something like this..I think this will helps you.enter image description here

Nuwan
  • 1,226
  • 1
  • 14
  • 38
  • Thanks for your answer. I am interested in having a button or have some kind of functionality where I can hit CTRL + k (for example) to put it in a code block. I'm aware you can macro it in the comment, but that takes a lot of extra time if you have say 10 or more.... – Hituptony Oct 08 '15 at 14:14