Skip to content

Commit

Permalink
Fix enum
Browse files Browse the repository at this point in the history
  • Loading branch information
aavishkarmishra committed Aug 16, 2024
1 parent ee57038 commit 2e45c09
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface QuoteConfig extends ToolConfig {
/**
* Default alignment for the quote.
*/
defaultAlignment: ALIGNMENT;
defaultAlignment: Alignment;
}

/**
Expand All @@ -53,7 +53,7 @@ export interface QuoteData {
/**
* The alignment of the quote.
*/
alignment: ALIGNMENT;
alignment: Alignment;
}

/**
Expand Down Expand Up @@ -113,12 +113,12 @@ interface QuoteCSS {
}

/**
* @typedef {Enum} ALIGNMENT
* @typedef {Enum} Alignment
* @description Enum for Quote Alignment
*/
enum ALIGNMENT {
left = "left",
center = "center",
enum Alignment {
Left = "left",
Center = "center",
}

/**
Expand Down Expand Up @@ -164,7 +164,7 @@ export default class Quote implements BlockTool {
* @param {boolean} params.readOnly - read only mode flag
*/
constructor({ data, config, api, readOnly }: QuoteParams) {
const { ALIGNMENTS, DEFAULT_ALIGNMENT } = Quote;
const { DEFAULT_ALIGNMENT } = Quote;

this.api = api;
this.readOnly = readOnly;
Expand All @@ -178,7 +178,7 @@ export default class Quote implements BlockTool {
text: data.text || "",
caption: data.caption || "",
alignment:
(Object.values(ALIGNMENTS).includes(data.alignment) &&
(Object.values(Alignment).includes(data.alignment as Alignment) &&
data.alignment) ||
config.defaultAlignment ||
DEFAULT_ALIGNMENT,
Expand Down Expand Up @@ -255,27 +255,15 @@ export default class Quote implements BlockTool {
return "Enter a caption";
}

/**
* Allowed quote alignments
*
* @public
* @returns {Record<string, ALIGNMENT> }
*/
static get ALIGNMENTS(): Record<string, ALIGNMENT> {
return {
left: ALIGNMENT.left,
center: ALIGNMENT.center,
};
}

/**
* Default quote alignment
*
* @public
* @returns {string}
*/
static get DEFAULT_ALIGNMENT(): ALIGNMENT {
return Quote.ALIGNMENTS.left;
static get DEFAULT_ALIGNMENT(): Alignment {
return Alignment.Left;
}

/**
Expand Down Expand Up @@ -321,14 +309,14 @@ export default class Quote implements BlockTool {
*
* @returns {*[]}
*/
get settings(): { name: ALIGNMENT; icon: string }[] {
get settings(): { name: Alignment; icon: string }[] {
return [
{
name: ALIGNMENT.left,
name: Alignment.Left,
icon: IconAlignLeft,
},
{
name: ALIGNMENT.center,
name: Alignment.Center,
icon: IconAlignCenter,
},
];
Expand Down Expand Up @@ -420,7 +408,7 @@ export default class Quote implements BlockTool {
* @param {string} tune - alignment
* @private
*/
_toggleTune(tune: ALIGNMENT) {
_toggleTune(tune: Alignment) {
this._data.alignment = tune;
}
}

0 comments on commit 2e45c09

Please sign in to comment.