@ckeditor/ckeditor5-font 38.2.0-alpha.0 → 39.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/build/font.js +2 -2
- package/build/translations/ar.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/en-gb.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nb.js +1 -1
- package/build/translations/ne.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sl.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/lang/contexts.json +1 -2
- package/lang/translations/ar.po +0 -4
- package/lang/translations/az.po +0 -4
- package/lang/translations/bg.po +0 -4
- package/lang/translations/bn.po +0 -4
- package/lang/translations/bs.po +0 -4
- package/lang/translations/ca.po +0 -4
- package/lang/translations/cs.po +0 -4
- package/lang/translations/da.po +0 -4
- package/lang/translations/de-ch.po +0 -4
- package/lang/translations/de.po +0 -4
- package/lang/translations/el.po +0 -4
- package/lang/translations/en-au.po +0 -4
- package/lang/translations/en-gb.po +0 -4
- package/lang/translations/en.po +0 -4
- package/lang/translations/es.po +0 -4
- package/lang/translations/et.po +0 -4
- package/lang/translations/fa.po +0 -4
- package/lang/translations/fi.po +0 -4
- package/lang/translations/fr.po +0 -4
- package/lang/translations/gl.po +0 -4
- package/lang/translations/he.po +0 -4
- package/lang/translations/hi.po +0 -4
- package/lang/translations/hr.po +0 -4
- package/lang/translations/hu.po +0 -4
- package/lang/translations/id.po +0 -4
- package/lang/translations/it.po +0 -4
- package/lang/translations/ja.po +0 -4
- package/lang/translations/jv.po +0 -4
- package/lang/translations/ko.po +0 -4
- package/lang/translations/ku.po +0 -4
- package/lang/translations/lt.po +0 -4
- package/lang/translations/lv.po +0 -4
- package/lang/translations/ms.po +0 -4
- package/lang/translations/nb.po +0 -4
- package/lang/translations/ne.po +0 -4
- package/lang/translations/nl.po +0 -4
- package/lang/translations/no.po +0 -4
- package/lang/translations/pl.po +0 -4
- package/lang/translations/pt-br.po +0 -4
- package/lang/translations/pt.po +0 -4
- package/lang/translations/ro.po +0 -4
- package/lang/translations/ru.po +0 -4
- package/lang/translations/sk.po +0 -4
- package/lang/translations/sl.po +0 -4
- package/lang/translations/sq.po +3 -7
- package/lang/translations/sr-latn.po +0 -4
- package/lang/translations/sr.po +0 -4
- package/lang/translations/sv.po +0 -4
- package/lang/translations/th.po +0 -4
- package/lang/translations/tk.po +0 -4
- package/lang/translations/tr.po +0 -4
- package/lang/translations/ug.po +1 -5
- package/lang/translations/uk.po +0 -4
- package/lang/translations/ur.po +0 -4
- package/lang/translations/uz.po +0 -4
- package/lang/translations/vi.po +0 -4
- package/lang/translations/zh-cn.po +0 -4
- package/lang/translations/zh.po +0 -4
- package/package.json +2 -4
- package/src/ui/colorui.d.ts +6 -5
- package/src/ui/colorui.js +19 -17
- package/src/utils.d.ts +13 -12
- package/src/utils.js +13 -14
- package/src/documentcolorcollection.d.ts +0 -70
- package/src/documentcolorcollection.js +0 -42
- package/src/ui/colortableview.d.ts +0 -459
- package/src/ui/colortableview.js +0 -645
- package/theme/fontcolor.css +0 -75
package/src/ui/colorui.js
CHANGED
|
@@ -7,16 +7,17 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core';
|
|
9
9
|
import { createDropdown, normalizeColorOptions, getLocalizedColorOptions, focusChildOnDropdownOpen } from 'ckeditor5/src/ui';
|
|
10
|
-
import {
|
|
10
|
+
import { addColorSelectorToDropdown } from '../utils';
|
|
11
11
|
/**
|
|
12
12
|
* The color UI plugin which isolates the common logic responsible for displaying dropdowns with color grids.
|
|
13
13
|
*
|
|
14
14
|
* It is used to create the `'fontBackgroundColor'` and `'fontColor'` dropdowns, each hosting
|
|
15
|
-
* a {@link module:
|
|
15
|
+
* a {@link module:ui/colorselector/colorselectorview~ColorSelectorView}.
|
|
16
16
|
*/
|
|
17
17
|
export default class ColorUI extends Plugin {
|
|
18
18
|
/**
|
|
19
|
-
* Creates a plugin which introduces a dropdown with a pre–configured
|
|
19
|
+
* Creates a plugin which introduces a dropdown with a pre–configured
|
|
20
|
+
* {@link module:ui/colorselector/colorselectorview~ColorSelectorView}.
|
|
20
21
|
*
|
|
21
22
|
* @param config The configuration object.
|
|
22
23
|
* @param config.commandName The name of the command which will be executed when a color tile is clicked.
|
|
@@ -32,7 +33,7 @@ export default class ColorUI extends Plugin {
|
|
|
32
33
|
this.icon = icon;
|
|
33
34
|
this.dropdownLabel = dropdownLabel;
|
|
34
35
|
this.columns = editor.config.get(`${this.componentName}.columns`);
|
|
35
|
-
this.
|
|
36
|
+
this.colorSelectorView = undefined;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* @inheritDoc
|
|
@@ -52,7 +53,7 @@ export default class ColorUI extends Plugin {
|
|
|
52
53
|
const dropdownView = createDropdown(locale);
|
|
53
54
|
// Font color dropdown rendering is deferred once it gets open to improve performance (#6192).
|
|
54
55
|
let dropdownContentRendered = false;
|
|
55
|
-
this.
|
|
56
|
+
this.colorSelectorView = addColorSelectorToDropdown({
|
|
56
57
|
dropdownView,
|
|
57
58
|
colors: localizedColors.map(option => ({
|
|
58
59
|
label: option.label,
|
|
@@ -66,9 +67,9 @@ export default class ColorUI extends Plugin {
|
|
|
66
67
|
colorPickerLabel: t('Color picker'),
|
|
67
68
|
documentColorsLabel: documentColorsCount !== 0 ? t('Document colors') : '',
|
|
68
69
|
documentColorsCount: documentColorsCount === undefined ? this.columns : documentColorsCount,
|
|
69
|
-
|
|
70
|
+
colorPickerViewConfig: hasColorPicker ? (componentConfig.colorPicker || {}) : false
|
|
70
71
|
});
|
|
71
|
-
this.
|
|
72
|
+
this.colorSelectorView.bind('selectedColor').to(command, 'value');
|
|
72
73
|
dropdownView.buttonView.set({
|
|
73
74
|
label: this.dropdownLabel,
|
|
74
75
|
icon: this.icon,
|
|
@@ -80,7 +81,7 @@ export default class ColorUI extends Plugin {
|
|
|
80
81
|
}
|
|
81
82
|
});
|
|
82
83
|
dropdownView.bind('isEnabled').to(command);
|
|
83
|
-
this.
|
|
84
|
+
this.colorSelectorView.on('execute', (evt, data) => {
|
|
84
85
|
if (dropdownView.isOpen) {
|
|
85
86
|
editor.execute(this.commandName, {
|
|
86
87
|
value: data.value,
|
|
@@ -90,11 +91,14 @@ export default class ColorUI extends Plugin {
|
|
|
90
91
|
if (data.source !== 'colorPicker') {
|
|
91
92
|
editor.editing.view.focus();
|
|
92
93
|
}
|
|
94
|
+
if (data.source === 'colorPickerSaveButton') {
|
|
95
|
+
dropdownView.isOpen = false;
|
|
96
|
+
}
|
|
93
97
|
});
|
|
94
|
-
this.
|
|
98
|
+
this.colorSelectorView.on('colorPicker:show', () => {
|
|
95
99
|
this._undoStepBatch = editor.model.createBatch();
|
|
96
100
|
});
|
|
97
|
-
this.
|
|
101
|
+
this.colorSelectorView.on('colorPicker:cancel', () => {
|
|
98
102
|
if (this._undoStepBatch.operations.length) {
|
|
99
103
|
// We need to close the dropdown before the undo batch.
|
|
100
104
|
// Otherwise, ColorUI treats undo as a selected color change,
|
|
@@ -108,20 +112,18 @@ export default class ColorUI extends Plugin {
|
|
|
108
112
|
dropdownView.on('change:isOpen', (evt, name, isVisible) => {
|
|
109
113
|
if (!dropdownContentRendered) {
|
|
110
114
|
dropdownContentRendered = true;
|
|
111
|
-
dropdownView.
|
|
115
|
+
dropdownView.colorSelectorView.appendUI();
|
|
112
116
|
}
|
|
113
117
|
if (isVisible) {
|
|
114
118
|
if (documentColorsCount !== 0) {
|
|
115
|
-
this.
|
|
119
|
+
this.colorSelectorView.updateDocumentColors(editor.model, this.componentName);
|
|
116
120
|
}
|
|
117
|
-
this.
|
|
118
|
-
|
|
119
|
-
else {
|
|
120
|
-
this.colorTableView.showColorGrids();
|
|
121
|
+
this.colorSelectorView.updateSelectedColors();
|
|
122
|
+
this.colorSelectorView.showColorGridsFragment();
|
|
121
123
|
}
|
|
122
124
|
});
|
|
123
125
|
// Accessibility: focus the first active color when opening the dropdown.
|
|
124
|
-
focusChildOnDropdownOpen(dropdownView, () => dropdownView.
|
|
126
|
+
focusChildOnDropdownOpen(dropdownView, () => dropdownView.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((item) => item.isOn));
|
|
125
127
|
return dropdownView;
|
|
126
128
|
});
|
|
127
129
|
}
|
package/src/utils.d.ts
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module font/utils
|
|
7
7
|
*/
|
|
8
|
-
import ColorTableView from './ui/colortableview';
|
|
9
8
|
import type { FontFamilyOption, FontSizeOption } from './fontconfig';
|
|
10
|
-
import type
|
|
9
|
+
import { ColorSelectorView, type ColorDefinition, type ColorPickerViewConfig, type DropdownView } from 'ckeditor5/src/ui';
|
|
11
10
|
import type { ArrayOrItem } from 'ckeditor5/src/utils';
|
|
12
11
|
import type { ViewAttributeElement, ViewElement, MatcherPattern, ViewElementDefinition, DowncastConversionApi } from 'ckeditor5/src/engine';
|
|
13
12
|
/**
|
|
@@ -55,25 +54,27 @@ export declare function renderUpcastAttribute(styleAttr: string): (viewElement:
|
|
|
55
54
|
*/
|
|
56
55
|
export declare function renderDowncastElement(styleAttr: string): (modelAttributeValue: string, { writer }: DowncastConversionApi) => ViewAttributeElement;
|
|
57
56
|
/**
|
|
58
|
-
* A helper that adds {@link module:
|
|
57
|
+
* A helper that adds {@link module:ui/colorselector/colorselectorview~ColorSelectorView} to the color dropdown with proper initial values.
|
|
59
58
|
*
|
|
60
|
-
* @param config.dropdownView The dropdown view to which a {@link module:
|
|
61
|
-
*
|
|
59
|
+
* @param config.dropdownView The dropdown view to which a {@link module:ui/colorselector/colorselectorview~ColorSelectorView}
|
|
60
|
+
* will be added.
|
|
61
|
+
* @param config.colors An array with definitions representing colors to be displayed in the color selector.
|
|
62
62
|
* @param config.removeButtonLabel The label for the button responsible for removing the color.
|
|
63
63
|
* @param config.documentColorsLabel The label for the section with document colors.
|
|
64
64
|
* @param config.documentColorsCount The number of document colors inside the dropdown.
|
|
65
|
-
* @
|
|
65
|
+
* @param config.colorPickerViewConfig Configuration of the color picker view.
|
|
66
|
+
* @returns The new color selector view.
|
|
66
67
|
*/
|
|
67
|
-
export declare function
|
|
68
|
-
dropdownView:
|
|
68
|
+
export declare function addColorSelectorToDropdown({ dropdownView, colors, columns, removeButtonLabel, colorPickerLabel, documentColorsLabel, documentColorsCount, colorPickerViewConfig }: {
|
|
69
|
+
dropdownView: ColorSelectorDropdownView;
|
|
69
70
|
colors: Array<ColorDefinition>;
|
|
70
71
|
columns: number;
|
|
71
72
|
removeButtonLabel: string;
|
|
72
73
|
colorPickerLabel: string;
|
|
73
74
|
documentColorsLabel?: string;
|
|
74
75
|
documentColorsCount?: number;
|
|
75
|
-
|
|
76
|
-
}):
|
|
77
|
-
export type
|
|
78
|
-
|
|
76
|
+
colorPickerViewConfig: ColorPickerViewConfig | false;
|
|
77
|
+
}): ColorSelectorView;
|
|
78
|
+
export type ColorSelectorDropdownView = DropdownView & {
|
|
79
|
+
colorSelectorView?: ColorSelectorView;
|
|
79
80
|
};
|
package/src/utils.js
CHANGED
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
* @module font/utils
|
|
7
|
-
*/
|
|
8
|
-
import ColorTableView from './ui/colortableview';
|
|
5
|
+
import { ColorSelectorView } from 'ckeditor5/src/ui';
|
|
9
6
|
/**
|
|
10
7
|
* The name of the font size plugin.
|
|
11
8
|
*/
|
|
@@ -66,29 +63,31 @@ export function renderDowncastElement(styleAttr) {
|
|
|
66
63
|
}, { priority: 7 });
|
|
67
64
|
}
|
|
68
65
|
/**
|
|
69
|
-
* A helper that adds {@link module:
|
|
66
|
+
* A helper that adds {@link module:ui/colorselector/colorselectorview~ColorSelectorView} to the color dropdown with proper initial values.
|
|
70
67
|
*
|
|
71
|
-
* @param config.dropdownView The dropdown view to which a {@link module:
|
|
72
|
-
*
|
|
68
|
+
* @param config.dropdownView The dropdown view to which a {@link module:ui/colorselector/colorselectorview~ColorSelectorView}
|
|
69
|
+
* will be added.
|
|
70
|
+
* @param config.colors An array with definitions representing colors to be displayed in the color selector.
|
|
73
71
|
* @param config.removeButtonLabel The label for the button responsible for removing the color.
|
|
74
72
|
* @param config.documentColorsLabel The label for the section with document colors.
|
|
75
73
|
* @param config.documentColorsCount The number of document colors inside the dropdown.
|
|
76
|
-
* @
|
|
74
|
+
* @param config.colorPickerViewConfig Configuration of the color picker view.
|
|
75
|
+
* @returns The new color selector view.
|
|
77
76
|
*/
|
|
78
|
-
export function
|
|
77
|
+
export function addColorSelectorToDropdown({ dropdownView, colors, columns, removeButtonLabel, colorPickerLabel, documentColorsLabel, documentColorsCount, colorPickerViewConfig }) {
|
|
79
78
|
const locale = dropdownView.locale;
|
|
80
|
-
const
|
|
79
|
+
const colorSelectorView = new ColorSelectorView(locale, {
|
|
81
80
|
colors,
|
|
82
81
|
columns,
|
|
83
82
|
removeButtonLabel,
|
|
84
83
|
colorPickerLabel,
|
|
85
84
|
documentColorsLabel,
|
|
86
85
|
documentColorsCount,
|
|
87
|
-
|
|
86
|
+
colorPickerViewConfig
|
|
88
87
|
});
|
|
89
|
-
dropdownView.
|
|
90
|
-
dropdownView.panelView.children.add(
|
|
91
|
-
return
|
|
88
|
+
dropdownView.colorSelectorView = colorSelectorView;
|
|
89
|
+
dropdownView.panelView.children.add(colorSelectorView);
|
|
90
|
+
return colorSelectorView;
|
|
92
91
|
}
|
|
93
92
|
/**
|
|
94
93
|
* Fixes the color value string.
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module font/documentcolorcollection
|
|
7
|
-
*/
|
|
8
|
-
import type { ColorDefinition } from 'ckeditor5/src/ui';
|
|
9
|
-
import { Collection, type CollectionAddEvent, type CollectionRemoveEvent, type CollectionChangeEvent } from 'ckeditor5/src/utils';
|
|
10
|
-
declare const DocumentColorCollection_base: import("ckeditor5/src/utils").Mixed<{
|
|
11
|
-
new (options?: {
|
|
12
|
-
readonly idProperty?: string | undefined;
|
|
13
|
-
} | undefined): Collection<ColorDefinition>;
|
|
14
|
-
new (initialItems: Iterable<ColorDefinition>, options?: {
|
|
15
|
-
readonly idProperty?: string | undefined;
|
|
16
|
-
} | undefined): Collection<ColorDefinition>;
|
|
17
|
-
}, import("ckeditor5/src/utils").Observable>;
|
|
18
|
-
/**
|
|
19
|
-
* A collection to store document colors. It enforces colors to be unique.
|
|
20
|
-
*/
|
|
21
|
-
export default class DocumentColorCollection extends DocumentColorCollection_base {
|
|
22
|
-
/**
|
|
23
|
-
* Indicates whether the document color collection is empty.
|
|
24
|
-
*
|
|
25
|
-
* @observable
|
|
26
|
-
*/
|
|
27
|
-
readonly isEmpty: boolean;
|
|
28
|
-
constructor(options?: any);
|
|
29
|
-
/**
|
|
30
|
-
* Adds a color to the document color collection.
|
|
31
|
-
*
|
|
32
|
-
* This method ensures that no color duplicates are inserted (compared using
|
|
33
|
-
* the color value of the {@link module:ui/colorgrid/colorgridview~ColorDefinition}).
|
|
34
|
-
*
|
|
35
|
-
* If the item does not have an ID, it will be automatically generated and set on the item.
|
|
36
|
-
*
|
|
37
|
-
* @param index The position of the item in the collection. The item is pushed to the collection when `index` is not specified.
|
|
38
|
-
* @fires add
|
|
39
|
-
* @fires change
|
|
40
|
-
*/
|
|
41
|
-
add(item: ColorDefinition, index?: number): this;
|
|
42
|
-
/**
|
|
43
|
-
* Checks if an object with given colors is present in the document color collection.
|
|
44
|
-
*/
|
|
45
|
-
hasColor(color: string): boolean;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Fired when the collection was changed due to adding or removing items.
|
|
49
|
-
*
|
|
50
|
-
* @eventName ~DocumentColorCollection#change
|
|
51
|
-
* @param data Changed items.
|
|
52
|
-
*/
|
|
53
|
-
export type DocumentColorCollectionChangeEvent = CollectionChangeEvent;
|
|
54
|
-
/**
|
|
55
|
-
* Fired when an item is added to the collection.
|
|
56
|
-
*
|
|
57
|
-
* @eventName ~DocumentColorCollection#add
|
|
58
|
-
* @param item The added item.
|
|
59
|
-
* @param index An index where the addition occurred.
|
|
60
|
-
*/
|
|
61
|
-
export type DocumentColorCollectionAddEvent = CollectionAddEvent;
|
|
62
|
-
/**
|
|
63
|
-
* Fired when an item is removed from the collection.
|
|
64
|
-
*
|
|
65
|
-
* @eventName ~DocumentColorCollection#remove
|
|
66
|
-
* @param item The removed item.
|
|
67
|
-
* @param index Index from which item was removed.
|
|
68
|
-
*/
|
|
69
|
-
export type DocumentColorCollectionRemoveEvent = CollectionRemoveEvent;
|
|
70
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
import { Collection, ObservableMixin } from 'ckeditor5/src/utils';
|
|
6
|
-
/**
|
|
7
|
-
* A collection to store document colors. It enforces colors to be unique.
|
|
8
|
-
*/
|
|
9
|
-
export default class DocumentColorCollection extends ObservableMixin((Collection)) {
|
|
10
|
-
constructor(options) {
|
|
11
|
-
super(options);
|
|
12
|
-
this.set('isEmpty', true);
|
|
13
|
-
this.on('change', () => {
|
|
14
|
-
this.set('isEmpty', this.length === 0);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Adds a color to the document color collection.
|
|
19
|
-
*
|
|
20
|
-
* This method ensures that no color duplicates are inserted (compared using
|
|
21
|
-
* the color value of the {@link module:ui/colorgrid/colorgridview~ColorDefinition}).
|
|
22
|
-
*
|
|
23
|
-
* If the item does not have an ID, it will be automatically generated and set on the item.
|
|
24
|
-
*
|
|
25
|
-
* @param index The position of the item in the collection. The item is pushed to the collection when `index` is not specified.
|
|
26
|
-
* @fires add
|
|
27
|
-
* @fires change
|
|
28
|
-
*/
|
|
29
|
-
add(item, index) {
|
|
30
|
-
if (this.find(element => element.color === item.color)) {
|
|
31
|
-
// No duplicates are allowed.
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
return super.add(item, index);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Checks if an object with given colors is present in the document color collection.
|
|
38
|
-
*/
|
|
39
|
-
hasColor(color) {
|
|
40
|
-
return !!this.find(item => item.color === color);
|
|
41
|
-
}
|
|
42
|
-
}
|