Skip to content

Commit

Permalink
Adjust typings in headings options (#15833)
Browse files Browse the repository at this point in the history
Other (heading): Adjusted types in heading config options to enable passing the custom heading elements.
  • Loading branch information
Mati365 committed Feb 19, 2024
1 parent 1e76767 commit 83fc67f
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions packages/ckeditor5-heading/src/headingconfig.ts
Expand Up @@ -7,7 +7,8 @@
* @module heading/headingconfig
*/

import type { ViewElementDefinition } from 'ckeditor5/src/engine.js';
import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
import type { MatcherPattern, ViewElementDefinition } from 'ckeditor5/src/engine.js';

/**
* The configuration of the heading feature.
Expand Down Expand Up @@ -72,7 +73,7 @@ export interface HeadingConfig {
/**
* Heading option descriptor.
*/
export type HeadingOption = HeadingElementOption | HeadingParagraphOption;
export type HeadingOption = HeadingElementOption | HeadingParagraphOption | HeadingCustomElementOption;

export interface HeadingElementOption {

Expand Down Expand Up @@ -100,6 +101,44 @@ export interface HeadingElementOption {
* Icon used by {@link module:heading/headingbuttonsui~HeadingButtonsUI}. It can be omitted when using the default configuration.
*/
icon?: string;

/**
* An array with all matched elements that the view-to-model conversion should also accept.
*/
upcastAlso?: ArrayOrItem<ViewElementDefinition | MatcherPattern>;
}

export interface HeadingCustomElementOption {

/**
* Name of the model element to convert.
*/
model: `heading${ string }`;

/**
* Definition of a view element to convert from/to.
*/
view: ViewElementDefinition;

/**
* The user-readable title of the option.
*/
title: string;

/**
* The class which will be added to the dropdown item representing this option.
*/
class: string;

/**
* Icon used by {@link module:heading/headingbuttonsui~HeadingButtonsUI}. It can be omitted when using the default configuration.
*/
icon?: string;

/**
* An array with all matched elements that the view-to-model conversion should also accept.
*/
upcastAlso?: ArrayOrItem<ViewElementDefinition | MatcherPattern>;
}

export interface HeadingParagraphOption {
Expand All @@ -123,4 +162,9 @@ export interface HeadingParagraphOption {
* Icon used by {@link module:heading/headingbuttonsui~HeadingButtonsUI}. It can be omitted when using the default configuration.
*/
icon?: string;

/**
* An array with all matched elements that the view-to-model conversion should also accept.
*/
upcastAlso?: ArrayOrItem<ViewElementDefinition | MatcherPattern>;
}

0 comments on commit 83fc67f

Please sign in to comment.