Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

WYSIWYG Plugin with embedded javascript

Luis Mayora
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 28, 2011

I am creating JIRA WYSIWYG Editor Plugin. The problem is that i have to manually copy the TinyMCE library to the include/js folder within the JIRA Instance. I was wondering if i could include this Tiny MCE Javascript library on my plugin folders(Eclipse IDE) and then reference my library files from the velocity templates like

<script type="text/javascript" src="/tinymce/jscripts/tiny_mce/tiny_mce.js" ></script > 

I would like to use something like

<script type="text/javascript" src="/{$my_eclipse_path}/tiny_mce/tiny_mce.js" ></script > 


With this approach it will be cleaner to use my custom field on every jira instance without manually copying the tinymce library.

Questions:

1. Do i have to include anything on my atlassian-plugin.xml?

Thanks.

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
brainicorn
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 30, 2011

If you need a library in your JIRA plugin code, you should piut the js files in your project's src/main/resources folder.

So let's say you put the tinyMCE files in /src/main/resources/tinyMCE/

From there, you can include the files in your atlassian-plugin.xml like so:

<web-resource key="tinymce" name="TinyMCE Resources" >

<resource type="download" name="tinyMCE.js" location="tinyMCE/tinyMCE.js" />

<!-- add additional resources if needed -->

</web-resource>

Once you have that, you can reference the library from your velocity template like this:

$webResourceManager.requireResource("your.full.plugin.key:tinymce")
<html>
<head>
    <title>My plugin template</title>
    $webResourceManager.getRequiredResources()
</head>
<body> ... </body>
</html>

The library files will automatically be included for you.

This is just one way to do it though. I'd suggest taking a look at the following page for more options:

http://confluence.atlassian.com/display/JIRA/Web+Resource+Plugin+Module

Kristian Andersen
Contributor
November 14, 2012

I was looking for a way to include a .js file in a webwork action template, and this did the trick. But it seems you do not need $webResourceManager.getRequiredResources()

Just Supplying $webResourceManager.requireResource("something") worked for me.

If i supplied both lines my .js file was included twice.

 
0 votes
Luis Mayora
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2011

Hi,

I tried your approach with no results.

I have included my process.

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
</plugin-info>

<customfield-type key="WYSIWYG" name="WYSIWYG Editor" class="org.mayorgsoft.jira.cf.plugins.WysiwugEditor">
<description>WYSIWYG HTML Editor based on Tiny MCE. http://tinymce.moxiecode.com/</description><br< a=""> /> <resource type="velocity" name="view" location="templates/view-wysiwyg.vm" />
<resource type="velocity" name="edit" location="templates/edit-wysiwyg.vm" />
<resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-basictext.vm" />
</customfield-type>

<web-resource key="tinymce" name="TinyMCE Resources">
<resource type="download" name="tiny_mce.js" location="tinymce/jscripts/tiny_mce/t...


The location is correct and the name of the script too.

I have included the plugin key.

$webResourceManager.requireResource("org.mayorgsoft.jira.cf.plugins.WYSIWYG:tinymce") on my velocity tempalte

I get the following exception.

2011-07-12 20:26:20,654 http-2990-2 ERROR admin 1226x887x1 edczuv 127.0.0.1 /secure/CreateIssue.jspa [webwork.util.ValueStack] METHOD: "createHtml", exception:
java.lang.NullPointerException
at org.mayorgsoft.jira.cf.plugins.WysiwugEditor.getCustomTable(Wysiw...













































































































































































































Luis Mayora
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 20, 2011

I guess this option will add some overhead and not planning to become a jira developer :). I guess using the mark it up library allows me to configure a wiki tool bar for jira using a json configuration file to update the confluence wiki markup. Really worked.

TAGS
AUG Leaders

Atlassian Community Events