"Facing difficulties in personalizing the PrimeNG Quill Editor within an Angular environment

In my Angular 7 project, I am utilizing the PrimeNG Editor (based on Quill) and I have a need to customize the toolbar. Despite experimenting with various configuration options in both HTML and JavaScript, the only modification I have been able to make is adjusting the placeholder property via HTML. Here is my approach, where I defined the Editor as a custom control:

#FormComponent.ts:

public controlDescription = new ControlEditor({
    key: 'Description',
    label: 'Description',
    required: true
});

this.controls = [this.controlDescription, ... ];


#FormComponent.html:

<div comp-dynamic-control [form]="form" [control]="controlDescription"></div>


#ControlEditor.html:

<p-editor [formControlName]="control.key" placeholder='Compose text...'></p-editor>


I also attempted to directly use the Editor (without our Custom Editor) by adding the following code in FormComponent.html. However, despite importing import {EditorModule} from 'primeng/editor'; into the ControlEditor.ts file, the editor does not appear on the page. Any suggestions?

<p-editor formControlName="description" [style]="{'height':'320px'}"></p-editor>

Answer №1

In my experience with Angular 9, I found that customization only worked when I supplied the formats property with a string array containing all the desired formats (buttons). Additionally, the buttons needed to be included in the HTML page within p-header tags, which should be nested within the p-editor tags as shown below:

<p-editor [(ngModel)]="value" [style]="{'height':'100px'}" formats="formats">
    <p-header>
       <span class="ql-formats">
        <button class="ql-bold" aria-label="Bold"></button>
        <button class="ql-italic" aria-label="Italic"></button>
       </span>
    </p-header>
</p-editor>

To make the bold and italic buttons appear, I also had to declare them in a string array within the typescript file like this:

formats: string[] = ['bold', 'italic'];

You can find additional formatting options here:

Remember to add formats="formats" to the first p-editor tag.

Answer №2

Make sure you import the Editor module at the Module level, not within a component's ts file.

App.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';

import {EditorModule} from 'primeng/editor';


@NgModule({
  imports:      [ BrowserModule, FormsModule, EditorModule ],
  declarations: [ AppComponent],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

I hope this solution solves your issue!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is preventing Ionic from locating my model interface?

I recently started working with Ionic and I am using a tutorial as a guide to integrate Firebase authentication into my project. However, I am encountering an issue with the user interface that is being generated. When I run ionic serve for the first time ...

Search for records in MySQL using Typeorm with the condition "column like %var%" to retrieve results containing the specified

Looking for a way to search in MySql using typeorm with the "column like" functionality. async findAll({ page, count, ...where }: CategorySelectFilter): Promise<Category[]> { return this.categoryRepository.find({ where, ...

In TypeScript, specifying that a type should only extend from an object does not effectively prevent strings from being accepted

My goal is to ensure proper typing for an attributes object that is stored in a wrapper class. This is necessary to maintain correct typing when accessing or setting individual attributes using the getOne/setOne methods as shown below. However, I am facin ...

Tips for effectively invoking an API within a Next.js application

I've been exploring the most effective method for calling an external API within a Next.js application recently. Given my experience in developing MERN stack applications, I typically rely on axios for handling API requests and utilize it within a use ...

Angular5: Dealing with View Encapsulation Problems

When applying CSS to child components called from a parent component using the ViewEncapsulation.None trick, everything seems to work fine. However, when navigating to other routes or pages, the styles of the component with ViewEncapsulation.None are stran ...

Subtracted TypeScript concept

Is it possible to create a modified type in Typescript for React components? import {Component, ComponentType} from 'react'; export function connect<S, A>(state: () => S, actions: A){ return function createConnected<P>(componen ...

Testing the service in Angular that has multiple dependencies using unit tests

I am seeking guidance on testing the functionality of the Service below, which requires two dependencies in its constructor. I am unsure how to set up the testing environment and how to incorporate MatDialog in the testing process. Should simulated reque ...

The state of an Angular 4 component

I am currently working on an Angular 4 application that consists of two components, CompA and CompB. CompA fetches books using an http service and displays them in a table, while CompB shows static data. When navigating between these components, I notice ...

Utilizing an Angular Service within the main.ts script

My main.ts file currently has the following code snippet: declare const require; const translations = require("raw-loader!./locale/messages.de.xlf"); platformBrowserDynamic().bootstrapModule(AppModule, { providers: [ { provide: TRANSLATIONS, useVa ...

Creating synchronous behavior using promises in Javascript

Currently, I am working with Ionic2/Typescript and facing an issue regarding synchronization of two Promises. I need both Promises to complete before proceeding further in a synchronous manner. To achieve this, I have placed the calls to these functions in ...

Can icons with an external path be utilized as a src in the manifest.json file within an Angular application?

Let's visualize the setup with two projects - project1 and project2. Each project has its own manifest.json file and the same apple-touch-icon-144x144.png file located in assets/icons directory. -project2 |_src | |_assets | | |_icons | | ...

What is the best way to preserve a web response in a file?

I am currently facing an issue with saving a JSON web response in a file. Although I am able to successfully create and save the file, the content of the web response is not being captured. The file only contains: [object Object] Below is my component cod ...

The error message "karma jasmine cannot subscribe to an undefined property" is displayed due to the inability to

I'm trying to create a test for this get function, but every time I attempt to do so, I encounter the error message "TypeError: Cannot read property 'subscribe' of undefined" This is my service function: getAPICard(): Observable<any> ...

Retrieve a multitude of nested Records within the returnType that correlate with the number of arguments provided to the function

My goal is to dynamically define a deeply nested ReturnType for a function based on the number of arguments passed in the "rest" parameter. For example, if we have: getFormattedDates( dates: Date[], ...rest: string[] // ['AAA', 'BBB&apos ...

Facing an issue with the TypeScript error in the Tailwind-Styled-Component Npm package. Any suggestions on how to troub

module.styles.ts File import tw from "tailwind-styled-components"; export const Wrapper = tw.div` bg-green-500 `; export const Link = tw.a` text-blue-500 `; home.jsx File import React from "react"; import { Wrapper, Link } from &qu ...

Utilizing ES6 Promises in Mongoose with Typescript to Create a Seamless Chain

When attempting to chain ES6 promises with Mongoose 4.5.4, I encountered an error in Typescript. public static signup(req: express.Request, res: express.Response) { UserModel.findOne({ email: req.body.email }).exec() .then(existingUser => { ...

NestJS: Specify the data type for @Body()

Consider the code snippet below: @Post() public async createPet(@Body() petDetails: PostPetDto): Promise<any> { } In this scenario, the type of @Bod() petDetails defaults to plain/any instead of the declared type of PostPetDto. What is the recommen ...

I'm attempting to showcase the keyName and pattern for the arrays of Objects in Keyless and Keypresent in AngularJS, but unfortunately, I'm facing some issues

let information = { headerFields: { noKey: [{ key1: { name: "test1" }, key2: { name: "test2" }, key3: { name: "test3" } }], hasKey: [{ key1: { name: "test4" } ...

Troubleshooting problem with @Input number in Angular 2

Here is the component in question: <component value="3"></component> This is the code for the component: private _value:number; get value(): number { return this._value; } @Input() set value(value: number) { console.log(v ...

Error message received: "ReferenceError: document is not defined when attempting to utilize Angular 8 NgxUsefulSwiper

The NgxUsefulSwiper library is being used in a component and works fine on the local environment. However, upon trying to access the page with the component on the development environment, the following error occurs: ReferenceError: document is not defin ...