import { InsertNewParagraphAction } from '../../actions/insert-new-paragraph-action';
import { ActionHandleStrategy } from '../action-handle-strategy.abstract';
/**
 * The image block insert line break strategy.
 */
export class ImageInsertLineBreakStrategy extends ActionHandleStrategy {
  /**
   * The image block not support insert the line break node, so invoke the insert new paragraph logic directly.
   *
   * @param {LineBreakSingleBlockAction} action - The action instance.
   * @param {RTEImageBlock} target - The image block.
   */
  handleAction(action, target) {
    const insertNewParagraphAction = new InsertNewParagraphAction(action.startContainerNode, action.startOffset);
    target.apply(insertNewParagraphAction);
    const newBlock = insertNewParagraphAction.newBlock;
    if (newBlock) {
      action.lineBreakNode = newBlock.children[0];
    }
  }
}
