import { EditorState } from 'draft-js' ; import Action , { ThunkAction } from './type' ; import KeymapTransition from '../keybinds/keymap_transition' ; import Tweet , { TwitterUser } from '../item/tweet' ; export function changeEditorState ( editor ) { return { type : 'ChangeEditorState' , editor , } ; } export function selectAutoCompleteSuggestion ( text , query ) { return { type : 'SelectAutoCompleteSuggestion' , text , query , } ; } export function openEditor ( text ? ) { return dispatch => { KeymapTransition . enterEditor ( ) ; dispatch ( { type : 'OpenEditor' , text , } ) ; } ; } export function openEditorForReply ( in_reply_to , owner , text ? ) { return dispatch => { KeymapTransition . enterEditor ( ) ; dispatch ( { type : 'OpenEditorForReply' , status : in_reply_to , user : owner , text , } ) ; } ; } export function closeEditor ( ) { return ( dispatch , getState ) => { KeymapTransition . escapeFromCurrentKeymaps ( getState ( ) ) ; dispatch ( { type : 'CloseEditor' , } ) ; } ; } export function toggleEditor ( ) { return ( dispatch , getState ) => ( getState ( ) . editor . is_open ? closeEditor : openEditor ) ( ) ( dispatch , getState ) ; }