Created
October 24, 2018 23:37
-
-
Save michaeldjeffrey/46b7556b901a1abe593384ed68f9302d to your computer and use it in GitHub Desktop.
Ckeditor Placeholder plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[contenteditable=true][placeholder].ck-editor__is-empty::before { | |
content: attr(placeholder); | |
position: absolute; | |
display: block; | |
margin: var(--ck-spacing-large) 0; | |
color: #aaa; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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