///
import { Range } from 'quill';
import { Delta, EmitterSource } from 'quill/core';
import type { TranslateFactory } from '../translate/translate-factory';
import RichTextService from './rich-text.service';
import { IComponentController } from 'angular';
import GoogleWebfontsApiService from '../font-selector/google-webfonts-api.service';
export default class RichTextComponentController implements IComponentController {
private $element;
private $rootScope;
private $timeout;
private $q;
private googleWebfontsApiService;
private richTextService;
private translateFactory;
allowColorSelection?: boolean;
allowFontSelection?: boolean;
allowImages?: boolean;
isRequired: boolean;
protected cachedSelection?: Range | null;
protected colorInputId: string;
protected editorSizeId: string;
protected fontSelectorId: string;
protected requiredText: string;
protected selectedColor: string;
protected selectedFont: string;
protected fontWeightOptions: string[];
protected fontWeightOptionsCache: Map;
protected selectedFontWeight: string;
protected toolbarId: string;
protected validationForm: ng.IFormController;
private colorPicker;
private editor;
private linkTargetCheckbox;
private ngModelCtrl;
private debouncedSanitizeAndValidate;
private DEFAULT_COLOR;
private DEFAULT_FONT;
private DEFAULT_SIZE;
private DEFAULT_WEIGHT;
private HEADING_1_COLOR;
private HEADING_1_FONT;
private HEADING_1_SIZE;
private HEADING_2_COLOR;
private HEADING_2_FONT;
private HEADING_2_SIZE;
private UNIVERSAL_FONT_WEIGHTS;
constructor($element: ng.IAugmentedJQuery, $rootScope: JSUIRootScope, $timeout: ng.ITimeoutService, $q: ng.IQService, googleWebfontsApiService: GoogleWebfontsApiService, richTextService: RichTextService, translateFactory: TranslateFactory);
$onChanges(changes: {
isRequired?: ng.IChangesObject;
}): void;
$onDestroy(): void;
$onInit(): void;
$postLink(): void;
private setupLinkTooltipWithTarget;
protected colorChanged(): void;
protected colorInputOpened(): void;
protected fontSelected(fontFamily: string, fontWeightOptions?: string[]): void;
protected fontWeightSelected(fontWeight: string): void;
/** The user entered/deleted/modified some text. Handle any formatting issues, then store the model. */
protected onTextChange(delta: Delta, oldContents: Delta, source: EmitterSource): void;
/** The user moved the cursor. Fix missing formats and update the toolbar to reflect the current selection. */
protected selectionChange(range: Range, _oldRange: Range, source: EmitterSource): void;
private checkValidity;
/**
* Quill's "Clear formatting" button leaves us with no font, size, or color, so the style is inherited from the CSS.
* We don't want that: we want everything to be fully defined, so that the user-entered text can be faithfully
* reproduced elsewhere.
*/
private fixClearFormatting;
/**
* Quill's "Heading 1" and "Heading 2" just change the to
or . The inner will still have a `style` on it,
* setting the font, size, and color. Quill prefers no `style` tags, so it expects the CSS to cover that. We use `style` for
* all our formatting, so we also need to define appropriate values for the Headings.
*/
private fixHeadingFormat;
/**
* Toggling bold/italic/underline clears the font, if the font name contains spaces and ends with digits: https://github.com/slab/quill/issues/4370.
* Spot when that happens and restore the old font(s).
*/
private fixClearedFonts;
/**
* Quill likes to default to no formatting: an empty paragraph has no font, size, or color, so the style is inherited
* from the CSS.
* We don't want that: we want everything to be fully defined, so that the user-entered text can be faithfully
* reproduced elsewhere.
* We try to get the format from the previous line, or fall back to the default.
*/
private fixMissingFormats;
private getColorFromFormat;
private getFontFromFormat;
private getFontWeightFromFormat;
/**
* Scans the entire text and returns an array of objects denoting which font is used for each range.
*/
private getFontRanges;
/**
* If you recently toggled bold/italic/underline with no text selected whilst in a block of text whose font name
* contains spaces and ends in a number, it will have forgotten the font.
* There's no event for the bold/italic/underline toggle, so we detect this when the user types the first letter.
*/
private getRangeOfAddedFontlessText;
private getSizeFromFormat;
/**
* Reapply the old fonts to a given range.
* @returns If the whole range is of the same font, returns that font. Otherwise undefined.
*/
private reinstateMissingFonts;
private sanitizeAndValidate;
/** Updates the color shown in the toolbar. Does not change the color being used in the text. */
private updateColorPicker;
/** Updates the font shown in the toolbar. Does not change the font being used in the text. */
private updateFontPicker;
private updateFontWeightPicker;
/** Updates the size shown in the toolbar. Does not change the size being used in the text. */
private updateSizePicker;
/**
* Caches all available font weights for all provided fonts.
* Sets fontWeightOptions to the weights common to all fonts (Always include normal and bold).
*/
private updateAvailableFontWeights;
}