Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

999 B
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */

import { Facet } from "@codemirror/state";
import type { CellActions } from "@/core/cells/actions";
import type { CellId } from "@/core/cells/ids";

export interface CodemirrorCellActions extends CellActions {
  toggleHideCode: () => boolean;
  aiCellCompletion: () => boolean;
  createManyBelow: (content: string[]) => void;
  /**
   * Create the setup cell with the given code, or append the code to the
   * existing setup cell if one already exists.
   */
  addOrAppendSetupCell: (code: string) => void;
  onRun: () => void;
  deleteCell: () => void;
  afterToggleMarkdown: () => void;
  afterToggleSQL: () => void;
  saveNotebook: () => void;
}

/**
 * State for cell actions
 */
export const cellActionsState = Facet.define<
  CodemirrorCellActions,
  CodemirrorCellActions
>({
  combine: (values) => values[0],
});

/**
 * State for cell id
 */
export const cellIdState = Facet.define<CellId, CellId>({
  combine: (values) => values[0],
});