#textCursor Source

textCursor :: TextCursorElement -> Effect TextCursor

Get the TextCursor from a TextCursorElement.

#setTextCursor Source

setTextCursor :: TextCursor -> TextCursorElement -> Effect Unit

Set the TextCursor on a TextCursorElement. Calls setValue, setSelectionStart, setSelectionEnd, and setSelectionDirection to ensure a consistent state for the field.

#modifyTextCursor Source

modifyTextCursor :: (TextCursor -> TextCursor) -> TextCursorElement -> Effect Unit

Modifies the TextCursor on an element through the given endomorphism.

#modifyTextCursorST Source

modifyTextCursorST :: forall s m. MonadState s m => MonadEffect m => Lens' s TextCursor -> (TextCursor -> TextCursor) -> TextCursorElement -> m s

Modifies the TextCursor on an element as well as setting the result in a State+Eff monad via a lens. Useful for components processing input events!

#focusTextCursor Source

focusTextCursor :: TextCursor -> TextCursorElement -> Effect Unit

Focuses an element after setting the TextCursor.

#focusTextCursorById Source

focusTextCursorById :: String -> TextCursor -> Effect Unit

Looks up an element by id to focus with a TextCursor.

Re-exports from Web.Util.TextCursor.Element.HTML

#value Source

value :: Getter String

Get the current text value of a TextCursorElement.

#setValue Source

setValue :: Setter String

Set the text value of a TextCursorElement to the specified string.

#setSelectionStart Source

setSelectionStart :: Setter Int

Set the index of the start of the selection.

#setSelectionEnd Source

setSelectionEnd :: Setter Int

Set the index of the end of the selection.

#setSelectionDirection Source

setSelectionDirection :: Setter Direction

Set the direction of the selection

#selectionStart Source

selectionStart :: Getter Int

Get the index of the start of the selection.

#selectionEnd Source

selectionEnd :: Getter Int

Get the index of the end of the selection.

#selectionDirection Source

selectionDirection :: Getter Direction

Get the direction of the selection.

Re-exports from Web.Util.TextCursor.Element.Type

#TextCursorElement Source

data TextCursorElement

A container for the two usable Element types:

  • HTMLInputElement
  • HTMLTextAreaElement

Note that not all HTMLInputElement nodes are valid, as they must contain text content. See validate for specifics.

Common operations are defined in TextCursor.Element.HTML.


#validate' Source

validate' :: Maybe TextCursorElement -> Effect (Maybe TextCursorElement)

Convert from a Foreign error computation (type F) to a validated TextCursorElement.

#validate Source

validate :: TextCursorElement -> Effect (Maybe TextCursorElement)

Validate a TextCursorElement. Input fields need to have one of the following types when this is called:

  • text (default)
  • email
  • search
  • url

#toHTMLElement Source

toHTMLElement :: TextCursorElement -> HTMLElement

Convert a TextCursorElement to a generic HTMLElement. Useful for focus.

#readEventTarget Source

readEventTarget :: Event -> Maybe TextCursorElement

Read a TextCursorElement from the target field of an Event.

#read Source

read :: Element -> Maybe TextCursorElement

Read a TextCursorElement from an Element.

#lookupValidateAndDo Source

lookupValidateAndDo :: String -> (TextCursorElement -> Effect Unit) -> Effect Unit

Look up a TextCursorElement by id and run an action if found.

#lookupAndValidate Source

lookupAndValidate :: String -> Effect (Maybe TextCursorElement)

Look up a TextCursorElement in the document by id.