Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for placeholder text #140

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ pell.init({
// Outputs <span style="font-weight: bold;"></span> instead of <b></b>
styleWithCSS: false,

// <string>, optional, default = ''
// Adds a placeholder text to the input area
placeholder: "",

// <Array[string | Object]>, string if overwriting, object if customizing/creating
// action.name<string> (only required if overwriting)
// action.icon<string> (optional if overwriting, required if custom action)
Expand Down
1 change: 1 addition & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h3>HTML output:</h3>
var editor = window.pell.init({
element: document.getElementById('editor'),
defaultParagraphSeparator: 'p',
placeholder: "Type something..."
onChange: function (html) {
document.getElementById('text-output').innerHTML = html
document.getElementById('html-output').textContent = html
Expand Down
9 changes: 8 additions & 1 deletion dist/pell.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
height: 300px;
outline: 0;
overflow-y: auto;
padding: 10px; }
padding: 10px;
position: relative; }
.pell-content:empty:before {
content: attr(data-placeholder);
position: absolute;
color: rgba(10, 10, 10, 0.4); }
.pell-content:empty:focus:before {
color: rgba(10, 10, 10, 0.1); }

.pell-actionbar {
background-color: #FFF;
Expand Down
3 changes: 3 additions & 0 deletions dist/pell.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ var init = function init(settings) {
var content = settings.element.content = createElement('div');
content.contentEditable = true;
content.className = classes.content;
if (settings.placeholder) {
content.dataset.placeholder = settings.placeholder;
}
content.oninput = function (_ref) {
var firstChild = _ref.target.firstChild;

Expand Down
2 changes: 1 addition & 1 deletion dist/pell.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/pell.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading