Skip to content

Commit

Permalink
Merge pull request #16378 from ckeditor/add-pure-comments-before-obje…
Browse files Browse the repository at this point in the history
…cts-and-arrays-in-global-scope

Other: Add `#__PURE__` comments before objects and arrays in global scope. Related to #16292.
  • Loading branch information
filipsobol committed May 20, 2024
2 parents 3f8edce + 65f79e7 commit 657feb1
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 64 deletions.
4 changes: 2 additions & 2 deletions packages/ckeditor5-alignment/src/alignmentui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import { isSupported, normalizeAlignmentOptions } from './utils.js';
import type { AlignmentFormat, SupportedOption } from './alignmentconfig.js';
import type AlignmentCommand from './alignmentcommand.js';

const iconsMap = new Map( [
const iconsMap = /* #__PURE__ */ ( () => new Map( [
[ 'left', icons.alignLeft ],
[ 'right', icons.alignRight ],
[ 'center', icons.alignCenter ],
[ 'justify', icons.alignJustify ]
] );
] ) )();

/**
* The default alignment UI plugin.
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-heading/src/headingbuttonsui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import { getLocalizedOptions } from './utils.js';
import type { HeadingOption } from './headingconfig.js';
import type HeadingCommand from './headingcommand.js';

const defaultIcons: Record<string, string> = {
const defaultIcons: Record<string, string> = /* #__PURE__ */ ( () => ( {
heading1: icons.heading1,
heading2: icons.heading2,
heading3: icons.heading3,
heading4: icons.heading4,
heading5: icons.heading5,
heading6: icons.heading6
};
} ) )();

/**
* The `HeadingButtonsUI` plugin defines a set of UI buttons that can be used instead of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import ImageResizeEditing from './imageresizeediting.js';
import type ResizeImageCommand from './resizeimagecommand.js';
import type { ImageResizeOption } from '../imageconfig.js';

const RESIZE_ICONS = {
const RESIZE_ICONS = /* #__PURE__ */ ( () => ( {
small: icons.objectSizeSmall,
medium: icons.objectSizeMedium,
large: icons.objectSizeLarge,
custom: icons.objectSizeCustom,
original: icons.objectSizeFull
};
} ) )();

/**
* The image resize buttons plugin.
Expand Down
41 changes: 17 additions & 24 deletions packages/ckeditor5-image/src/imagestyle/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import { type Editor, icons, type PluginCollection } from 'ckeditor5/src/core.js
import { logWarning } from 'ckeditor5/src/utils.js';
import type { ImageStyleConfig, ImageStyleDropdownDefinition, ImageStyleOptionDefinition } from '../imageconfig.js';

const {
objectFullWidth,
objectInline,
objectLeft, objectRight, objectCenter,
objectBlockLeft, objectBlockRight
} = icons;

/**
* Default image style options provided by the plugin that can be referred in the {@link module:image/imageconfig~ImageConfig#styles}
* configuration.
Expand All @@ -42,7 +35,7 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
return {
name: 'inline',
title: 'In line',
icon: objectInline,
icon: icons.objectInline,
modelElements: [ 'imageInline' ],
isDefault: true
};
Expand All @@ -53,7 +46,7 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
return {
name: 'alignLeft',
title: 'Left aligned image',
icon: objectLeft,
icon: icons.objectLeft,
modelElements: [ 'imageBlock', 'imageInline' ],
className: 'image-style-align-left'
};
Expand All @@ -64,7 +57,7 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
return {
name: 'alignBlockLeft',
title: 'Left aligned image',
icon: objectBlockLeft,
icon: icons.objectBlockLeft,
modelElements: [ 'imageBlock' ],
className: 'image-style-block-align-left'
};
Expand All @@ -75,7 +68,7 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
return {
name: 'alignCenter',
title: 'Centered image',
icon: objectCenter,
icon: icons.objectCenter,
modelElements: [ 'imageBlock' ],
className: 'image-style-align-center'
};
Expand All @@ -86,7 +79,7 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
return {
name: 'alignRight',
title: 'Right aligned image',
icon: objectRight,
icon: icons.objectRight,
modelElements: [ 'imageBlock', 'imageInline' ],
className: 'image-style-align-right'
};
Expand All @@ -97,7 +90,7 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
return {
name: 'alignBlockRight',
title: 'Right aligned image',
icon: objectBlockRight,
icon: icons.objectBlockRight,
modelElements: [ 'imageBlock' ],
className: 'image-style-block-align-right'
};
Expand All @@ -108,7 +101,7 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
return {
name: 'block',
title: 'Centered image',
icon: objectCenter,
icon: icons.objectCenter,
modelElements: [ 'imageBlock' ],
isDefault: true
};
Expand All @@ -119,7 +112,7 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
return {
name: 'side',
title: 'Side image',
icon: objectRight,
icon: icons.objectRight,
modelElements: [ 'imageBlock' ],
className: 'image-style-side'
};
Expand All @@ -134,15 +127,15 @@ export const DEFAULT_OPTIONS: Record<string, ImageStyleOptionDefinition> = {
*
* There are 7 default icons available: `'full'`, `'left'`, `'inlineLeft'`, `'center'`, `'right'`, `'inlineRight'`, and `'inline'`.
*/
export const DEFAULT_ICONS: Record<string, string> = {
full: objectFullWidth,
left: objectBlockLeft,
right: objectBlockRight,
center: objectCenter,
inlineLeft: objectLeft,
inlineRight: objectRight,
inline: objectInline
};
export const DEFAULT_ICONS: Record<string, string> = /* #__PURE__ */ ( () => ( {
full: icons.objectFullWidth,
left: icons.objectBlockLeft,
right: icons.objectBlockRight,
center: icons.objectCenter,
inlineLeft: icons.objectLeft,
inlineRight: icons.objectRight,
inline: icons.objectInline
} ) )();

