mirror of
https://github.com/usatiuk/writer.git
synced 2025-10-29 00:17:48 +01:00
save document at enter press in name input
Signed-off-by: Stepan Usatyuk <usaatyuk@ustk.me>
This commit is contained in:
28
frontend/package-lock.json
generated
28
frontend/package-lock.json
generated
@@ -4098,12 +4098,14 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@@ -4118,17 +4120,20 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@@ -4245,7 +4250,8 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@@ -4257,6 +4263,7 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@@ -4271,6 +4278,7 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@@ -4278,12 +4286,14 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
@@ -4302,6 +4312,7 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@@ -4382,7 +4393,8 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@@ -4394,6 +4406,7 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@@ -4515,6 +4528,7 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
||||
@@ -63,6 +63,9 @@ export class DocumentEditComponent extends React.PureComponent<
|
||||
|
||||
this.state = defaultDocumentEditComponentState;
|
||||
this.handleInputChange = this.handleInputChange.bind(this);
|
||||
this.handleNameKeyPress = this.handleNameKeyPress.bind(this);
|
||||
this.remove = this.remove.bind(this);
|
||||
this.save = this.save.bind(this);
|
||||
this.onUnload = this.onUnload.bind(this);
|
||||
}
|
||||
|
||||
@@ -76,37 +79,20 @@ export class DocumentEditComponent extends React.PureComponent<
|
||||
onChange={this.handleInputChange}
|
||||
name="name"
|
||||
value={this.state.name}
|
||||
onKeyPress={this.handleNameKeyPress}
|
||||
/>
|
||||
<div className="buttons">
|
||||
<Button
|
||||
icon="trash"
|
||||
minimal={true}
|
||||
intent="danger"
|
||||
onClick={() => {
|
||||
this.props.history.push(`/`);
|
||||
this.props.deleteDoc(this.state.id);
|
||||
AppToaster.show({
|
||||
message: "Document deleted!",
|
||||
intent: "danger",
|
||||
timeout: 2900,
|
||||
action: {
|
||||
text: "Undo",
|
||||
onClick: () =>
|
||||
this.props.cancelDelete(),
|
||||
},
|
||||
});
|
||||
}}
|
||||
onClick={this.remove}
|
||||
/>
|
||||
<Button
|
||||
icon="tick"
|
||||
intent="success"
|
||||
minimal={true}
|
||||
onClick={() => {
|
||||
this.update();
|
||||
this.props.history.push(
|
||||
`/docs/${this.state.id}`,
|
||||
);
|
||||
}}
|
||||
onClick={this.save}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -135,6 +121,31 @@ export class DocumentEditComponent extends React.PureComponent<
|
||||
} as any);
|
||||
}
|
||||
|
||||
public remove() {
|
||||
this.props.history.push(`/`);
|
||||
this.props.deleteDoc(this.state.id);
|
||||
AppToaster.show({
|
||||
message: "Document deleted!",
|
||||
intent: "danger",
|
||||
timeout: 2900,
|
||||
action: {
|
||||
text: "Undo",
|
||||
onClick: () => this.props.cancelDelete(),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public save() {
|
||||
this.update();
|
||||
this.props.history.push(`/docs/${this.state.id}`);
|
||||
}
|
||||
|
||||
public handleNameKeyPress(event: React.KeyboardEvent<HTMLInputElement>) {
|
||||
if (event.key === "Enter") {
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
|
||||
public handleInputChange(
|
||||
event:
|
||||
| React.FormEvent<HTMLInputElement>
|
||||
|
||||
Reference in New Issue
Block a user