devexpress-richedit
Version:
DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.
31 lines (30 loc) • 1.25 kB
JavaScript
import { isNumber } from '@devexpress/utils/lib/utils/common';
import { CommandBase } from '../command-base';
import { SimpleCommandState } from '../command-states';
import { RichUtils } from '../../model/rich-utils';
export class ChangeZoomLevelCommand extends CommandBase {
getState() {
const state = new SimpleCommandState(this.isEnabled(), this.control.viewManager.zoomLevel);
state.visible = this.control.viewManager.allowZoom;
return state;
}
executeCore(_state, options) {
if (options.param == this.control.viewManager.zoomLevel)
return false;
this.control.viewManager.zoomLevel = options.param;
return true;
}
isEnabledInReadOnlyMode() {
return true;
}
isEnabled() {
return this.control.viewManager.allowZoom;
}
DEPRECATEDConvertOptionsParameter(parameter) {
const res = typeof parameter == "string" ? parseFloat(parameter) : parameter;
return this.isZoomLevelValueCorrect(res) ? res : this.control.viewManager.zoomLevel;
}
isZoomLevelValueCorrect(size) {
return isNumber(size) && !isNaN(size) && size >= RichUtils.minZoomLevel && size <= RichUtils.maxZoomLevel;
}
}