How can I resolve get is not defined of my quilljs function

Published

I want to add MS Word formatting in my quill.js so I find this function

public static updateQuillInstance(quillInstance) {
    quillInstance.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
      return this.msftFormattingMatcher(node, delta);
    });
  }

private static msftFormattingMatcher(node, delta) {
    const htmlElementWithMetadata = node.ownerDocument.activeElement;
    const allOpSpanElementsNested: any[] = get(htmlElementWithMetadata, 'children[0].children', []);
    const allOpSpanElements: any[] = [];
    // superscript styling is nested as a child element unlike the others... need to parse
    for (let i = 0; i < allOpSpanElementsNested.length; i++) {
      if (allOpSpanElementsNested[i].children.length < 1) {
        allOpSpanElements.push(allOpSpanElementsNested[i]);
      } else {
        allOpSpanElements.push(...allOpSpanElementsNested[i].children);
      }
    }

    const op = delta && delta.ops && delta.ops[0];
    if (op) {
      const correspondingSpan = find(allOpSpanElements, el => {
        return op.insert === el.innerText;
      });

      if (correspondingSpan) {
        this.setQuillStyles(op, correspondingSpan);
      }
    }
    return delta;
  }

private static setQuillStyles(op, correspondingSpan) {
    const verticalAlign = correspondingSpan.style.verticalAlign;
    if (verticalAlign === 'super' || verticalAlign === 'sub') {
      assign(op.attributes, {script: verticalAlign});
    }

    const fontFamilyMap = {
      // TODO: This can be automatically built from the whitelist
      Arial: 'arial',
      Georgia: 'georgia',
      'Courier New': 'courier-new',
      'Comic Sans MS': 'comic-sans-ms', // except this one -_-
      Impact: 'impact',
      'Lucida Console': 'lucida-console',
    };
    const fontFamily = correspondingSpan.style.fontFamily;
    const font = fontFamily && fontFamilyMap[fontFamily.replace(/"/gi, '')];
    if (font) {
      assign(op.attributes, {font});
    }
  }

I replace private static and public static by function but when I paste text in my quill.js editor I have the error get is not defined.

Someone have any idea how can I change my code to make it works ?

Source: AngularJS Questions

Published
Categorized as angularjs, javascript, quill Tagged , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq