"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index$1 = require("../_vendor/@codemirror/view/dist-index.cjs");
const react = require("react");
const index = require("../_vendor/@replit/codemirror-indentation-markers/dist-index.cjs");
const format = require("../extensions/format.cjs");
const useBaseExtensions = require("./use-base-extensions.cjs");
const theme = require("../extensions/theme.cjs");
const tooltipConfig = require("../extensions/tooltip-config.cjs");
const clipboardHandler = require("../extensions/clipboard-handler.cjs");
const keymap = require("../extensions/keymap.cjs");
function useExtensions(props) {
  const { readonly, lineWrapping = true, customExtensions = [], rows, onChange, onEditorUpdate, onFormat, onCursorChange, onSelectionChange } = props;
  const baseExtensions = useBaseExtensions.useBaseExtensions({
    readonly,
    lineWrapping,
    onChange,
    onCursorChange,
    onSelectionChange,
    onEditorUpdate,
    theme: theme.codeEditorTheme({
      isReadOnly: readonly,
      maxHeight: "100%",
      minHeight: "20vh",
      rows
    }),
    includeKeymap: true
  });
  const extensions = react.useMemo(() => {
    const allExtensions = [
      ...baseExtensions,
      tooltipConfig.tooltipToBody,
      clipboardHandler.clipboardHandler
    ];
    if (!readonly) {
      allExtensions.push(
        // 缩进标记
        index.indentationMarkers({
          highlightActiveBlock: true,
          markerType: "fullScope",
          colors: {
            activeDark: "var(--color-code-indentation-marker-active)",
            activeLight: "var(--color-code-indentation-marker-active)",
            dark: "var(--color-code-indentation-marker)",
            light: "var(--color-code-indentation-marker)"
          }
        }),
        // 编辑器键盘映射
        index$1.keymap.of(keymap.editorKeymap)
      );
    }
    const formatExtension = onFormat ? format.createFormatExtension(onFormat) : [];
    return [...allExtensions, formatExtension, ...customExtensions];
  }, [baseExtensions, customExtensions, onFormat, readonly]);
  return extensions;
}
exports.useExtensions = useExtensions;
//# sourceMappingURL=use-extensions.cjs.map
