Skip to content

Content importers

Content importers let editors load external content directly into the Context Item Content field using the rich markdown editor (MDXEditor). Instead of copy-pasting from PDFs, web pages, or files, editors use Load Document in the toolbar to import normalized markdown into the field.

Importers are built on the Document Loader ecosystem. AI Context ships a Document Loader: Context Importer submodule and supports optional importer plugins for additional source types. More importers may be added over time.

See optional extensions at Configuration → AI → Context Control Center → Settings → Extensions (/admin/config/ai/context/settings/extensions).

Document Loader: Context Importer

The Document Loader: Context Importer submodule (ai_context_document_loader) connects Context Items to Document Loader's MDXEditor integration.

This submodule is marked experimental — APIs and behavior may change before it stabilizes.

When enabled, editors see a Load Document button in the Content field toolbar. Imported content replaces the current editor contents.

Requirements

  • AI Context (parent module)
  • AI 1.4 or higher (MDXEditor)
  • Document Loader 2.0.x-dev (until the next stable 2.0.x release)
  • AI File to Text 1.0.x — file extraction for text, Markdown, PDF, Word, spreadsheets, and more

Enabling Document Loader: Context Importer also enables these Document Loader sub-modules:

  • document_loader_media — media library file picker
  • document_loader_mdx — MDXEditor toolbar button and dialog

Installation

  1. Require Document Loader and AI File to Text via Composer. The ai_context module applies required patches automatically via its composer.json (see Composer patches below):

bash composer require drupal/document_loader drupal/ai_file_to_text

  1. Enable the Document Loader: Context Importer submodule:

bash drush en ai_context_document_loader drush cr

Or enable Document Loader: Context Importer from Extend (/admin/modules).

  1. Optional importer plugin for URL content:

bash composer require drupal/document_loader_webpage drush en document_loader_webpage

On install, Document Loader: Context Importer adds md and markdown to the standard Document media type file extensions when that field exists, so Markdown files can be selected in the Load Document media picker.

Supported sources

Available sources appear automatically in the Load from select based on which importer modules are installed.

Source Module Type Notes
Text / Markdown / PDF / Word / spreadsheets ai_file_to_text Importer Required dependency of Document Loader: Context Importer
URL (webpage) document_loader_webpage Importer Optional; install separately

Usage

  1. Go to Configuration → AI → Context Control Center → Context Items (/admin/config/ai/context/items).
  2. Add or edit a context item.
  3. In the Content field MDXEditor toolbar, click Load Document.
  4. Choose a source (file, URL, or text depending on installed importers), then click Load.

No additional form display configuration is required.

MDXEditor assets

If you use a development branch of the AI module, build MDXEditor assets before testing importers. The minimum required Node version is 20.14.0.

cd web/modules/contrib/ai/ui/mdxeditor
npm install
npm run build

See also Installation in the main documentation.

Future importers

The Extensions settings page groups general optional modules separately from importer plugins. As new importer types are added, they will appear in the Importers section on that page and documented here.