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 File 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 File Importer

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

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

Requirements

On Canvas-enabled sites, use Drupal Canvas 1.8.0 or later. Older releases could fail to save large Context Item content values (canvas#3575644, fixed in Canvas 1.8.0). No Composer patches are required.

Enabling Document Loader: Context File 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:

bash composer require 'drupal/document_loader:^2.0.3' 'drupal/ai_file_to_text:^1.0'

  1. Enable the Document Loader: Context File Importer submodule:

bash drush en ai_context_document_loader drush cr

Or enable Document Loader: Context File 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 File Importer adds md and markdown to the standard Document media type file extensions when that field exists (field.field.media.document.field_media_document), so Markdown files can be selected in the Load Document media picker. This change is additive and idempotent — it is skipped when the field does not exist or already allows those extensions — and is not reverted on uninstall, because Markdown media files uploaded while the module was active would otherwise become invalid. Remove the extensions manually from the field settings if your site does not want them.

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 File 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.

Review imported content before publication

Imported files and webpages are copied into the Context Item Content field. They are not trusted, synchronized with the source, or continuously validated after import.

Treat every import as untrusted input until an authorized editor reviews it:

  • Imported text may be outdated, inaccurate, or incomplete relative to the source.
  • Web pages and documents may contain instructions aimed at AI systems (prompt injection) or misleading claims.
  • Sanitization protects the markdown editor from unsafe markup; it does not establish semantic safety for content that will be injected into agent prompts.

Editorial workflow:

  1. Import into a new or existing context item.
  2. Review and revise the copied content for accuracy, tone, and safety.
  3. Save as draft or disable Publish by default on Context item settings when your site relies heavily on importers.
  4. Publish only after review.

Once saved on a context item, copied content follows the item's publication and access lifecycle. Permissions on the original file, URL, or entity do not protect that text after import. See Access boundaries — Imported and copied content lifecycle.

Provenance tracking and source synchronization are planned for a future release; they are out of scope for 1.0.

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.