Skip to content

Instantly share code, notes, and snippets.

@wwalser
Created August 16, 2012 07:00
Show Gist options
  • Save wwalser/3367579 to your computer and use it in GitHub Desktop.
Save wwalser/3367579 to your computer and use it in GitHub Desktop.
Add New Page Layouts To Confluence
/**
* Hard coded! Nah, we put our smart pants on the day we wrote page layouts. We even gave
* external developers a way to create new layouts.
*
* Layouts are algorithmically generated based on a JSON string in the layout toolbar.
* On an edit page, use your Javascript foo to find #rte-button-pagelayout in the DOM
* then check out the hidden toolbar just below it and you'll find the JSON I'm
* talking about.
*
* We expose an editor command though which you can add new layouts and provide
* class names so that you can customize their widths with CSS. Layouts are fairly
* limited, this is somewhat intentional.
*
* Don't worry about the ui parameter, it doesn't serve a purpose with this command
*/
/**
* Sets the layout of the current editor to the provided layout.
*
* param command String name of the command
* param ui bool show UI for this command
* param layout Object representing the layout that the current editor should
* be converted too
* it is structured as follows:
* {
* name: name of the layout (this is required)
* header: boolean
* footer: boolean
* columns: array length represents the number of columns and each index n
* is a string to be added to the classname of the nth column
* }
*/
AJS.Rte.getEditor().execCommand(
'mcePageLayout',
false,
{name: 'dominicsAwesomeLayout', header: true, footer: true, columns: ['foo','bar']}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment