For AI agents: the complete documentation index is available at https://a3s-lab.github.io/Office/docs/en/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/Office/docs/en/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/Office/docs/en/components/extensions.md.
  • English
  • latest
  • Extension model

    A3S Office is modular without pretending that every editor has the same interaction model. Document and Markdown surfaces accept TipTap extensions; spreadsheet, presentation, and PDF currently expose typed host ports while their internal command contexts remain private.

    TipTap extensions

    import { Extension } from '@tiptap/core';
    import { useMemo } from 'react';
    import { DocumentEditor } from '@a3s-lab/office/react';
    
    const ReviewShortcut = Extension.create({
      name: 'hostReviewShortcut',
      addKeyboardShortcuts() {
        return {
          'Mod-Shift-r': () => {
            this.editor.commands.focus();
            return true;
          },
        };
      },
    });
    
    export function Editor(props) {
      const extensions = useMemo(() => [ReviewShortcut], []);
      return <DocumentEditor {...props} extensions={extensions} />;
    }

    Rules:

    1. Every extension needs a unique name; collisions with built-in extensions fail explicitly.
    2. Keep the extension array reference stable.
    3. Custom Nodes and Marks need matching DOCX or Markdown round-trip semantics.
    4. Do not import implementation modules from @a3s-lab/office/internal paths.

    Host extension ports

    PortUse
    fileActionsSave, export, history, approval, or domain-specific file commands.
    onAgentRequestSend structured editor context to the host AI workflow.
    getSelectionMenuItemsCompletely define selected-text actions and their asynchronous logic.
    loadSource / onSaveOwn the PDF source and persistence lifecycle.
    onStartSlideshowSynchronize presentation playback with host routing or devices.

    The library never infers host behavior from localized labels or keyword matching. Selection-menu callbacks receive typed context and safe commands; the host owns prompts, model calls, authorization, and persistence.