Browse Source

Add ColorPickerOptions interface

pull/5716/head
Artur Arseniev 2 years ago
parent
commit
b5859fe69d
  1. 4
      src/editor/config/config.ts
  2. 40
      src/utils/ColorPicker.ts

4
src/editor/config/config.ts

@ -22,6 +22,7 @@ import { DomComponentsConfig } from '../../dom_components/config/config';
import { HTMLGeneratorBuildOptions } from '../../code_manager/model/HtmlGenerator'; import { HTMLGeneratorBuildOptions } from '../../code_manager/model/HtmlGenerator';
import { CssGeneratorBuildOptions } from '../../code_manager/model/CssGenerator'; import { CssGeneratorBuildOptions } from '../../code_manager/model/CssGenerator';
import { ObjectAny } from '../../common'; import { ObjectAny } from '../../common';
import { ColorPickerOptions } from '../../utils/ColorPicker';
export interface EditorConfig { export interface EditorConfig {
/** /**
@ -415,10 +416,11 @@ export interface EditorConfig {
*/ */
customUI?: boolean; customUI?: boolean;
el?: HTMLElement; el?: HTMLElement;
/** /**
* Color picker options. * Color picker options.
*/ */
colorPicker?: ObjectAny; colorPicker?: ColorPickerOptions;
pStylePrefix?: string; pStylePrefix?: string;
} }

40
src/utils/ColorPicker.ts

@ -7,11 +7,49 @@
// License: MIT // License: MIT
import { hasWin } from './mixins'; import { hasWin } from './mixins';
export interface ColorPickerOptions {
beforeShow?: () => void;
move?: () => void;
change?: () => void;
show?: () => void;
hide?: () => void;
color?: boolean;
flat?: boolean;
showInput?: boolean;
allowEmpty?: boolean;
showButtons?: boolean;
clickoutFiresChange?: boolean;
showInitial?: boolean;
showPalette?: boolean;
showPaletteOnly?: boolean;
hideAfterPaletteSelect?: boolean;
togglePaletteOnly?: boolean;
showSelectionPalette?: boolean;
localStorageKey?: boolean;
appendTo?: string;
maxSelectionSize?: number;
cancelText?: string;
chooseText?: string;
togglePaletteMoreText?: string;
togglePaletteLessText?: string;
clearText?: string;
noColorSelectedText?: string;
preferredFormat?: boolean;
containerClassName?: string;
replacerClassName?: string;
showAlpha?: boolean;
theme?: string;
palette?: string[][];
selectionPalette?: string[];
disabled?: boolean;
offset?: { top: number; left: number };
}
export default function ($, undefined?: any) { export default function ($, undefined?: any) {
'use strict'; 'use strict';
if (!hasWin()) return; if (!hasWin()) return;
var defaultOpts = { var defaultOpts: ColorPickerOptions = {
// Callbacks // Callbacks
beforeShow: noop, beforeShow: noop,
move: noop, move: noop,

Loading…
Cancel
Save