|
|
|
@ -15,7 +15,7 @@ import { TemplateSaveDir } from './TemplateSaveDir';
|
|
|
|
|
import { ModalHeader, ModalFooter } from '../Modal/ModalContainer';
|
|
|
|
|
import { CommandNames } from '../../../Common/CommandNames';
|
|
|
|
|
import { AppToaster } from '../Toaster';
|
|
|
|
|
import { begin } from 'xaop';
|
|
|
|
|
import { begin, end } from 'xaop';
|
|
|
|
|
import { GetCompoentObjectIdString } from '../ComponentObjectId';
|
|
|
|
|
|
|
|
|
|
export interface ITemplateEditorProps
|
|
|
|
@ -29,7 +29,9 @@ export const TEMP_EDITOR_KEY = "tempEditorKey";
|
|
|
|
|
|
|
|
|
|
@observer
|
|
|
|
|
export class TemplateEditor extends React.Component<ITemplateEditorProps, any> {
|
|
|
|
|
private event: Function;
|
|
|
|
|
private disposeCalls: Function[] = [];
|
|
|
|
|
|
|
|
|
|
templateNameInputRef = React.createRef<HTMLInputElement>();
|
|
|
|
|
componentDidMount()
|
|
|
|
|
{
|
|
|
|
|
if (TempEditor.EditorIng && this.props.tid)
|
|
|
|
@ -54,7 +56,14 @@ export class TemplateEditor extends React.Component<ITemplateEditorProps, any> {
|
|
|
|
|
}
|
|
|
|
|
}, TEMP_EDITOR_KEY);
|
|
|
|
|
|
|
|
|
|
this.event = begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) =>
|
|
|
|
|
const UpdateUIData = () =>
|
|
|
|
|
{
|
|
|
|
|
this.props.store.InitParams();
|
|
|
|
|
if (this.templateNameInputRef.current)
|
|
|
|
|
this.templateNameInputRef.current.value = this.props.store.Template.Name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.disposeCalls.push(begin(app.Editor.ModalManage, app.Editor.ModalManage.OnKeyDown, (e: KeyboardEvent) =>
|
|
|
|
|
{
|
|
|
|
|
if (GetCompoentObjectIdString(TemplateEditor) !== app.Editor.ModalManage.CurrentModalKey) return;
|
|
|
|
|
let el = e.target as HTMLInputElement;
|
|
|
|
@ -72,17 +81,18 @@ export class TemplateEditor extends React.Component<ITemplateEditorProps, any> {
|
|
|
|
|
}
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
end(app.Database.hm, app.Database.hm.UndoEvent, UpdateUIData),
|
|
|
|
|
end(app.Database.hm, app.Database.hm.RedoEvent, UpdateUIData)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.props.store.currentParamIndex = undefined;
|
|
|
|
|
}
|
|
|
|
|
componentWillUnmount()
|
|
|
|
|
{
|
|
|
|
|
if (this.event)
|
|
|
|
|
{
|
|
|
|
|
this.event();
|
|
|
|
|
this.event = null;
|
|
|
|
|
}
|
|
|
|
|
for (let f of this.disposeCalls)
|
|
|
|
|
f();
|
|
|
|
|
this.disposeCalls.length = 0;
|
|
|
|
|
}
|
|
|
|
|
public render()
|
|
|
|
|
{
|
|
|
|
@ -116,6 +126,7 @@ export class TemplateEditor extends React.Component<ITemplateEditorProps, any> {
|
|
|
|
|
<input className={Classes.INPUT}
|
|
|
|
|
disabled={this.props.isCheck}
|
|
|
|
|
defaultValue={template.Name}
|
|
|
|
|
ref={this.templateNameInputRef}
|
|
|
|
|
onBlur={e =>
|
|
|
|
|
{
|
|
|
|
|
CommandWrap(() =>
|
|
|
|
|