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.

Usage of Quill modules in angular universal

See original GitHub issue

I have already read all of the content of the following related Issues: #91 and #57.

Error:

When running dev:ssr i get the following error:
ReferenceError: document is not defined

Solutions from above mentioned issues did not help as following.

Code i need to implement

I need to implement the following code to add icons to my custom “undo” and “redo” actions.

const isBrowser = isPlatformBrowser( platformId );
if ( isBrowser ) {
    const icons = Quill.import( 'ui/icons' );
    icons[ 'undo' ] = quillUndoIcon;
    icons[ 'redo' ] = quillRedoIcon;
}

Mocked “document” global in server.ts (not helping)

i have tried mocking the document with domino, but somehow its still saying document is not defined…

const template = fs
  .readFileSync( path.join( join( process.cwd(), 'dist/lebenslauf-generator/browser' ), 'index.html' ) )
  .toString();

// Shim for the global window and document objects.
const window = domino.createWindow( template );
global[ 'window' ] = window;
global[ 'document' ] = window.document;

Usage of quill with require

I have also tried avoiding the quill import by requiring Quill in an if isBrowser statement:

  const Quill = require( 'quill' );
  const icons = Quill.import( 'ui/icons' );
  icons[ 'undo' ] = quillUndoIcon;
  icons[ 'redo' ] = quillRedoIcon;

while this resolved the error on compilation, it broke quill on the client.

What next?

So should i mock a quill component somehow? How would i do that? Could you provide a mocked version for the server or something?

Also i dont quite understand: We would mock the ngx-quill component but i dont think this would fix the problem which is caused by the following import: import Quill from 'quill';

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
KillerCodeMonkeycommented, Feb 28, 2022

Keep in mind to check if you are in browser and the service function is returning an observable you need to subscribe 😉.

0reactions
KillerCodeMonkeycommented, Mar 1, 2022

Feel free to send a pr 😃

Jeremias Nater @.***> schrieb am Di., 1. März 2022, 09:37:

@KillerCodeMonkey https://github.com/KillerCodeMonkey Thanks again! It might be helpful to add a section about how to get the Quill instance in the documentation (maybe specifically at universal, since it doesnt matter if you import it like i did first otherwise)

— Reply to this email directly, view it on GitHub https://github.com/KillerCodeMonkey/ngx-quill/issues/1492#issuecomment-1055159516, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARI4YA6LUQPDSJ4R6EFE7LU5XJM3ANCNFSM5PQWIBGA . You are receiving this because you were mentioned.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ngx-Quill and ImageResize with Angular universal / SSR
import * as QuillNamespace from 'quill'; const Quill: any = QuillNamespace; import ImageResize from 'quill-image-resize-module'; Quill.register( ...
Read more >
ngx-quill - npm
Angular components for the easy use of the QuillJS richt text editor. ... Start using ngx-quill in your project by running `npm i...
Read more >
How to use Quill Editor in Angular Application - YouTube
Angular Editor | how to implement Editor in angular | html editor · Using Redux in Angular 2 + Apps | Mosh ·...
Read more >
ngx-quill-advance - npm Package Health Analysis - Snyk
An angular (>= v2) component for the easy use of the QuillJS rich text editor for v2 For more information about how to...
Read more >
Build a rich text editor in Angular with ngx-quill
Basic Usage · 1. Import QuillModule into your AppModule · 2. Import QuillModule into RichTextEditorModule · 3. Import quill themes CSS into styles....
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