I am using CKEditor 4 with Placeholder plugin, when I add a placeholder (FirstName), I want it to be printed with single brackets instead of double: ([FirstName] instead of [[FirstName]]). I have tried to change it from ‘after init’ function but didn’t work. I installed ckeditor 4 package with Placeholder plugin included.
ckeditor.js:
CKEDITOR.plugins.add("placeholder", {
requires: "widget,dialog", onLoad: function () { CKEDITOR.addCss(".cke_placeholder{background-color:#ff0}") }, init: function (a) {
var b = a.lang.placeholder; CKEDITOR.dialog.add("placeholder", this.path + "dialogs/placeholder.js"); a.widgets.add("placeholder", {
dialog: "placeholder", pathName: b.pathName, template: 'x3cspan classx3d"cke_placeholder"x3e[[]]x3c/spanx3e', downcast: function () { return new CKEDITOR.htmlParser.text("[[" + this.data.name + "]]") }, init: function () {
this.setData("name",
this.element.getText().slice(2, -2))
}, data: function () { this.element.setText("[[" + this.data.name + "]]") }, getLabel: function () { return this.editor.lang.widget.label.replace(/%1/, this.data.name + " " + this.pathName) }
}); a.ui.addButton && a.ui.addButton("CreatePlaceholder", { label: b.toolbar, command: "placeholder", toolbar: "insert,5", icon: "placeholder" })
}, afterInit: function (a) {
var b = /[[([^[]])+]]/g; a.dataProcessor.dataFilter.addRules({
text: function (f, d) {
var e = d.parent && CKEDITOR.dtd[d.parent.name]; if (!e || e.span) return f.replace(b,
function (b) { var c = null, c = new CKEDITOR.htmlParser.element("span", { "class": "cke_placeholder" }); c.add(new CKEDITOR.htmlParser.text(b)); c = a.widgets.wrapElement(c, "placeholder"); return c.getOuterHtml() })
}
})
}
})
placeholder.js
CKEDITOR.dialog.add("placeholder", function (a) { var b = a.lang.placeholder; a = a.lang.common.generalTab; return { title: b.title, minWidth: 300, minHeight: 80, contents: [{ id: "info", label: a, title: a, elements: [{ id: "name", type: "text", style: "width: 100%;", label: b.name, "default": "", required: !0, validate: CKEDITOR.dialog.validate.regex(/^[^[]<>]+$/, b.invalidName), setup: function (a) { this.setValue(a.data.name) }, commit: function (a) { a.setData("name", this.getValue()) } }] }] } });