/**
* Default drop-downs provided by the plugin that can be referred in the {@link module:image/imageconfig~ImageConfig#toolbar}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ import '../../../theme/form.css';
import '../../../theme/tableform.css';
import '../../../theme/tablecellproperties.css';

const ALIGNMENT_ICONS = {
left: icons.alignLeft,
center: icons.alignCenter,
right: icons.alignRight,
justify: icons.alignJustify,
top: icons.alignTop,
middle: icons.alignMiddle,
bottom: icons.alignBottom
};

export interface TableCellPropertiesViewOptions {
borderColors: Array<NormalizedColorOption>;
backgroundColors: Array<NormalizedColorOption>;
Expand Down Expand Up @@ -716,6 +706,16 @@ export default class TableCellPropertiesView extends View {

const alignmentLabel = new LabelView( locale );

const ALIGNMENT_ICONS = {
left: icons.alignLeft,
center: icons.alignCenter,
right: icons.alignRight,
justify: icons.alignJustify,
top: icons.alignTop,
middle: icons.alignMiddle,
bottom: icons.alignBottom
};

alignmentLabel.text = t( 'Table cell text alignment' );

// -- Horizontal ---------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ import '../../../theme/tableproperties.css';
import type ColorInputView from '../../ui/colorinputview.js';
import type { TablePropertiesOptions } from '../../tableconfig.js';

const ALIGNMENT_ICONS = {
left: icons.objectLeft,
center: icons.objectCenter,
right: icons.objectRight
};

/**
* Additional configuration of the view.
*/
Expand Down Expand Up @@ -661,7 +655,11 @@ export default class TablePropertiesView extends View {

fillToolbar( {
view: this,
icons: ALIGNMENT_ICONS,
icons: {
left: icons.objectLeft,
center: icons.objectCenter,
right: icons.objectRight
},
toolbar: alignmentToolbar,
labels: this._alignmentLabels,
propertyName: 'alignment',
Expand Down
20 changes: 9 additions & 11 deletions packages/ckeditor5-table/src/utils/ui/contextualballoon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ import type { Element, Position, Range } from 'ckeditor5/src/engine.js';
import { getSelectionAffectedTableWidget, getTableWidgetAncestor } from './widget.js';
import { getSelectionAffectedTable } from '../common.js';

const DEFAULT_BALLOON_POSITIONS = BalloonPanelView.defaultPositions;

const BALLOON_POSITIONS = [
DEFAULT_BALLOON_POSITIONS.northArrowSouth,
DEFAULT_BALLOON_POSITIONS.northArrowSouthWest,
DEFAULT_BALLOON_POSITIONS.northArrowSouthEast,
DEFAULT_BALLOON_POSITIONS.southArrowNorth,
DEFAULT_BALLOON_POSITIONS.southArrowNorthWest,
DEFAULT_BALLOON_POSITIONS.southArrowNorthEast,
DEFAULT_BALLOON_POSITIONS.viewportStickyNorth
];
const BALLOON_POSITIONS = /* #__PURE__ */ ( () => [
BalloonPanelView.defaultPositions.northArrowSouth,
BalloonPanelView.defaultPositions.northArrowSouthWest,
BalloonPanelView.defaultPositions.northArrowSouthEast,
BalloonPanelView.defaultPositions.southArrowNorth,
BalloonPanelView.defaultPositions.southArrowNorthWest,
BalloonPanelView.defaultPositions.southArrowNorthEast,
BalloonPanelView.defaultPositions.viewportStickyNorth
] )();

/**
* A helper utility that positions the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import type { FocusableView } from '../focuscycler.js';
import type { ColorSelectorExecuteEvent, ColorSelectorColorPickerShowEvent } from './colorselectorview.js';
import { icons } from '@ckeditor/ckeditor5-core';

const { eraser: removeButtonIcon, colorPalette: colorPaletteIcon } = icons;

/**
* One of the fragments of {@link module:ui/colorselector/colorselectorview~ColorSelectorView}.
*
Expand Down Expand Up @@ -334,7 +332,7 @@ export default class ColorGridsFragmentView extends View {
this.colorPickerButtonView.set( {
label: this._colorPickerLabel,
withText: true,
icon: colorPaletteIcon,
icon: icons.colorPalette,
class: 'ck-color-selector__color-picker'
} );

Expand All @@ -351,7 +349,7 @@ export default class ColorGridsFragmentView extends View {

buttonView.set( {
withText: true,
icon: removeButtonIcon,
icon: icons.eraser,
label: this._removeButtonLabel
} );

Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-ui/src/toolbar/toolbarview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { isObject } from 'lodash-es';

import '../../theme/components/toolbar/toolbar.css';

export const NESTED_TOOLBAR_ICONS: Record<string, string | undefined> = {
export const NESTED_TOOLBAR_ICONS: Record<string, string | undefined> = /* #__PURE__ */ ( () => ( {
alignLeft: icons.alignLeft,
bold: icons.bold,
importExport: icons.importExport,
Expand All @@ -55,7 +55,7 @@ export const NESTED_TOOLBAR_ICONS: Record<string, string | undefined> = {
threeVerticalDots: icons.threeVerticalDots,
pilcrow: icons.pilcrow,
dragIndicator: icons.dragIndicator
};
} ) )();

/**
* The toolbar view class.
Expand Down

0 comments on commit 657feb1

Please sign in to comment.