|
@@ -56,7 +56,10 @@ function enterBlock( model, writer, selection, schema ) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ( isSelectionEmpty ) {
|
|
if ( isSelectionEmpty ) {
|
|
|
|
|
+ // List of text attributes copied to new line/block.
|
|
|
|
|
+ const filteredAttr = getAllowedAttributes( writer.model.schema, selection.getAttributes() );
|
|
|
splitBlock( writer, range.start );
|
|
splitBlock( writer, range.start );
|
|
|
|
|
+ writer.setSelectionAttribute( filteredAttr );
|
|
|
} else {
|
|
} else {
|
|
|
const leaveUnmerged = !( range.start.isAtStart && range.end.isAtEnd );
|
|
const leaveUnmerged = !( range.start.isAtStart && range.end.isAtEnd );
|
|
|
const isContainedWithinOneElement = ( startElement == endElement );
|
|
const isContainedWithinOneElement = ( startElement == endElement );
|
|
@@ -84,3 +87,11 @@ function splitBlock( writer, splitPos ) {
|
|
|
writer.split( splitPos );
|
|
writer.split( splitPos );
|
|
|
writer.setSelection( splitPos.parent.nextSibling, 0 );
|
|
writer.setSelection( splitPos.parent.nextSibling, 0 );
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+function* getAllowedAttributes( schema, allAttributes ) {
|
|
|
|
|
+ for ( const attr of allAttributes ) {
|
|
|
|
|
+ if ( attr && schema.getAttributeProperties( attr[ 0 ] ).copyOnEnter ) {
|
|
|
|
|
+ yield attr;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|