Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
falk-stefan opened this issue Jul 30, 2022 · 2 comments
Open

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

falk-stefan opened this issue Jul 30, 2022 · 2 comments

Comments

@falk-stefan
Copy link

falk-stefan commented Jul 30, 2022

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?

@ramarivera
Copy link

Absolutely late to the party, but since your blot is using both a tag and class name, I believe you need to use both somehow.

I had some experience with embeds, and for those there is a special method.

Did you manage to solve this somehow? If not, I could try to take a look :)

@ramarivera
Copy link

https://quilljs.com/guides/cloning-medium-with-parchment/

I'm theory you should use blot name, not tag name I think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants