GithubHelp home page GithubHelp logo

Comments (3)

wlecki avatar wlecki commented on May 22, 2024 1

@suparnavg Yes, I've integrated it pretty easily after all - I should have closed the issue :)

How I did it:
I'm building a bigger portal, that has three different configurations for Quill, depending on where it is used and I needed to customize quill mention module, so I've downloaded source files, modify them, made them exportable, later I created a shared Quill configuration service, so all configurations and Quill itself is initialized only once.

  1. Imports in my service:
import * as QuillNamespace from 'quill';  
const Quill: any = QuillNamespace;
import AutoLinks from 'quill-auto-links';
import Mention from '../../external-modules/quill-mention/quill.mention.js';
import MentionBlot from '../../external-modules/quill-mention/blots/mention.js';
  1. Method initializing Quill and all the modules that is called only once, by e.g. you main component:
registerQuillAdditionalOptions() {
    MentionBlot.blotName = 'mention';
    MentionBlot.tagName = 'span';
    MentionBlot.className = 'mention';
    Quill.register(MentionBlot);
    Quill.register('modules/autoLinks', AutoLinks);
    Quill.register('modules/mention', Mention);
}
  1. In my service, there is couple configurations, so every component that uses Quill and needs something specific, can use this service like this:
<quill-editor
[options]="quillService.chosenConfig">
</quill-editor>

Also, remember that if you specify formats in Quill config, e.g.: formats: ['bold', 'italic', 'underline', 'strike', 'list', 'link', 'mention'],, you HAVE to include 'mention' in the array - otherwise this module won't work.


In your case, if you do not feel the need to modify quill mention, your service could look like this:

import { Injectable } from '@angular/core';

import * as QuillNamespace from 'quill';
const Quill: any = QuillNamespace;
import AutoLinks from 'quill-auto-links';
import 'quill-mention';

@Injectable()
export class QuillConfigService {
    constructor() {}

    registerQuillAdditionalOptions() {
        Quill.register('modules/autoLinks', AutoLinks);
    }

    getGeneralWysiwygConfig() {
        return {
            debug: 'error',
            placeholder: '',
            modules: {
                autoLinks: true,
                mention: {
                    // mention configuration
                },
                toolbar: [
                    ['bold', 'italic', 'underline', 'strike'],
                    [{ list: 'ordered' }, { list: 'bullet' }],
                    ['image', 'video'],
                ],
            },
            formats: [
                'bold',
                'italic',
                'underline',
                'strike',
                'list',
                'link',
                'mention',
            ],
        };
    }
}

And if the styles don't get applied, try in angular-cli.json in styles array add:
"../node_modules/quill-mention/dist/quill.mention.min.css" before your main css file.

from ngx-quill-editor.

suparnavg avatar suparnavg commented on May 22, 2024

@wlecki I'm facing the same issue. Did you find a solution? (I'm trying to integrate quill-mention)

from ngx-quill-editor.

suparnavg avatar suparnavg commented on May 22, 2024

Putting this here in case anyone finds it useful.

In a similar angular-quilljs library, I found the following approach

  1. Install the quill-mention library
  2. In the component where your quill editor is located, include the line import 'quill-mention'; in the imports
  3. Use the example given on the quill-mention page above to add the module in the editorOptions

You should have a working dropdown at this stage, but the css does not seem to get applied. I just took the css from the library and added it to my main styles file - this fixed it!

from ngx-quill-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.