You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Static method returning Quill library, format, module, or theme. In general the path should map exactly to Quill source code directory structure.
And the example has a comment that using Quill.import is…
// Similar to ES6 syntax import Link from 'quill/formats/link';
No other discussion is provided regarding exceptions to the "in general". So when I needed to get a non-default export that exists inside the "Quill source code directory structure" at blots/block I guessed I would have to do something like
let { BlockEmbed } = Quill.import('blots/block'); // WRONG
…and the Quill.import internals would have set things up so that all the other exports would be exposed as properties on the Block as default value it returns. But BlockEmbed gets an undefined value; apparently not much similarity to ES import as claimed.
You can view a list of Blots and Attributors available by calling console.log(Quill.imports);. Direct modification of this object is not supported. Use Quill.register instead.
So the secret is that Quill.import actually has very little to do with filesystem paths and ES module syntax, and a whole lot more to do with what calls to Quill.register are made internally. Behold, in quill/core.js I found:
let BlockEmbed = Quill.import('blots/block/embed');
It would have saved me significant time if the API documentation for Quill.import() itself had confessed the connection with Quill.register() and ability to see what Quill.imports exist, instead of conveying the impression that it was more like the real ES module import.
Make it more clear that `Quill.import` is just the read to `Quill.register`'s write, and that the relationship between Quill source code and an object's "path" is simply a convention.
I wrote this assuming that `Quill.imports` is internal API but since it was already mentioned elsewhere in the public docs it seemed fitting to share a similar tip here.
The API documentation for Quill.import is misleading (emphasis mine):
And the example has a comment that using
Quill.import
is…No other discussion is provided regarding exceptions to the "in general". So when I needed to get a non-default export that exists inside the "Quill source code directory structure" at
blots/block
I guessed I would have to do something like…and the
Quill.import
internals would have set things up so that all the other exports would be exposed as properties on theBlock as default
value it returns. ButBlockEmbed
gets an undefined value; apparently not much similarity to ESimport
as claimed.Elsewhere in the documentation, I found a more helpful note:
So the secret is that
Quill.import
actually has very little to do with filesystem paths and ES module syntax, and a whole lot more to do with what calls toQuill.register
are made internally. Behold, in quill/core.js I found:As it turns out, my code should actually be:
It would have saved me significant time if the API documentation for
Quill.import()
itself had confessed the connection withQuill.register()
and ability to see whatQuill.imports
exist, instead of conveying the impression that it was more like the real ES moduleimport
.Related: #2659
The text was updated successfully, but these errors were encountered: