|
|
@@ -20,12 +20,21 @@ import Element from '../model/element';
|
|
|
* @param {Object} [options]
|
|
|
* @param {Boolean} [options.leaveUnmerged=false] Whether to merge elements after removing the content of the selection.
|
|
|
*
|
|
|
- * For example `<h>x[x</h><p>y]y</p>` will become:
|
|
|
- * * `<h>x^y</h>` with the option disabled (`leaveUnmerged == false`)
|
|
|
- * * `<h>x^</h><p>y</p>` with enabled (`leaveUnmerged == true`).
|
|
|
+ * For example `<heading>x[x</heading><paragraph>y]y</paragraph>` will become:
|
|
|
+ *
|
|
|
+ * * `<heading>x^y</heading>` with the option disabled (`leaveUnmerged == false`)
|
|
|
+ * * `<heading>x^</heading><paragraph>y</paragraph>` with enabled (`leaveUnmerged == true`).
|
|
|
*
|
|
|
* Note: {@link module:engine/model/schema~Schema#objects object} and {@link module:engine/model/schema~Schema#limits limit}
|
|
|
* elements will not be merged.
|
|
|
+ *
|
|
|
+ * @param {Boolean} [options.doNotResetEntireContent=false] Whether to skip replacing the entire content with a
|
|
|
+ * paragraph when the entire content was selected.
|
|
|
+ *
|
|
|
+ * For example `<heading>[x</heading><paragraph>y]</paragraph> will become:
|
|
|
+ *
|
|
|
+ * * `<paragraph>^</paragraph>` with the option disabled (`doNotResetEntireContent == false`)
|
|
|
+ * * `<heading>^</heading>` with enabled (`doNotResetEntireContent == true`).
|
|
|
*/
|
|
|
export default function deleteContent( selection, batch, options = {} ) {
|
|
|
if ( selection.isCollapsed ) {
|
|
|
@@ -34,7 +43,7 @@ export default function deleteContent( selection, batch, options = {} ) {
|
|
|
|
|
|
// 1. Replace the entire content with paragraph.
|
|
|
// See: https://github.com/ckeditor/ckeditor5-engine/issues/1012#issuecomment-315017594.
|
|
|
- if ( shouldEntireContentBeReplacedWithParagraph( batch.document.schema, selection ) ) {
|
|
|
+ if ( !options.doNotResetEntireContent && shouldEntireContentBeReplacedWithParagraph( batch.document.schema, selection ) ) {
|
|
|
replaceEntireContentWithParagraph( batch, selection );
|
|
|
|
|
|
return;
|