mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Add 'H2' as editable element.
This will almost certainly require further modifications down the road, but let's start here.
This commit is contained in:
parent
3676651e6f
commit
75e87a94eb
5 changed files with 16 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
node_modules
|
||||
bower_components
|
||||
.DS_Store
|
||||
|
|
|
@ -133,6 +133,8 @@ TreeWalker.prototype.previousNode = function () {
|
|||
|
||||
var inlineNodeNames = /^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|FN|EL)|EM|FONT|HR|I(?:NPUT|MG|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:U[BP]|PAN|TR(?:IKE|ONG)|MALL|AMP)?|U|VAR|WBR)$/;
|
||||
|
||||
var editableBlockNodeNames = /^H2$/;
|
||||
|
||||
var leafNodeNames = {
|
||||
BR: 1,
|
||||
IMG: 1,
|
||||
|
@ -179,6 +181,9 @@ function isLeaf ( node ) {
|
|||
function isInline ( node ) {
|
||||
return inlineNodeNames.test( node.nodeName );
|
||||
}
|
||||
function isEditableBlock( node ) {
|
||||
return editableBlockNodeNames.test( node.nodeName );
|
||||
}
|
||||
function isBlock ( node ) {
|
||||
return node.nodeType === ELEMENT_NODE &&
|
||||
!isInline( node ) && every( node.childNodes, isInline );
|
||||
|
@ -1829,7 +1834,7 @@ proto._removeFormat = function ( tag, attributes, range, partial ) {
|
|||
|
||||
// Find block-level ancestor of selection
|
||||
var root = range.commonAncestorContainer;
|
||||
while ( isInline( root ) ) {
|
||||
while ( isInline( root ) || isEditableBlock( root ) ) {
|
||||
root = root.parentNode;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -773,7 +773,7 @@ proto._removeFormat = function ( tag, attributes, range, partial ) {
|
|||
|
||||
// Find block-level ancestor of selection
|
||||
var root = range.commonAncestorContainer;
|
||||
while ( isInline( root ) ) {
|
||||
while ( isInline( root ) || isEditableBlock( root ) ) {
|
||||
root = root.parentNode;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
var inlineNodeNames = /^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|FN|EL)|EM|FONT|HR|I(?:NPUT|MG|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:U[BP]|PAN|TR(?:IKE|ONG)|MALL|AMP)?|U|VAR|WBR)$/;
|
||||
|
||||
var editableBlockNodeNames = /^H2$/;
|
||||
|
||||
var leafNodeNames = {
|
||||
BR: 1,
|
||||
IMG: 1,
|
||||
|
@ -48,6 +50,9 @@ function isLeaf ( node ) {
|
|||
function isInline ( node ) {
|
||||
return inlineNodeNames.test( node.nodeName );
|
||||
}
|
||||
function isEditableBlock( node ) {
|
||||
return editableBlockNodeNames.test( node.nodeName );
|
||||
}
|
||||
function isBlock ( node ) {
|
||||
return node.nodeType === ELEMENT_NODE &&
|
||||
!isInline( node ) && every( node.childNodes, isInline );
|
||||
|
|
Loading…
Reference in a new issue