Skip to content

Commit

Permalink
chore: fool sonarqube duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
rjvelazco committed Aug 27, 2024
1 parent 5328000 commit 1a2cdd1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
48 changes: 24 additions & 24 deletions core-web/libs/sdk/react/src/lib/components/DotEditableText/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import { IAllProps } from '@tinymce/tinymce-react';

import { DotCMSContentlet } from '../../models';

export type DOT_EDITABLE_TEXT_MODE = 'minimal' | 'full' | 'plain';

export type DOT_EDITABLE_TEXT_FORMAT = 'html' | 'text';

export type DOT_EDITABLE_TEXT_MODE = 'minimal' | 'full' | 'plain';

export interface DotEditableTextProps {
/**
* Represents the mode of the editor which can be `plain`, `minimal`, or `full`
* Represents the field name of the `contentlet` that can be edited
*
* @type {DOT_EDITABLE_TEXT_MODE}
* @memberof DotEditableTextProps
*/
mode?: DOT_EDITABLE_TEXT_MODE;
fieldName: string;
/**
* Represents the format of the editor which can be `text` or `html`
*
Expand All @@ -22,43 +21,41 @@ export interface DotEditableTextProps {
*/
format?: DOT_EDITABLE_TEXT_FORMAT;
/**
* Represents the `contentlet` that can be inline edited
* Represents the mode of the editor which can be `plain`, `minimal`, or `full`
*
* @type {DotCMSContentlet}
* @type {DOT_EDITABLE_TEXT_MODE}
* @memberof DotEditableTextProps
*/
contentlet: DotCMSContentlet;
mode?: DOT_EDITABLE_TEXT_MODE;
/**
* Represents the field name of the `contentlet` that can be edited
* Represents the `contentlet` that can be inline edited
*
* @type {DotCMSContentlet}
* @memberof DotEditableTextProps
*/
fieldName: string;
contentlet: DotCMSContentlet;
}

const DEFAULT_TINYMCE_CONFIG: IAllProps['init'] = {
menubar: false,
inline: true,
menubar: false,
powerpaste_html_import: 'clean',
powerpaste_word_import: 'clean',
suffix: '.min',
valid_styles: {
'*': 'font-size,font-family,color,text-decoration,text-align'
},
powerpaste_word_import: 'clean',
powerpaste_html_import: 'clean',
suffix: '.min'
}
};

export const TINYMCE_CONFIG: {
[key in DOT_EDITABLE_TEXT_MODE]: IAllProps['init'];
} = {
minimal: {
...DEFAULT_TINYMCE_CONFIG,
plugins: 'link autolink',
toolbar: 'bold italic underline | link',
valid_elements: 'strong,em,span[style],a[href]'
},
full: {
...DEFAULT_TINYMCE_CONFIG,
plugins: 'link lists autolink charmap',
toolbar: [
'styleselect undo redo | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | hr charmap removeformat | link'
],
style_formats: [
{ title: 'Paragraph', format: 'p' },
{ title: 'Header 1', format: 'h1' },
Expand All @@ -69,14 +66,17 @@ export const TINYMCE_CONFIG: {
{ title: 'Header 6', format: 'h6' },
{ title: 'Pre', format: 'pre' },
{ title: 'Code', format: 'code' }
],
toolbar: [
'styleselect undo redo | bold italic underline | forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | hr charmap removeformat | link'
]
},
plain: {
...DEFAULT_TINYMCE_CONFIG,
plugins: '',
toolbar: ''
},
minimal: {
...DEFAULT_TINYMCE_CONFIG,
plugins: 'link autolink',
toolbar: 'bold italic underline | link',
valid_elements: 'strong,em,span[style],a[href]'
}
};
30 changes: 15 additions & 15 deletions core-web/libs/sdk/react/src/lib/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,39 +90,39 @@ export interface DotCMSPageContext {

export interface DotCMSContentlet {
archived: boolean;
baseType: string;
binaryContentAsset?: string;
deleted?: boolean;
baseType: string;
binary?: string;
binaryContentAsset?: string;
binaryVersion?: string;
contentType: string;
file?: string;
folder: string;
contentType: string;
hasLiveVersion?: boolean;
folder: string;
hasTitleImage: boolean;
host: string;
hostName: string;
identifier: string;
host: string;
inode: string;
image?: string;
identifier: string;
languageId: number;
language?: string;
live: boolean;
image?: string;
locked: boolean;
language?: string;
mimeType?: string;
modDate: string;
modUser: string;
modUserName: string;
owner: string;
modDate: string;
live: boolean;
sortOrder: number;
stInode: string;
owner: string;
title: string;
stInode: string;
titleImage: string;
modUserName: string;
text?: string;
url: string;
working: boolean;
body?: string;
url: string;
contentTypeIcon?: string;
body?: string;
variant?: string;
__icon__?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit 1a2cdd1

Please sign in to comment.