# Lua script : “Add text to note”

Function to add a text to a note.
Use to save a quick information.

Button : ${widgets.button("Add text to note", shizendo.addTextToNote)}

```space-lua
-- priority: 100

shizendo = shizendo or {}

function shizendo.addTextToNote()
  -- Demande à l'utilisateur de saisir un texte
  local page = "Sandbox/TestNote"
  local userText = editor.prompt("Entrez votre texte", "")
    
  -- Vérifie si l'utilisateur a saisi quelque chose
  if userText then
      local currentText = space.readPage(page)
      local content = currentText .. "\n\n---\n" .. userText

      local meta = space.writePage(page, content)
      -- print("Page updated at: " .. meta.lastModified)
  
      -- Affiche le texte dans une popup
      editor.flashNotification("Text added to ".. page, "info")
  else
      -- Affiche un message si l'utilisateur a annulé
      editor.flashNotification("Aborted", "error")
  end
end
```

```lua
-- Defines a new button that forces your UI into read-only mode
actionButton.define {
  icon = "eye",
  -- Uncomment the following line to only make this button appear 
  -- ONLY on mobile devices:
  --   mobile = true,
  run = function()
     shizendo.addTextToNote()
  end,
  description = "Add a text to a note",
  priority = 100
}
```


