How to convert page source frim preview mode to storage format

Hi!
When the Confluence macro is rendered in Previw mode and reads parent page xhtml-code, it gets a code, which is not the same, which is on a saved page. All the macro instances are enclosed in wysiwyg-macros. How I can transform such code to normal page storage format?
Thanks!

1 answer

0 vote

Hi Alexey,

Can you let us know perhaps what you are trying to do? The Source Editor plugin, for example, will display the actual storage format and allow you to edit it.

Kind Regards,
Shannon

Hi,
I'm developing a macro, which uses it's parent page contents.
When this macro is rendered on a saved page, it reads its content normally. But when it is rendered in a preview mode and reads its parent page in the same manner, the page content is different: macros are replaced with Wysiwyg-macro and macro parameters are specified as parameters of this Wysiwyg-macro. Replacing this macro manually does not seem tobe a good solution, so I'm asking how to get normal page content, without Wysiwyg-macro?
Thanks!

Alexey,

When you install the Source Editor plugin above, once you've saved the page you can go in and edit again, and there will be a <> icon in the top right of the editor. You can click this and it will show all content as the source rather than WYSIWYG. Have you been able to test this, and is it what you require? 

Note, it won't show the source content when just viewing the page, but it sounds like you only need it to display that content when editing. Is this correct?

Kind Regards,
Shannon

Hi Shannon,

Thank you for your answer.

I don't use Source Editor, I just read source page from my macro. Here is the code:

PageContext renderContext = conversionContext.getPageContext();
PageContext pageContext = ((PageContext) renderContext);
pageContext.setOutputType(RenderContextOutputType.DISPLAY);
ContentEntityObject contentObject = pageContext.getEntity();
String page = contentObject.getBodyAsString();

 So, the page variable contains page source in storage format, but all the macros on the page are enclosed in WYSIWYG macro body:

<tr>
<td class="confluenceTd">&nbsp;</td>
<td class="confluenceTd"><table class="wysiwyg-macro"
style="background-image: url('http://LEXUS:1990/confluence/plugins/servlet/confluence/placeholder/macro-heading?definition=e251bWVyaWNhbC1leHByZXNzaW9uOm91dGVyLXZhbHVlcy1zb3VyY2U9UGFnZSBjb250ZW50fGF0bGFzc2lhbi1tYWNyby1vdXRwdXQtdHlwZT1JTkxJTkV9&amp;locale=en_GB&amp;version=2'); background-repeat: no-repeat;"
data-macro-name="my-macro"
data-macro-id="47a26b47-7e92-408b-b149-e30831f20416"
data-macro-parameters="atlassian-macro-output-type=INLINE|parameter=value"
data-macro-schema-version="1" data-macro-body-type="RICH_TEXT">
<tbody>
<tr>
<td class="wysiwyg-macro-body"><p>2+2</p></td>
</tr>
</tbody>
</table></td>
</tr>

What I need is to get page source without this WYSIWYG macro.

Thanks!

Hi Alexey,

From my understanding, you wish to display the Confluence page as page source rather than WYSIWYG. Correct?

The Source Editor add-on that I recommended you install, will do just that, allow you to view Confluence pages in edit mode as the source, and not WYSIWYG.

If you've already tested that add-on, can you let me know why it might not work for your use case?

Kind Regards,
Shannon

Hi Shannon,

We are developing a commercial plug-in, so installing any other plug-ins is not an option.

What I need is to get page source in storage format from my macro code, when it is placed on a page in preview mode.

Thanks!

Alexey,

Thank you for letting me know why you weren't able to use the other add-on.

I'm still a little unclear on what you need to do exactly. Are you saying this is the functionality you want your macro to have? You want it to display page source in storage format anytime a user has it on a page and previews the page?

This sounds like something that our development community would need to help you with, so I will add the Confluence Development tag on your question and someone will be able to assist.

Kind Regards,
Shannon

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

804 views 23 12
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you