question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Parchment] Unable to create mention blot

See original GitHub issue

I use this module in Quill but error me:

[Parchment] Unable to create mention blot

I used this:

 import mention from 'quill-mention';
Quill.register({
     'modules/mention': mention,
});

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

8reactions
mtimofiivcommented, Dec 31, 2019

This problem is still around. I figured out what goes wrong in my case…

The quill-mention lib tries to import Quill via import Quill from "quill" (https://github.com/afry/quill-mention/blob/master/src/quill.mention.js#L1)

But if you’re using import Quill from 'quill/dist/quill.core' in your app, that’s where it fails.

So this issue is actually rather similar to https://github.com/afry/quill-mention/issues/77

My quick and dirty fix is essentially to do a core-only build of this package, but that’s obviously not ideal.

I would like to offer a suggestion on how to fix this – perhaps don’t self-register with Quill on import and let the developer run Quill.register themselves?

You could potentially export the blot and the module separately and allow the developer to do something like:

import Quill from 'quill'
import { QuillMentionBlot, QuillMentionModule } from 'quill-mention'

Quill.register(QuillMentionBlot)
Quill.register('modules/mention', QuillMentionModule)

This would be a breaking API change for the package, but something to consider. Also possible to export a constructing function that takes Quill as an argument:

import Quill from 'quill'
import QuillMention from 'quill-mention'

QuillMention(Quill)
2reactions
mtimofiivcommented, Jul 23, 2020

@NakedFool I actually ended up doing what @jurgen-reconcept suggests in that thread and clone the package, run npm run build, copy the files in ./dist into your own project and use that. This way, you force the plugin to use the version of Quill you’re using, in your case 2.0.0.

TLDR; explanation:

See, when you create a plugin you need to register it, by running Quill.register(MyPlugin). This is well documented and all but a lot of plugins (like the Emoji one as well) run Quill.register() for you inside their own module.

They do this cause then there’s less boilerplate code for devs wanting to use their plugins, but the downside is that they need to import Quill themselves into their module in order to run its static method. So in this module’s dependencies you’ll find quill@1.3.x and npm resolves this as its own version of Quill, meaning your code runs quill@2.0.0 and this plugin has a different version, quill@1.3.7. Here’s where this goes wrong.

The problem I was having was actually not with 2.0.0 as much as using the quill/core version of Quill. the solution is very similar. Clone the repo, go into src/quill.mention.js and src/blots/mention.js and edit the import Quill from 'quill' to import Quill from 'quill/core'. Do your own build. Copy files from ./dist and viola.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Parchment] Unable to create mention blot · Issue #76 - GitHub
I use this module in Quill but error me: [Parchment] Unable to create mention blot I used this: import mention from 'quill-mention'; ...
Read more >
angular 5 and quilljs [Parchment] Unable to create blot
I was apple to fix my problem with next approach ... declare var Quill: any; const BlockEmbed = Quill.import('blots/embed'); export class ...
Read more >
Quill/Parchment error: Unable to create list-item blot - CodePen
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >
Getting to know QuillJS - Part 1 (Parchment, Blots, and Lifecycle)
When creating a Blot with Parchment.create(blotName) and passing in a sting corresponding to a register blotName , you will always get the ...
Read more >
[Parchment] Unable to create image blot - Bountysource
I'm trying to insert image: import Quill from 'quill/core'; import Toolbar from 'quill/modules/toolbar'; import Snow from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found