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

WIP Trying to prevent header nesting in lists in Chrome #WIP #109

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
14 changes: 7 additions & 7 deletions src/pell.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ const defaultActions = {
heading1: {
icon: '<b>H<sub>1</sub></b>',
title: 'Heading 1',
result: () => exec(formatBlock, '<h1>')
result: () => exec(formatBlock, 'H1')
},
heading2: {
icon: '<b>H<sub>2</sub></b>',
title: 'Heading 2',
result: () => exec(formatBlock, '<h2>')
result: () => exec(formatBlock, 'H2')
},
paragraph: {
icon: '&#182;',
title: 'Paragraph',
result: () => exec(formatBlock, '<p>')
result: () => exec(formatBlock, 'P')
},
quote: {
icon: '&#8220; &#8221;',
title: 'Quote',
result: () => exec(formatBlock, '<blockquote>')
result: () => exec(formatBlock, 'BLOCKQUOTE')
},
olist: {
icon: '&#35;',
Expand All @@ -66,7 +66,7 @@ const defaultActions = {
code: {
icon: '&lt;/&gt;',
title: 'Code',
result: () => exec(formatBlock, '<pre>')
result: () => exec(formatBlock, 'PRE')
},
line: {
icon: '&#8213;',
Expand Down Expand Up @@ -121,15 +121,15 @@ export const init = settings => {
content.contentEditable = true
content.className = classes.content
content.oninput = ({ target: { firstChild } }) => {
if (firstChild && firstChild.nodeType === 3) exec(formatBlock, `<${defaultParagraphSeparator}>`)
if (firstChild && firstChild.nodeType === 3) exec(formatBlock, defaultParagraphSeparator.toUpperCase())
else if (content.innerHTML === '<br>') content.innerHTML = ''
settings.onChange(content.innerHTML)
}
content.onkeydown = event => {
if (event.key === 'Tab') {
event.preventDefault()
} else if (event.key === 'Enter' && queryCommandValue(formatBlock) === 'blockquote') {
setTimeout(() => exec(formatBlock, `<${defaultParagraphSeparator}>`), 0)
setTimeout(() => exec(formatBlock, defaultParagraphSeparator.toUpperCase()), 0)
}
}
appendChild(settings.element, content)
Expand Down