import { HistoryNodeOptionEvent , nodeOptionEvent } from '@/store/history/types' ; import VisualEditor , { VisualEditorMode } from './visual-editor' ; import { VisualPropertyType } from '@/data/visuals' ; enum VisualEditorEventType { SELECT_MODE = 'setMode' , INPUT_VISUALS_COLOR = 'setVisualsColor' , INPUT_VISUALS_BORDER = 'setVisualsBorder' , INPUT_VISUALS_SIZE = 'setVisualsSize' , INPUT_VISUALS_WIDTH = 'setVisualsWidth' , INPUT_VISUALS_OPACITY = 'setVisualsOpacity' , SELECT_ENCODING_COLUMN = 'setEncodingColumn' , SELECT_ENCODING_TYPE = 'setEncodingType' , SELECT_ENCODING_COLOR_SCALE = 'setEncodingColorScale' , INPUT_ENCODING_SCALE_MIN = 'setEncodingScaleMin' , INPUT_ENCODING_SCALE_MAX = 'setEncodingScaleMax' } export const selectModeEvent = ( node , mode , prevMode ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . SELECT_MODE , 'select visual editor mode' , node , node . setMode , mode , prevMode ) ; } ; export const inputVisualsColorEvent = ( node , color , prevColor ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . INPUT_VISUALS_COLOR , 'input color' , node , node . setVisualsColor , color , prevColor ) ; } ; export const inputVisualsBorderEvent = ( node , border , prevBorder ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . INPUT_VISUALS_BORDER , 'input border' , node , node . setVisualsBorder , border , prevBorder ) ; } ; export const inputVisualsSizeEvent = ( node , size , prevSize ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . INPUT_VISUALS_SIZE , 'input size' , node , node . setVisualsSize , size , prevSize ) ; } ; export const inputVisualsWidthEvent = ( node , width , prevWidth ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . INPUT_VISUALS_WIDTH , 'input width' , node , node . setVisualsWidth , width , prevWidth ) ; } ; export const inputVisualsOpacityEvent = ( node , opacity , prevOpacity ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . INPUT_VISUALS_OPACITY , 'input opacity' , node , node . setVisualsOpacity , opacity , prevOpacity ) ; } ; export const selectEncodingColumnEvent = ( node , column , prevColumn ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . SELECT_ENCODING_COLUMN , 'select encoding column' , node , node . setEncodingColumn , column , prevColumn ) ; } ; export const selectEncodingTypeEvent = ( node , type , prevType ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . SELECT_ENCODING_TYPE , 'select encoding type' , node , node . setEncodingType , type , prevType ) ; } ; export const selectEncodingColorScaleEvent = ( node , colorScaleId , prevColorScaleId ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . SELECT_ENCODING_COLOR_SCALE , 'select color scale' , node , node . setEncodingColorScale , colorScaleId , prevColorScaleId ) ; } ; export const inputEncodingScaleMinEvent = ( node , value , prevValue ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . INPUT_ENCODING_SCALE_MIN , 'input scale min' , node , node . setEncodingScaleMin , value , prevValue ) ; } ; export const inputEncodingScaleMaxEvent = ( node , value , prevValue ) : HistoryNodeOptionEvent => { return nodeOptionEvent ( VisualEditorEventType . INPUT_ENCODING_SCALE_MAX , 'input scale max' , node , node . setEncodingScaleMax , value , prevValue ) ; } ;