Skip to content
Snippets Groups Projects
MatchingContainerNodeView.js 865 B
Newer Older
chris's avatar
chris committed
import { QuestionsNodeView } from 'wax-prosemirror-core';
chris's avatar
chris committed

export default class MatchingContainerNodeView extends QuestionsNodeView {
  constructor(
    node,
    view,
    getPos,
    decorations,
    createPortal,
    Component,
    context,
  ) {
    super(node, view, getPos, decorations, createPortal, Component, context);

    this.node = node;
    this.outerView = view;
    this.getPos = getPos;
    this.context = context;
  }

  static name() {
    return 'matching_container';
  }

chris's avatar
chris committed
  update(node) {
    if (node.type.name === 'paragraph') {
      if (!node.sameMarkup(this.node)) return false;
    }
    return super.update(node);
  }

chris's avatar
chris committed
  stopEvent(event) {
    if (event.target.type === 'text') {
      return true;
    }
    const innerView = this.context.pmViews[this.node.attrs.id];
    return innerView && innerView.dom.contains(event.target);
  }
}