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

#1127 | Placeholder is visible when only empty table is in Editor. #1128

Merged
merged 2 commits into from
Jun 21, 2016
Merged
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
6 changes: 6 additions & 0 deletions spec/placeholder.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ describe('MediumEditor.extensions.placeholder TestCase', function () {
expect(editor.elements[0].className).not.toContain('medium-editor-placeholder');
});

it('should not set a placeholder for elements with table', function () {
this.el.innerHTML = '<table></table>';
var editor = this.newMediumEditor('.editor');
expect(editor.elements[0].className).not.toContain('medium-editor-placeholder');
});

it('should set placeholder for elements with empty children', function () {
this.el.innerHTML = '<p><br></p><div class="empty"></div>';
var editor = this.newMediumEditor('.editor');
Expand Down
2 changes: 1 addition & 1 deletion src/js/extensions/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

updatePlaceholder: function (el, dontShow) {
// If the element has content, hide the placeholder
if (el.querySelector('img, blockquote, ul, ol') || (el.textContent.replace(/^\s+|\s+$/g, '') !== '')) {
if (el.querySelector('img, blockquote, ul, ol, table') || (el.textContent.replace(/^\s+|\s+$/g, '') !== '')) {
return this.hidePlaceholder(el);
}

Expand Down