@@ -18,11 +18,15 @@ const calcIndex = (idx, keyCode, resultCount) => {
return Math.max(idx - 1, 0);
}

export type TagCreateButtonProps = {
tagSearch: string,
onCreateTag: Function
}

export type Props = {
searchTags: Function,
selectTag: Function,
TagCreateButton?: //factory function
Function,
TagCreateButton?: React.Element<any>,
};

type State = {
@@ -38,6 +42,9 @@ class TagSearch extends Component {
onTagSearchChange: Function;
onKeyDown: Function;
setResultIndex: Function;
container: HTMLElement;
input: HTMLInputElement;

static defaultProps = {
TagCreateButton: () => false
}
@@ -76,8 +83,8 @@ class TagSearch extends Component {
}

onKeyDown(evt) {
const {keyCode} = evt;
const {currentIndex, tags} = this.state;
const { keyCode } = evt;
const { currentIndex, tags } = this.state;

if (applicableKeys.indexOf(keyCode) === -1) {
return;
@@ -98,7 +105,7 @@ class TagSearch extends Component {

onTagSearchChange(evt) {
let tagSearch = evt.target.value;
const {searchTags} = this.props;
const { searchTags } = this.props;

const tags = tagSearch === '' ? [] : searchTags(tagSearch.trim())

@@ -110,7 +117,7 @@ class TagSearch extends Component {
}

onSelectTag(tag) {
const {selectTag} = this.props;
const { selectTag } = this.props;

selectTag(tag);

@@ -125,8 +132,8 @@ class TagSearch extends Component {
}

render() {
const {tags, tagSearch, currentIndex} = this.state
const {TagCreateButton} = this.props;
const { tags, tagSearch, currentIndex } = this.state
const { TagCreateButton } = this.props;

const tagResult = tags.map((t, idx) => (<div className={`bm-tag-search__dropdown__item ${idx === currentIndex ? 'bm-tag-search__dropdown__item--highlighted' : ''}`}
key={t.id}
@@ -135,22 +142,21 @@ class TagSearch extends Component {
</div>))

return (<div ref={(container) => { this.container = container }} className="bm-tag-search">
<div className="bm-tag-search__search-row">
<input type="text" name="tagSearch"
placeholder="Search Tags"
className="bm-tag-search__search-row__input"
value={tagSearch}
ref={t=> this.input = t}
onChange={this.onTagSearchChange}
onBlur={this.onTagSearchBlur} />
<TagCreateButton tagSearch={tagSearch}
onCreateTag={this.onCreateTag}
></TagCreateButton>
</div>
<div className="bm-tag-search__dropdown">
{tagResult}
</div>
</div>)
<div className="bm-tag-search__search-row">
<input type="text" name="tagSearch"
placeholder="Search Tags"
className="bm-tag-search__search-row__input"
value={tagSearch}
ref={t => this.input = t}
onChange={this.onTagSearchChange} />
<TagCreateButton tagSearch={tagSearch}
onCreateTag={this.onCreateTag}
></TagCreateButton>
</div>
<div className="bm-tag-search__dropdown">
{tagResult}
</div>
</div>)
}
}

@@ -1,14 +1,8 @@
/* @flow */
import React from 'react';

export type Props = {
children: any,
className?: string,
};

const Card = (props: Props) => {
const {children, className} = props;
return <div className={`bm-card ${className}`}>
const Card = ({ children, className }: { children: any, className?: string }) => {
return <div className={`bm-card ${className || ''}`}>
{children}
</div>
}
@@ -7,7 +7,7 @@ export type Props = {
value: any,
display: string,
}>,
onSelect: Function,
onSelect: string => void,
};

type State = { showList: boolean };
@@ -18,13 +18,17 @@ class Dropdown extends Component {
toggleList: Function;
preventBubble: Function;
bodyWasClicked: Function;
dropdownContainer: HTMLDivElement;
discardClick: boolean;

constructor() {
super();

this.toggleList = this.toggleList.bind(this);
this.selectItem = this.selectItem.bind(this);
this.bodyWasClicked = this.bodyWasClicked.bind(this);
this.preventBubble = this.preventBubble.bind(this);
this.discardClick = false;

this.state = {
showList: false
@@ -70,7 +74,7 @@ class Dropdown extends Component {
})
}

selectItem(selected) {
selectItem(selected: string) {
const {onSelect} = this.props;

this.setState({
@@ -6,11 +6,11 @@ import * as css from '../styles/markdown-editor'
import debounce from 'lodash.debounce'

export type Props = {
onBlur?: Function,
onChange?: Function,
onBlur: string => void,
onChange: string => void,
initialText?: string,
collapsible?: boolean,
children?: number | string | React.Element | Array<any>,
children?: number | string | React.Element<any> | Array<any>,
};

type State = {
@@ -24,7 +24,7 @@ class MarkdownEditor extends Component {
onEditorChangeImpl: Function;
onEditorChange: Function;
onEditorBlur: Function;
textArea: React.Element<*>;
textArea: HTMLInputElement;

static defaultProps = {
onBlur: noop,
@@ -51,8 +51,8 @@ class MarkdownEditor extends Component {

props: Props;

onEditorBlur(evt) {
const {value} = evt.target;
onEditorBlur(evt: any) {
const value: string = evt.target.value;
const {onBlur, collapsible} = this.props;

onBlur(value);
@@ -64,13 +64,13 @@ class MarkdownEditor extends Component {
}
}

onEditorChange(evt: SyntheticEvent) {
const {value} = evt.target;
onEditorChange(evt: any) {
const value:string = evt.target.value;

this.onEditorChangeImpl(value);
}

onEditorChangeImpl(value) {
onEditorChangeImpl(value: string) {
const {onChange} = this.props;

onChange(value);
@@ -14,6 +14,8 @@ class MarkdownViewer extends Component {
super();
}

convertor: showdown.Convertor

props: Props;

componentWillMount() {
@@ -11,7 +11,7 @@ export type Props = {
openByDefault?: boolean,
destroyChildOnClose?: boolean,
onClose?: Function,//in case we need to notify parent when closing
children: number | string | React.Element | Array<any>,
children: number | string | React.Element<any> | Array<any>,
toggleButtonFunc?: Function,
};

@@ -35,8 +35,6 @@ class ToggleView extends Component {
}
}

props: Props;

toggleShow() {
const { isOpen } = this.state;
this.setState({
@@ -1,12 +1,18 @@
/* @flow */
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import {connect} from 'react-redux'
import {getBookmark} from '../redux/bookmark/actions'
import {getBookmarkById} from '../redux/bookmark/selectors'

const requireBookmark = Bookmark => {
const requireBookmark = (Bookmark: React.Component<*, *, *>) => {
class RequireBookmark extends Component {

props: {
bookmark: BookmarkType,
rest: Array<any>,
maybeFetchBookmark: () => void
}

componentDidMount() {
this.props.maybeFetchBookmark()
}