KillerCodeMonkey / ngx-quill

Angular (>=2) components for the Quill Rich Text Editor
MIT License
1.79k stars 262 forks source link

Cannot register a BlockBlot #1854

Closed rick2ricks closed 6 months ago

rick2ricks commented 6 months ago

Hi,

I am not sure if I am missing somthing, but the following shouldn't work?

//This returns unkown:
const Block = Quill.import('blots/block');

class DivBlot extends Block {
  static blotName = 'div';
  static tagName = 'div';
}

Quill.register(DivBlot);

How else should I extend and register a BlockBlot after upgrading to quill@2 and ngx-quill@25.

Thank you.

KillerCodeMonkey commented 6 months ago

This should work. There is an example in the Demo repo if I remember it correctly.

But you need to pass true as second Parameter to override an existing blot.

Am 16. Mai 2024 23:19:42 MESZ schrieb rick2ricks @.***>:

Hi,

I am not sure if I am missing somthing, but the following shouldn't work?

//This returns unkown:
const Block = Quill.import('blots/block');

class DivBlot extends Block {
 static blotName = 'div';
 static tagName = 'div';
}

Quill.register(DivBlot);

How else should I extend and register a BlockBlot after upgrading to @. and @.

Thank you.

-- Reply to this email directly or view it on GitHub: https://github.com/KillerCodeMonkey/ngx-quill/issues/1854 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

KillerCodeMonkey commented 6 months ago

see: https://github.com/quilljs/quill/blob/9f4e18540de93e8dec7cb7f53d8d0493714b7a09/packages/quill/src/core/quill.ts#L124

rick2ricks commented 6 months ago

Thanks for the response, but the problem starts before the register, when trying to extend Block, because Quill.import('blots/block') returns unkown.

Also I could not find any references to extending a Blot or using Quill.register in any examples.

KillerCodeMonkey commented 6 months ago

just checked the quilljs repo and tried this:

import Block from 'quill/blots/block';

Block.tagName = "DIV";
Quill.register(Block, true);

it is working

Edit: committed it to the demo repo and deployed the new version

rick2ricks commented 6 months ago

Don't know why I didn't find this import before.

import Block from 'quill/blots/block';"

Thank you.