I'm not very familiar with the CKEDITOR API yet, and now I'm stuck trying to find a way to create placeholders inside the CKEDITOR editable area. The expected behavior for the placeholder is to disappear when interacting with the user, which allows you to edit the content.
I know that there is already a placeholder plugin ( http://ckeditor.com/addon/placeholder ), but its behavior is not what I'm looking for.
To be more specific, the question arises: is it possible to subscribe to some events on a specific element inside CKEDITOR?
Working in an angular context I can compile my html before it is passed to the CKEDITOR ng model
$scope.html = $compile('<div><span text-placeholder >Placeholder</span></div>')($scope).html();
But then I am not trying to set click events inside the directive:
.directive('textPlaceholder', [ function () {
return {
restrict: 'A',
link: function ($scope, $element) {
$element.on('click', function () {
console.log('clicked');
})
}
}
}])
Any thoughts?
UPDATE:. , CKEDITOR:
(function () {
CKEDITOR.plugins.add('text-placeholder', {
init: function (editor) {
editor.on('key', function (evt) {
var el = $(CKEDITOR.instances.editor1.getSelection().getNative().baseNode.parentElement);
if (el.hasClass('text-placeholder')) {
el.remove();
}
});
}
});
})();
. .