Skip to content
This repository has been archived by the owner on Nov 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request digineo#1 from shalotelli/4.x
Browse files Browse the repository at this point in the history
plugin updated for v4.x
  • Loading branch information
corny committed Oct 22, 2013
2 parents ce633fd + b213c89 commit f848ae4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
# Liquid Markup Plugin for CKEditor 3.x
# Liquid Markup Plugin for CKEditor 4.x

This plugin highlights Liquid Markup Blocks like `{{variable.name}}` and `{% liquid block %}` in the WYSIWYG view.

Expand Down
31 changes: 17 additions & 14 deletions plugin.js
@@ -1,7 +1,7 @@
CKEDITOR.plugins.add('liquid', {
requires: ['htmldataprocessor'],
afterInit: function(editor){
editor.addCss('liquidVariable, liquidBlock' +
onLoad: function()
{
CKEDITOR.addCss('liquidVariable, liquidBlock' +
'{' +
'color: #000;' +
'background-color: #ffc;' +
Expand All @@ -13,16 +13,19 @@ CKEDITOR.plugins.add('liquid', {
'{' +
'background-color: #fcc;' +
'}');

var dataProcessor = editor.dataProcessor, dataFilter = dataProcessor && dataProcessor.dataFilter, htmlFilter = dataProcessor && dataProcessor.htmlFilter;
},
init: function(editor)
{
var dataProcessor = editor.dataProcessor,
dataFilter = dataProcessor && dataProcessor.dataFilter,
htmlFilter = dataProcessor && dataProcessor.htmlFilter;

// html to data conversion
if (dataFilter) {
dataFilter.addRules({

text: function(text){
text = text.replace(/\{\{([\w\.]+)\}\}/g, "<liquidVariable>$1</liquidVariable>");
text = text.replace(/\{%(.+)%\}/g, "<liquidBlock>$1</liquidBlock>");
text: function(text) {
text = text.replace(/\{\{([\w\.]+)\}\}/g, "<liquidVariable>{{$1}}</liquidVariable>");
text = text.replace(/\{%(.+)%\}/g, "<liquidBlock>{%$1%}</liquidBlock>");
return text;
}
});
Expand All @@ -36,20 +39,20 @@ CKEDITOR.plugins.add('liquid', {
// Drop the wrapper element.
delete element.name;

if (element.children.size() > 0) {
element.children[0].value = "{{" + element.children[0].value + "}}"
if (element.children.length > 0) {
element.children[0].value = element.children[0].value;
}
},
liquidblock: function(element, b, c){
// Drop the wrapper element.
delete element.name;

if (element.children.size() > 0) {
element.children[0].value = "{%" + element.children[0].value + "%}"
if (element.children.length > 0) {
element.children[0].value = element.children[0].value;
}
}
}
});
}
},
}
});

0 comments on commit f848ae4

Please sign in to comment.