UNPKG

devexpress-richedit

Version:

DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.

19 lines (18 loc) 960 B
import { ListUtils } from '@devexpress/utils/lib/utils/list'; import { FieldName } from '../names'; import { FieldSwitchType } from './field-code-parser'; import { FieldCodeParserClientUpdatingBase } from './field-code-parser-client-updating-base'; export class FieldCodeParserFillIn extends FieldCodeParserClientUpdatingBase { get name() { return FieldName.FillIn; } fillResult() { const switches = ListUtils.reducedMap(this.switchInfoList, switchInfo => switchInfo.type == FieldSwitchType.FieldSpecific ? switchInfo : null); const defaultPrompt = switches[0]?.name == 'd' ? switches[0].arg : ""; const prompt = this.parameterInfoList[0]?.text ?? ''; const response = window.prompt(prompt, defaultPrompt); if (response) { this.setInputPositionState(); this.replaceTextByInterval(this.getTopField().getResultInterval(), response); } return true; } }