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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to copy a Macro filled with content, without going into the Edit Mode?

Hey Guys,

I've been working on a solution to copy a macro filled with content, without going into the Edit mode. I did some research, I iterated on couple of drafts but to no avail.

Let me try to structure the problem, and path I went through.

1. Reasoning (the need)

The reason behind this kind of solution is to serve a user, that has read only permission, a possibilty to copy into his own Confluence page not only the outcome of the macro's work but also the whole macro filled with the content, so he/she can modify it, while keeping him/her from editing the page.

2. Example of use

There is a form (a ContiForm) pre-populated with content and variety of options already picked. Setting up such form takes a good while. Through such solution user could copy the form into his Confluence page, modify 1-2 fields and re-use the whole bunch of options. But he/she would not have a chance to change anything in the source page, since has read-only privileges.

3. Attempts

So I've tried adding js scripts through html macro, with and without using the jQuery.

The furthest I got was to copy specific part of the page with full formatting and function (the result of macro's work), but not the macro itself.

function copy(element_id){
var aux = document.createElement("div");
aux.setAttribute("contentEditable", true);
aux.innerHTML = document.getElementById(element_id).innerHTML;
aux.setAttribute("onfocus", "document.execCommand('selectAll',false,null)");
document.body.appendChild(aux);
aux.focus();
document.execCommand("copy");
document.body.removeChild(aux);
}

+

<p id="demo"><b>Bold text</b> and <u>underlined text</u>.</p>
<button onclick="copy('demo')">Copy Result</button>

I know it might seem this is a very hacky attempt, but that was my idea. I have no experience in velocity, nor I have administration privileges in the the said Confluence sever instance. Hence this is the way I tried to achieve the goal with such attempt.

4. Discussion starter

If you have any insight you might share, or idea of your own or some advice, I'd be more the happy to read your input.

Any constructive help would be most appreciated.

0 comments

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Confluence

🏑 Atlympic Event: Confluence

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

474 views 18 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you