Skip to content

Instantly share code, notes, and snippets.

@michaeldjeffrey
Created October 24, 2018 23:37
Show Gist options
  • Save michaeldjeffrey/46b7556b901a1abe593384ed68f9302d to your computer and use it in GitHub Desktop.
Save michaeldjeffrey/46b7556b901a1abe593384ed68f9302d to your computer and use it in GitHub Desktop.
Ckeditor Placeholder plugin
[contenteditable=true][placeholder].ck-editor__is-empty::before {
content: attr(placeholder);
position: absolute;
display: block;
margin: var(--ck-spacing-large) 0;
color: #aaa;
}
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import './placeholder.css';
export default class ETWPlaceholder extends Plugin {
static get pluginName() {
return "Placeholder";
}
init() {
debugger;
const editor = this.editor;
const view = editor.ui.view.editable;
const placeholder = editor.sourceElement.getAttribute('placeholder');
if (placeholder) {
view.extendTemplate({
attributes: {
placeholder: placeholder,
}
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment