Skip to content

How to add custom inline blot (or any blot whatsoever)? #118

@falk-stefan

Description

@falk-stefan

I'm getting out of ideas. After trying for an eternity I'd like to ask directly how it's possible to add a blot in Angular.

I want the user to be able to annotate text. Ideally it would be possible to add overlapping annotation but I'd be happy if adding a simple blot would work for a start.

I'm essentially creating an Annotation:

import {InlineBlot} from "parchment";
import * as QuillNamespace from 'quill';
let Quill: any = QuillNamespace;

class Annotation extends InlineBlot {
  blotName = "annotation";
  tagName = "SPAN";
  className = "annotation-class";
  static create(node: Node){
    console.log("CREATE");
    return node;
  }
  static formats() {
    return true as any;
  }
}

Quill.register(Annotation, true);

which I try to add like this:

this.quill.on('selection-change', function(range: RangeStatic) {
  if (range) {
    if (range.length > 0) {
      quill.formatText(range, Annotation.tagName, true);
    }
  }
});

However, nothing really happens. There's nothing crashing but there's nothing added as well.

What am I missing here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions