custom-dropdown-ckeditor4
custom-dropdown-ckeditor4 copied to clipboard
Allow text and HTML values
Hello, please consider the patch below to control whether a string is inserted as either text or HTML. To indicate a string is HTML formatted you must provide a property html with value that evaluates to true in the strinsert_strings configuration object, like done in the additional example. This implementation also transparently works around the issue that CKEditor richcombo values does not like HTML entities in its values as confirmed in https://dev.ckeditor.com/ticket/11701.
Index: plugin.js
===================================================================
--- plugin.js (revision 25)
+++ plugin.js (working copy)
@@ -27,6 +27,7 @@
{'name': 'Name', 'value': '*|VALUE|*'},
{'name': 'Group 1'},
{'name': 'Another name', 'value': 'totally_different', 'label': 'Good looking'},
+ {'name': 'Some HTML', 'html': true, 'value': '<strong>Some <HTML></strong>'},
];
/**
@@ -89,7 +90,7 @@
if (!string.label) {
string.label = string.name;
}
- this.add(string.value, string.name, string.label);
+ this.add(""+i, string.name, string.label);
}
}
},
@@ -98,7 +99,8 @@
{
editor.focus();
editor.fire( 'saveSnapshot' );
- editor.insertHtml(value);
+ var string = strings[value];
+ editor[string.html ? 'insertHtml' : 'insertText'](string.value);
editor.fire( 'saveSnapshot' );
},