Demo plugin

JWT emitted by DrPublish

function fetchJWT() { var jwt = PluginAPI.getJWT(); if (jwt !== '') { var jwtParsed = parseJwt(jwt); jwtParsed.jwt = jwt; $('#jwt-result').val(JSON.stringify(jwtParsed)); } else { $('#jwt-result').val('no JWT given'); } }

Fetch article id dynamically, each time a new article is loaded in the editor

function initPlugin() { PluginAPI.setPluginName('helloworld'); // fetch article id after the article has been loaded fetchArticleIdDynamically(); } function fetchArticleIdDynamically() { PluginAPI.Article.getId(function(id) { console.log('stef:fetchedartid', id); $('#fetchArticleId-result').val(id); }); }

Inject HTML text string at cursor position

PluginAPI.Editor.insertString('<h3>Hello World</h3>');

Read article content

PluginAPI.Editor.getHTMLBySelector('*', function (data) { $('#result-preview-txt').val(data); });

Get article id

PluginAPI.Article.getId(function (id) { $('#getId-result').val(id); });

Get tags

PluginAPI.Article.getTags(function (tags) { $('#getTags-result').val(tags.length > 0 ? JSON.stringify(tags) : 'article has no tags'); });

Get custom metadata (aka. "article property")

* If no value is provided, all available custom metadata are fetched
PluginAPI.Article.getTags(function (tags) { $('#getTags-result').val(tags.length > 0 ? JSON.stringify(tags) : 'article has no tags'); });

Set custom metadata (aka. "article property")

PluginAPI.Article.getTags(function (tags) { $('#getTags-result').val(tags.length > 0 ? JSON.stringify(tags) : 'article has no tags'); });