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

    MarkdownEditor opens in a resizable source-and-visual split view. The Markdown string remains the single persistence source while TipTap provides the visual editing surface.

    Properties

    PropertyTypeRequiredDefaultDescription
    contentMarkdownContentYesControlled Markdown value.
    onChange(content: MarkdownContent) => voidYesEmits the complete next value.
    previewbooleanNofalseRead-only rendering.
    saveStatusstringNoHost-owned save status.
    fileActionsreadonly OfficeFileAction[]No[]Host file actions.
    extensionsExtensionsNo[]Additional TipTap extensions.
    getSelectionMenuItemsGetMarkdownSelectionMenuItemsNobuilt-in menuReplaces the selected-text menu in source and visual surfaces.
    theme'light' | 'dark' | 'system'No'system'Color mode.

    Content contract

    interface MarkdownContent {
      type: 'markdown';
      markdown: string;
    }

    The controlled source history coalesces typing, keeps explicit commands as separate records, restores source selection on undo and redo, and rebases when the host replaces the value.

    Selection menu

    The host menu covers both source and visual selections. The snapshot identifies selection.surface and includes exact selected text, adjacent context, the complete Markdown source, rendered plain text, and safe replace/insert commands.

    import type { GetMarkdownSelectionMenuItems } from '@a3s-lab/office/core';
    
    const getSelectionMenuItems: GetMarkdownSelectionMenuItems = (context) => [
      {
        id: 'summarize',
        label: 'Summarize',
        run: async () => {
          const summary = await summarize(context.document.markdown);
          await context.commands.replaceText(summary);
        },
      },
    ];

    Extensions that introduce new Nodes or Marks must provide matching Markdown parse and serialization rules. Otherwise the structure cannot survive a source-view round trip.