import { LinkAnnotation } from '../annotations/link-annotation';
import { TextSplittableAction } from './splittable-action.abstract';
import { isNonNullable } from '../../../../types/type-guard';
/**
 * Action to toggle link annotation
 */
export class LinkAnnotationAction extends TextSplittableAction {
  constructor({ link, newText, needMergeNode, doSplit, type, }) {
    super();
    this.isFlushable = true;
    this.link = link;
    this.needMergeNode = needMergeNode;
    this.newText = newText;
    this.type = type;
    if (isNonNullable(doSplit)) {
      this.doSplit = doSplit;
    }
  }
  /**
   * Converts the action to an annotation
   *
   * @returns {LinkAnnotation} the annotation
   */
  toAnnotation() {
    return new LinkAnnotation(this.link);
  }
}
