Module

DOM.Util.TextCursor.Element

Package
purescript-textcursor
Repository
MonoidMusician/purescript-textcursor

#textCursor Source

textCursor :: forall eff. TextCursorElement -> Eff (dom :: DOM | eff) TextCursor

Get the TextCursor from a TextCursorElement.

#setTextCursor Source

setTextCursor :: forall eff. TextCursor -> TextCursorElement -> Eff (dom :: DOM | eff) Unit

Set the TextCursor on a TextCursorElement. Calls setValue, setSelectionStart, and setSelectionEnd.

#modifyTextCursor Source

modifyTextCursor :: forall eff. (TextCursor -> TextCursor) -> TextCursorElement -> Eff (dom :: DOM | eff) Unit

Modifies the TextCursor on an element through the given endomorphism.

#modifyTextCursorST Source

modifyTextCursorST :: forall s m eff. MonadState s m => MonadEff (dom :: DOM | eff) m => Lens' s TextCursor -> (TextCursor -> TextCursor) -> TextCursorElement -> m Unit

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 :: forall eff. TextCursor -> TextCursorElement -> Eff (dom :: DOM | eff) Unit

Focuses an element after setting the TextCursor.

#focusTextCursorById Source

focusTextCursorById :: forall eff. ElementId -> TextCursor -> Eff (dom :: DOM | eff) Unit

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

Re-exports from DOM.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 DOM.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.

Constructors

#validate' Source

validate' :: forall eff. F TextCursorElement -> Eff (dom :: DOM | eff) (Maybe TextCursorElement)

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

#validate Source

validate :: forall eff. TextCursorElement -> Eff (dom :: DOM | eff) (Maybe TextCursorElement)

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

  • text (default)
  • email
  • search
  • url

#readEventTarget Source

readEventTarget :: Event -> F TextCursorElement

Read a TextCursorElement from the target field of an Event.

#lookupValidateAndDo Source

lookupValidateAndDo :: forall eff. ElementId -> (TextCursorElement -> Eff (dom :: DOM | eff) Unit) -> Eff (dom :: DOM | eff) Unit

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

#lookupAndValidate Source

lookupAndValidate :: forall eff. ElementId -> Eff (dom :: DOM | eff) (Maybe TextCursorElement)

Look up a TextCursorElement in the document by id.

#htmlTextCursorElementToHTMLElement Source

htmlTextCursorElementToHTMLElement :: TextCursorElement -> HTMLElement

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