aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/LinkEditor.tsx
blob: f82c6e9cbeb87503b432a1009cb18470ffb76452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { observable, computed, action } from "mobx";
import React = require("react");
import { SelectionManager } from "../../util/SelectionManager";
import { observer } from "mobx-react";
import './LinkEditor.scss';
import { props } from "bluebird";
import { DocumentView } from "./DocumentView";
import { link } from "fs";
import { StrCast } from "../../../new_fields/Types";
import { Doc } from "../../../new_fields/Doc";

interface Props {
    linkDoc: Doc;
    showLinks: () => void;
}

@observer
export class LinkEditor extends React.Component<Props> {

    @observable private _nameInput: string = StrCast(this.props.linkDoc.title);
    @observable private _descriptionInput: string = StrCast(this.props.linkDoc.linkDescription);


    onSaveButtonPressed = (e: React.PointerEvent): void => {
        e.stopPropagation();

        this.props.linkDoc.title = this._nameInput;
        this.props.linkDoc.linkDescription = this._descriptionInput;

        this.props.showLinks();
    }



    render() {

        return (
            <div className="edit-container">
                <input onChange={this.onNameChanged} className="name-input" type="text" value={this._nameInput} placeholder="Name . . ."></input>
                <textarea onChange={this.onDescriptionChanged} className="description-input" value={this._descriptionInput} placeholder="Description . . ."></textarea>
                <div className="save-button" onPointerDown={this.onSaveButtonPressed}>SAVE</div>
            </div>

        );
    }

    @action
    onNameChanged = (e: React.ChangeEvent<HTMLInputElement>) => {
        this._nameInput = e.target.value;
    }

    @action
    onDescriptionChanged = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
        this._descriptionInput = e.target.value;
    }
}