# `PhoenixKitKnowledgeBase.Web.NotesPanel`
[🔗](https://github.com/BeamLabEU/phoenix_kit_knowledge_base/blob/v0.1.0/lib/phoenix_kit_knowledge_base/web/notes_panel.ex#L1)

Notes you can drop into any page: a small file list and an editor for one
folder of a vault, named by a path.

    <PhoenixKitKnowledgeBase.Web.Components.notes_panel
      id="client-notes"
      current_user={@current_user}
      path={["CRM", "Clients", @client.name]}
    />

The first segment of `path` is the vault, the rest the folder the panel shows;
the first note or folder creates whatever is missing (`Places`). People make
subfolders and write notes here, with autosave; they never see above `path`.
Notes are ordinary files of an ordinary vault, so the admin vault page, links,
tags and backlinks all work on them.

## Attributes

  * `id` (required)
  * `current_user` (required) — `%PhoenixKit.Users.Auth.User{}`; `nil` renders nothing
  * `path` (required) — `[vault, folder, …]`. Notes are kept by path: put
    something stable in it (an id), since a renamed segment is a new folder
  * `label` — the heading; defaults to the last path segment
  * `show_label` — default `true`
  * `visibility_options` — `[:private, :shared]` (default); the switch is
    hidden when there is one. Shared notes ask the host's `:authorize` hook
    (see `Places`); private ones are each person's own
  * `default_visibility` — `:shared` (default)
  * `poll` — ms between refreshes of the list, default `5_000`; `0` turns it off
  * `class`

## How it runs inside someone else's page

A LiveComponent shares the host LiveView's process. It cannot subscribe to
PubSub or receive `handle_info`, so it polls, and its editor is Leaf with
`notify: {__MODULE__, id}` — Leaf's messages arrive in `update/2` as
`%{leaf: message}` instead of in the host's `handle_info`. A component's
`put_flash` never reaches the page, so every message is shown inline.

Every event checks access again (`Places.authorize/3`) and checks that what
it names lies inside the panel's folder (`Places.within?/2`): the page is not
trusted to have offered only what it was allowed to.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
