Piotrek Koszuliński před 9 roky
rodič
revize
e762c01b98

+ 31 - 1
packages/ckeditor5-engine/src/treemodel/composer/composer.js

@@ -34,8 +34,16 @@ export default class Composer {
 	/**
 	 * See {@link engine.treeModel.composer.deleteContents}.
 	 *
+	 * Note: For the sake of predictability, the resulting selection should always be collapsed.
+	 * In cases where a feature wants to modify deleting behavior so selection isn't collapsed
+	 * (e.g. a table feature may want to keep row selection after pressing <kbd>Backspace</kbd>),
+	 * then that behavior should be implemented in the view's listener. At the same time, the table feature
+	 * will need to modify this method's behavior too, e.g. to "delete contents and then collapse
+	 * the selection inside the last selected cell" or "delete the row and collapse selection somewhere near".
+	 * That needs to be done in order to ensure that other features which use `deleteContents()` work well with tables.
+	 *
 	 * @fires engine.treeModel.composer.Composer#deleteContents
-	 * @param {engine.treeModel.Batch} batch Batch to which the deltas will be added.
+	 * @param {engine.treeModel.Batch} batch Batch to which deltas will be added.
 	 * @param {engine.treeModel.Selection} selection Selection of which the content should be deleted.
 	 */
 	deleteContents( batch, selection ) {
@@ -55,3 +63,25 @@ export default class Composer {
 }
 
 utils.mix( Composer, EmitterMixin );
+
+/**
+ * Event fired when {@link engine.treeModel.composer.Composer#deleteContents} method is called.
+ * The {@link engine.treeModel.composer.deleteContents default action of the composer} is implemented as a
+ * listener to that event so it can be fully customized by the features.
+ *
+ * @event engine.treeModel.composer.Composer#deleteContents
+ * @param {Object} data
+ * @param {engine.treeModel.Batch} data.batch
+ * @param {engine.treeModel.Selection} data.selection
+ */
+
+/**
+ * Event fired when {@link engine.treeModel.composer.Composer#modifySelection} method is called.
+ * The {@link engine.treeModel.composer.modifySelection default action of the composer} is implemented as a
+ * listener to that event so it can be fully customized by the features.
+ *
+ * @event engine.treeModel.composer.Composer#modifySelection
+ * @param {Object} data
+ * @param {engine.treeModel.Selection} data.selection
+ * @param {Object} data.options See {@link engine.treeModel.composer.modifySelection}'s options.
+ */

+ 1 - 1
packages/ckeditor5-engine/src/treemodel/composer/deletecontents.js

@@ -10,7 +10,7 @@ import Position from '../position.js';
 import utils from '../../../utils/utils.js';
 
 /**
- * Delete contents of the selection and merge siblings.
+ * Delete contents of the selection and merge siblings. The resulting selection is always collapsed.
  *
  * @method engine.treeModel.composer.deleteContents
  * @param {engine.treeModel.Batch} batch Batch to which the deltas will be added.