|
|
|
@ -15,7 +15,6 @@ interface ITodoItemState
|
|
|
|
|
historyCommands: Array<string>,// 历史命令
|
|
|
|
|
isShow: React.CSSProperties,// 是否显示历史命令框
|
|
|
|
|
isShowSet: React.CSSProperties,//是否显示设置块
|
|
|
|
|
commands: Array<string>, //命令库
|
|
|
|
|
searchCommand: Array<string>, //联想命令库
|
|
|
|
|
executeCommand: string, //所执行的命令
|
|
|
|
|
viceCommand: Array<{ title: string, keyboard: string }>,//副命令
|
|
|
|
@ -40,7 +39,6 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
historyCommands: [],
|
|
|
|
|
isShow: { display: 'none' },
|
|
|
|
|
hiUlPos: { bottom: '2rem' },
|
|
|
|
|
commands: ['LINE', 'LINETYPE', 'TR', 'TRANSLATE', 'TEXT1', 'TEXT2', 'TEXT3', 'TEXT4'],
|
|
|
|
|
searchCommand: [],
|
|
|
|
|
executeCommand: '',
|
|
|
|
|
viceCommand: [],
|
|
|
|
@ -53,7 +51,7 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
public handleOnChange = (e: React.FormEvent<HTMLInputElement>) =>
|
|
|
|
|
{
|
|
|
|
|
// 输入的命令
|
|
|
|
|
let m_inputValue = e.currentTarget.value.toUpperCase();
|
|
|
|
|
let m_inputValue = e.currentTarget.value;
|
|
|
|
|
|
|
|
|
|
this.setState({ command: m_inputValue });
|
|
|
|
|
//储存找到的相关命令
|
|
|
|
@ -67,14 +65,14 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
// 动态生成正则表达式
|
|
|
|
|
let m_searchReg: RegExp = new RegExp('');
|
|
|
|
|
// 拼接动态正则表达式
|
|
|
|
|
let m_comTmp: string = '^' + m_inputValue.split('').join('\\w*') + '\\w*$';
|
|
|
|
|
let m_comTmp: string = '^' + m_inputValue.toUpperCase().split('').join('\\w*') + '\\w*$';
|
|
|
|
|
m_searchReg = new RegExp(m_comTmp, 'i');
|
|
|
|
|
|
|
|
|
|
//如果没有确认执行命令,将显示推荐索引的命令
|
|
|
|
|
if (!this.state.executeCommand)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
this.state.commands.forEach((value: string) =>
|
|
|
|
|
this.props.commandStore.CommandList.forEach((value: string) =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (m_searchReg.test(value))
|
|
|
|
@ -122,7 +120,6 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
{
|
|
|
|
|
executeCommand: e.currentTarget.innerHTML,
|
|
|
|
|
searchCommand: [],
|
|
|
|
|
command: '',
|
|
|
|
|
historyCommands
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@ -130,7 +127,8 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
//绑定键盘命令
|
|
|
|
|
public handleSelectCommand = (e: KeyboardEvent) =>
|
|
|
|
|
{
|
|
|
|
|
// (this.props.commandStore.elInput as HTMLInputElement).focus();
|
|
|
|
|
// if (document.activeElement.nodeName !== 'INPUT')
|
|
|
|
|
// (this.props.commandStore.elInput as HTMLInputElement).focus();
|
|
|
|
|
|
|
|
|
|
let m_li: HTMLCollection = this.m_recommendUl.children;;
|
|
|
|
|
let historyCommands = this.state.historyCommands;
|
|
|
|
@ -193,7 +191,6 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
this.setState({ command: this.m_liHover.innerHTML });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果有关联命令执行以下逻辑
|
|
|
|
|
if (this.state.searchCommand.length > 0)
|
|
|
|
|
{
|
|
|
|
@ -217,8 +214,7 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
executeCommand: this.m_liHover.innerHTML,
|
|
|
|
|
searchCommand: [],
|
|
|
|
|
command: ''
|
|
|
|
|
searchCommand: []
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
return;
|
|
|
|
@ -254,13 +250,12 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
if (!this.state.executeCommand)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (this.state.command && this.state.commands.indexOf(this.state.command.trim()) !== -1)
|
|
|
|
|
if (this.state.command && this.props.commandStore.CommandList.indexOf(this.state.command.trim()) !== -1)
|
|
|
|
|
{
|
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
executeCommand: this.state.command,
|
|
|
|
|
searchCommand: [],
|
|
|
|
|
command: ''
|
|
|
|
|
searchCommand: []
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -275,13 +270,12 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
|
|
|
|
|
if (this.state.command === 'U')
|
|
|
|
|
{
|
|
|
|
|
this.setState({ viceCommand: [], command: '' });
|
|
|
|
|
this.setState({ viceCommand: [] });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.setState(
|
|
|
|
|
{
|
|
|
|
|
viceCommand: [{ title: '放弃', keyboard: 'U' }],
|
|
|
|
|
command: ''
|
|
|
|
|
viceCommand: [{ title: '放弃', keyboard: 'U' }]
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -459,10 +453,9 @@ export default class InputHint extends React.Component<{ commandStore?: CommandS
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="请输入命令"
|
|
|
|
|
ref={o => { this.props.commandStore.elInput = o; }}
|
|
|
|
|
// onKeyPress={this.handleConfirmInput}
|
|
|
|
|
onKeyDown={e => { e.preventDefault() }}
|
|
|
|
|
// onKeyDown={e => { e.preventDefault() }}
|
|
|
|
|
onChange={this.handleOnChange}
|
|
|
|
|
// value={this.state.command}
|
|
|
|
|
value={this.state.command}
|
|
|
|
|
/>
|
|
|
|
|
<ul
|
|
|
|
|
className="history-command"
|
|
|
|
|