PhiaUi.Components.Editor.Export (phia_ui v0.1.17)

Copy Markdown View Source

Export Suite — 6 components for importing, exporting, and printing editor content.

Provides dialogs and controls for document export (HTML, Markdown, PDF, DOCX, LaTeX, TXT), import (drag-and-drop file upload), print preview, template gallery, and page setup configuration.

Components

Summary

Functions

Renders a download button that triggers export for the given editor and format.

Renders an export dialog with format selection and an Export button.

Renders an import dialog with a drag-and-drop zone and file input.

Renders a page setup dialog with size, orientation, and margin controls.

Renders a page-sized white frame for print preview.

Renders a grid of document template cards.

Functions

download_button(assigns)

Renders a download button that triggers export for the given editor and format.

Example

<.download_button editor_id="my-editor" format={:markdown} label="Download MD" />

Attributes

  • editor_id (:string) (required)
  • format (:atom) - Defaults to :html.
  • label (:string) - Defaults to "Download".
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

export_dialog(assigns)

Renders an export dialog with format selection and an Export button.

Each format is displayed as a radio button. Fires phx-click="export:run" with the selected format on export.

Example

<.export_dialog id="export" visible={@show_export} selected_format={@export_format} />

Attributes

  • id (:string) (required)
  • visible (:boolean) - Defaults to false.
  • formats (:list) - Defaults to [:html, :markdown, :pdf, :docx, :latex, :txt].
  • selected_format (:atom) - Defaults to :html.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

import_dialog(assigns)

Renders an import dialog with a drag-and-drop zone and file input.

Accepts files of the types listed in :accepted_types. Fires phx-click="import:file" when a file is selected.

Example

<.import_dialog id="import" visible={@show_import} />

Attributes

  • id (:string) (required)
  • visible (:boolean) - Defaults to false.
  • accepted_types (:list) - Defaults to [".html", ".md", ".txt", ".docx"].
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

page_setup_dialog(assigns)

Renders a page setup dialog with size, orientation, and margin controls.

Example

<.page_setup_dialog
  id="page-setup"
  visible={@show_page_setup}
  page_size={@page_size}
  orientation={@orientation}
  margins={%{top: 1, bottom: 1, left: 1, right: 1}}
/>

Attributes

  • id (:string) (required)
  • visible (:boolean) - Defaults to false.
  • page_size (:atom) - Defaults to :a4.
  • orientation (:atom) - Defaults to :portrait. Must be one of :portrait, or :landscape.
  • margins (:map) - Defaults to %{}.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

template_gallery(assigns)

Renders a grid of document template cards.

Each item in :templates should be a map with :name, :description, :thumbnail (URL or nil), and :id keys.

Example

<.template_gallery id="tpl" templates={[
  %{id: "blank", name: "Blank", description: "Empty document", thumbnail: nil},
  %{id: "report", name: "Report", description: "Business report template", thumbnail: "/img/report.png"}
]} />

Attributes

  • id (:string) (required)
  • templates (:list) - Defaults to [].
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.