Skip to content
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
17 changes: 17 additions & 0 deletions build/squire-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,15 @@ var handleEnter = function ( self, shiftKey, range ) {

block = getStartBlockOfRange( range, root );

// If the block is begining with CHECKBOX,
// the splitted next line should begin with CHECKBOX.
var beginingCheckbox = (
block.firstChild.nodeName == 'SPAN' &&
!block.firstChild.isContentEditable &&
block.firstChild.firstChild.nodeName == 'INPUT' &&
block.firstChild.firstChild.getAttribute('TYPE') == 'checkbox'
) && block.firstChild.cloneNode(true) || null;

// Inside a PRE, insert literal newline, unless on blank line.
if ( block && ( parent = getNearest( block, root, 'PRE' ) ) ) {
moveRangeBoundariesDownTree( range );
Expand Down Expand Up @@ -1511,6 +1520,14 @@ var handleEnter = function ( self, shiftKey, range ) {
nodeAfterSplit = splitBlock( self, block,
range.startContainer, range.startOffset );

// If the block is begining with CHECKBOX,
// the splitted next line should begin with CHECKBOX,
// and the cursor should located at the next to the CHECKBOX.
if (beginingCheckbox) {
nodeAfterSplit.prepend(beginingCheckbox);
nodeAfterSplit = nodeAfterSplit.firstChild.nextSibling;
}

// Clean up any empty inlines if we hit enter at the beginning of the
// block
removeZWS( block );
Expand Down
4 changes: 2 additions & 2 deletions build/squire.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "squire-rte",
"version": "1.10.2-1",
"version": "1.10.2-2",
"description": "Squire is an HTML5 rich text editor, which provides powerful cross-browser normalisation, whilst being supremely lightweight and flexible.",
"main": "build/squire.js",
"scripts": {
Expand Down
17 changes: 17 additions & 0 deletions source/KeyHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ var handleEnter = function ( self, shiftKey, range ) {

block = getStartBlockOfRange( range, root );

// If the block is begining with CHECKBOX,
// the splitted next line should begin with CHECKBOX.
var beginingCheckbox = (
block.firstChild.nodeName == 'SPAN' &&
!block.firstChild.isContentEditable &&
block.firstChild.firstChild.nodeName == 'INPUT' &&
block.firstChild.firstChild.getAttribute('TYPE') == 'checkbox'
) && block.firstChild.cloneNode(true) || null;

// Inside a PRE, insert literal newline, unless on blank line.
if ( block && ( parent = getNearest( block, root, 'PRE' ) ) ) {
moveRangeBoundariesDownTree( range );
Expand Down Expand Up @@ -256,6 +265,14 @@ var handleEnter = function ( self, shiftKey, range ) {
nodeAfterSplit = splitBlock( self, block,
range.startContainer, range.startOffset );

// If the block is begining with CHECKBOX,
// the splitted next line should begin with CHECKBOX,
// and the cursor should located at the next to the CHECKBOX.
if (beginingCheckbox) {
nodeAfterSplit.prepend(beginingCheckbox);
nodeAfterSplit = nodeAfterSplit.firstChild.nextSibling;
}

// Clean up any empty inlines if we hit enter at the beginning of the
// block
removeZWS( block );
Expand Down