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

Disabled headings for lists #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 18 additions & 1 deletion dist/pell.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,19 @@ var defaultActions = {
olist: {
icon: '#',
title: 'Ordered List',
state: function state() {
return queryCommandState('insertOrderedList');
},
result: function result() {
return exec('insertOrderedList');
}
},
ulist: {
icon: '•',
title: 'Unordered List',
state: function state() {
return queryCommandState('insertUnorderedList');
},
result: function result() {
return exec('insertUnorderedList');
}
Expand Down Expand Up @@ -172,8 +178,18 @@ var init = function init(settings) {
content.className = classes.content;
content.oninput = function (_ref) {
var firstChild = _ref.target.firstChild;

if (firstChild && firstChild.nodeType === 3) exec(formatBlock, '<' + defaultParagraphSeparator + '>');else if (content.innerHTML === '<br>') content.innerHTML = '';

var h1 = document.getElementById('Heading 1');
var h2 = document.getElementById('Heading 2');
var p = document.getElementById('Paragraph');
var q = document.getElementById('Quote');
if(queryCommandState('insertUnorderedList') != false || queryCommandState('insertOrderedList') != false){
h1.disabled = h2.disabled = p.disabled = q.disabled = true;
}else {
h1.disabled = h2.disabled = p.disabled = q.disabled = false;
}

settings.onChange(content.innerHTML);
};
content.onkeydown = function (event) {
Expand All @@ -189,6 +205,7 @@ var init = function init(settings) {
var button = createElement('button');
button.className = classes.button;
button.innerHTML = action.icon;
button.id = action.title;
button.title = action.title;
button.setAttribute('type', 'button');
button.onclick = function () {
Expand Down