function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _array_without_holes(arr) {
    if (Array.isArray(arr)) return _array_like_to_array(arr);
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
    try {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
        return;
    }
    if (info.done) {
        resolve(value);
    } else {
        Promise.resolve(value).then(_next, _throw);
    }
}
function _async_to_generator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}
function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _iterable_to_array(iter) {
    if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _non_iterable_spread() {
    throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _to_consumable_array(arr) {
    return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
function _ts_generator(thisArg, body) {
    var f, y, t, _ = {
        label: 0,
        sent: function() {
            if (t[0] & 1) throw t[1];
            return t[1];
        },
        trys: [],
        ops: []
    }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
    return d(g, "next", {
        value: verb(0)
    }), d(g, "throw", {
        value: verb(1)
    }), d(g, "return", {
        value: verb(2)
    }), typeof Symbol === "function" && d(g, Symbol.iterator, {
        value: function() {
            return this;
        }
    }), g;
    function verb(n) {
        return function(v) {
            return step([
                n,
                v
            ]);
        };
    }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while(g && (g = 0, op[0] && (_ = 0)), _)try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [
                op[0] & 2,
                t.value
            ];
            switch(op[0]){
                case 0:
                case 1:
                    t = op;
                    break;
                case 4:
                    _.label++;
                    return {
                        value: op[1],
                        done: false
                    };
                case 5:
                    _.label++;
                    y = op[1];
                    op = [
                        0
                    ];
                    continue;
                case 7:
                    op = _.ops.pop();
                    _.trys.pop();
                    continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                        _ = 0;
                        continue;
                    }
                    if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
                        _.label = op[1];
                        break;
                    }
                    if (op[0] === 6 && _.label < t[1]) {
                        _.label = t[1];
                        t = op;
                        break;
                    }
                    if (t && _.label < t[2]) {
                        _.label = t[2];
                        _.ops.push(op);
                        break;
                    }
                    if (t[2]) _.ops.pop();
                    _.trys.pop();
                    continue;
            }
            op = body.call(thisArg, _);
        } catch (e) {
            op = [
                6,
                e
            ];
            y = 0;
        } finally{
            f = t = 0;
        }
        if (op[0] & 5) throw op[1];
        return {
            value: op[0] ? op[1] : void 0,
            done: true
        };
    }
}
/* eslint-disable @typescript-eslint/no-use-before-define */ /* eslint-disable react/no-children-prop */ import { useDebounceFn } from "@ant-design/pro-components";
import classNames from "clsx";
import React, { useContext, useEffect, useMemo, useRef } from "react";
import { ErrorBoundary } from "react-error-boundary";
import { Editor, Node, Range, Transforms } from "slate";
import { Editable, ReactEditor, Slate } from "slate-react";
import { useRefFunction } from "../../Hooks/useRefFunction";
import { parserMdToSchema } from "../BaseMarkdownEditor";
import { PluginContext } from "../plugin";
import { LazyElement } from "./components/LazyElement";
import { MElement, MLeaf } from "./elements";
import { handleFilesPaste, handleHtmlPaste, handleHttpLinkPaste, handlePlainTextPaste, handleSlateMarkdownFragment, handleSpecialTextPaste, handleTagNodePaste, shouldInsertTextDirectly } from "./plugins/handlePaste";
import { useHighlight } from "./plugins/useHighlight";
import { useKeyboard } from "./plugins/useKeyboard";
import { useOnchange } from "./plugins/useOnchange";
import { useEditorStore } from "./store";
import { useStyle } from "./style";
import { MARKDOWN_EDITOR_EVENTS, parserSlateNodeToMarkdown } from "./utils";
import { EditorUtils, findByPathAndText, findLeafPath, getSelectionFromDomSelection, hasEditableTarget, isEventHandled, isPath } from "./utils/editorUtils";
// 默认允许的类型
var defaultAllowedTypes = [
    'application/x-slate-md-fragment',
    'text/html',
    'Files',
    'text/markdown',
    'text/plain'
];
/**
 * 生成表格最小尺寸配置
 *
 * 该函数用于设置表格的最小列数和行数，确保表格的基本结构。
 * 通过递归遍历编辑器元素，找到表格元素并应用最小尺寸约束。
 *
 * @param elements - 编辑器元素数组
 * @param config - 配置对象
 * @param config.minColumn - 最小列数
 * @param config.minRows - 最小行数
 */ var genTableMinSize = function genTableMinSize1(elements, config) {
    if (!config) return elements;
    elements.forEach(function(element) {
        if (element.children) {
            genTableMinSize(element.children, config);
        }
    });
};
/**
 * SlateMarkdownEditor 组件 - Slate Markdown编辑器组件
 *
 * 基于Slate.js的Markdown编辑器，支持丰富的编辑功能，包括文本编辑、表格、代码块、媒体插入、链接等。
 * 通过MobX进行状态管理，支持多种编辑器事件和操作。
 *
 * @component
 * @description 基于Slate.js的Markdown编辑器组件
 * @param {MEditorProps} props - 编辑器属性
 * @param {Function} [props.eleItemRender] - 自定义元素渲染函数
 * @param {Function} [props.leafRender] - 自定义叶子节点渲染函数
 * @param {Function} [props.onChange] - 内容变化回调
 * @param {MarkdownEditorInstance} props.instance - 编辑器实例
 * @param {string} [props.className] - 自定义CSS类名
 * @param {CommentDataType} [props.comment] - 评论数据
 * @param {string} [props.prefixCls] - 前缀类名
 * @param {boolean} [props.reportMode] - 是否为报告模式
 * @param {string} [props.placeholder] - 占位符文本
 *
 * @example
 * ```tsx
 * <SlateMarkdownEditor
 *   instance={editorInstance}
 *   onChange={(value) => console.log('内容变化:', value)}
 *   placeholder="请输入Markdown内容..."
 *   reportMode={false}
 * />
 * ```
 *
 * @returns {React.ReactElement} 渲染的Markdown编辑器组件
 *
 * @remarks
 * - 基于Slate.js实现
 * - 支持丰富的Markdown语法
 * - 提供自定义渲染功能
 * - 支持插件系统
 * - 集成状态管理
 * - 支持键盘快捷键
 * - 提供粘贴处理
 * - 支持错误边界
 * - 响应式布局
 */ export var SlateMarkdownEditor = /*#__PURE__*/ React.memo(function(props) {
    var _markdownEditorRef_current, _props_textAreaProps, _props_comment, _markdownEditorRef_current1;
    // 所有hooks必须在组件顶部按固定顺序调用
    var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, setDomRect = _useEditorStore.setDomRect, jinjaEnabled = _useEditorStore.jinjaEnabled;
    // 懒加载元素索引计数器
    var lazyElementIndexRef = useRef(0);
    // 用于标记是否已在当前渲染周期重置过索引
    var hasResetIndexRef = useRef(false);
    // 计算懒加载元素总数的函数
    var countLazyElements = useRefFunction(function(nodes) {
        var count = 0;
        var traverse = function traverse1(nodeList) {
            nodeList.forEach(function(node) {
                // 跳过表格单元格和表格行
                if (node.type !== 'table-cell' && node.type !== 'table-row') {
                    count++;
                }
                // 继续遍历子节点（例如表格内的元素）
                if (node.children && Array.isArray(node.children)) {
                    traverse(node.children);
                }
            });
        };
        traverse(nodes);
        return count;
    });
    var changedMark = useRef(false);
    var value = useRef([
        EditorUtils.p
    ]);
    var nodeRef = useRef();
    var first = useRef(true);
    var plugins = useContext(PluginContext);
    var onKeyDown = useKeyboard(store, markdownEditorRef, props);
    var onChange = useOnchange(markdownEditorRef.current, props.onChange);
    var high = useHighlight(store, jinjaEnabled);
    var childrenIsEmpty = useMemo(function() {
        var _markdownEditorRef_current;
        if (!((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children)) return false;
        if (!Array.isArray(markdownEditorRef.current.children)) return false;
        if (markdownEditorRef.current.children.length === 0) return false;
        return value.current.filter(function(v) {
            var _v_children_at, _v_children_at1, _v_children;
            return v.type === 'paragraph' && ((_v_children = v.children) === null || _v_children === void 0 ? void 0 : (_v_children_at1 = _v_children.at) === null || _v_children_at1 === void 0 ? void 0 : (_v_children_at = _v_children_at1.call(_v_children, 0)) === null || _v_children_at === void 0 ? void 0 : _v_children_at.text) === '';
        }).length < 1;
    }, [
        (_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children
    ]);
    var readonlyCls = useMemo(function() {
        if (readonly) return 'readonly';
        return !childrenIsEmpty ? 'focus' : '';
    }, [
        readonly,
        !childrenIsEmpty
    ]);
    var _useStyle = useStyle("".concat(props.prefixCls, "-content"), {
        placeholderContent: (props === null || props === void 0 ? void 0 : (_props_textAreaProps = props.textAreaProps) === null || _props_textAreaProps === void 0 ? void 0 : _props_textAreaProps.placeholder) || (props === null || props === void 0 ? void 0 : props.placeholder)
    }), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    var commentMap = useMemo(function() {
        var _props_comment_commentList, _props_comment;
        var map = new Map();
        props === null || props === void 0 ? void 0 : (_props_comment = props.comment) === null || _props_comment === void 0 ? void 0 : (_props_comment_commentList = _props_comment.commentList) === null || _props_comment_commentList === void 0 ? void 0 : _props_comment_commentList.forEach(function(c) {
            c.updateTime = Date.now();
            var path = c.path.join(',');
            if (map.has(path)) {
                var childrenMap = map.get(path);
                var selection = JSON.stringify(c.selection);
                if (childrenMap === null || childrenMap === void 0 ? void 0 : childrenMap.has(selection)) {
                    childrenMap.set(selection, _to_consumable_array(childrenMap.get(selection) || []).concat([
                        c
                    ]));
                    map.set(path, childrenMap);
                    return;
                } else if (childrenMap) {
                    childrenMap === null || childrenMap === void 0 ? void 0 : childrenMap.set(selection, [
                        c
                    ]);
                    map.set(path, childrenMap);
                    return;
                }
            }
            var childrenMap1 = new Map();
            childrenMap1.set(JSON.stringify(c.selection), [
                c
            ]);
            map.set(path, childrenMap1);
        });
        return map;
    }, [
        props === null || props === void 0 ? void 0 : (_props_comment = props.comment) === null || _props_comment === void 0 ? void 0 : _props_comment.commentList
    ]);
    var handleSelectionChange = useDebounceFn(function(e) {
        return _async_to_generator(function() {
            var _props_floatBar, currentSelection, getSelectionContent, _markdownContainerRef_current, event, _props_onSelectionChange, _getSelectionContent, markdown, nodes, domSelection, _props_onSelectionChange1, selection, _markdownContainerRef_current1, event1, _props_onSelectionChange2, _getSelectionContent1, markdown1, nodes1, range, rect, _props_onSelectionChange3;
            return _ts_generator(this, function(_state) {
                // 只读且不需要选区（无 onSelectionChange、无 FloatBar）时，跳过选区同步与 DOM 测量，提升性能
                if (readonly && !props.onSelectionChange && (!props.reportMode || ((_props_floatBar = props.floatBar) === null || _props_floatBar === void 0 ? void 0 : _props_floatBar.enable) === false)) {
                    setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
                    return [
                        2
                    ];
                }
                currentSelection = markdownEditorRef.current.selection;
                // 获取选中内容的 markdown 和节点
                getSelectionContent = function getSelectionContent(selection) {
                    if (!selection || Range.isCollapsed(selection)) {
                        return {
                            markdown: '',
                            nodes: []
                        };
                    }
                    try {
                        var fragment = Editor.fragment(markdownEditorRef.current, selection);
                        var markdown = parserSlateNodeToMarkdown(fragment);
                        return {
                            markdown: markdown,
                            nodes: fragment
                        };
                    } catch (error) {
                        console.error('Failed to get selection content:', error);
                        return {
                            markdown: '',
                            nodes: []
                        };
                    }
                };
                if (!readonly) {
                    ;
                    // 非只读模式下的选区处理
                    event = new CustomEvent(MARKDOWN_EDITOR_EVENTS.SELECTIONCHANGE, _object_spread_props(_object_spread({}, e), {
                        detail: currentSelection
                    }));
                    markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current = markdownContainerRef.current) === null || _markdownContainerRef_current === void 0 ? void 0 : _markdownContainerRef_current.dispatchEvent(event);
                    // 调用 props.onSelectionChange 回调
                    if (props.onSelectionChange) {
                        ;
                        _getSelectionContent = getSelectionContent(currentSelection), markdown = _getSelectionContent.markdown, nodes = _getSelectionContent.nodes;
                        (_props_onSelectionChange = props.onSelectionChange) === null || _props_onSelectionChange === void 0 ? void 0 : _props_onSelectionChange.call(props, currentSelection, markdown, nodes);
                    }
                    return [
                        2
                    ];
                }
                if (typeof window === 'undefined') return [
                    2
                ];
                // 只读模式下的选区处理
                domSelection = window.getSelection();
                if (!domSelection) {
                    setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
                    // 调用 props.onSelectionChange 回调（无选中）
                    if (props.onSelectionChange) {
                        ;
                        (_props_onSelectionChange1 = props.onSelectionChange) === null || _props_onSelectionChange1 === void 0 ? void 0 : _props_onSelectionChange1.call(props, null, '', []);
                    }
                    return [
                        2
                    ];
                }
                try {
                    selection = getSelectionFromDomSelection(markdownEditorRef.current, domSelection);
                    if (selection) {
                        ;
                        // 更新编辑器的选区
                        markdownEditorRef.current.selection = selection;
                        // 触发选区变化事件
                        event1 = new CustomEvent(MARKDOWN_EDITOR_EVENTS.SELECTIONCHANGE, {
                            detail: selection
                        });
                        markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : (_markdownContainerRef_current1 = markdownContainerRef.current) === null || _markdownContainerRef_current1 === void 0 ? void 0 : _markdownContainerRef_current1.dispatchEvent(event1);
                        // 调用 props.onSelectionChange 回调
                        if (props.onSelectionChange) {
                            ;
                            _getSelectionContent1 = getSelectionContent(selection), markdown1 = _getSelectionContent1.markdown, nodes1 = _getSelectionContent1.nodes;
                            (_props_onSelectionChange2 = props.onSelectionChange) === null || _props_onSelectionChange2 === void 0 ? void 0 : _props_onSelectionChange2.call(props, selection, markdown1, nodes1);
                        }
                        // 只有在有实际选中文本时才显示工具栏
                        if (!Range.isCollapsed(selection)) {
                            range = ReactEditor.toDOMRange(markdownEditorRef.current, selection);
                            rect = range === null || range === void 0 ? void 0 : range.getBoundingClientRect();
                            if (rect) {
                                setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(rect);
                            } else {
                                setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
                            }
                        } else {
                            setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
                        }
                    } else {
                        setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
                        // 调用 props.onSelectionChange 回调（无选中）
                        if (props.onSelectionChange) {
                            ;
                            (_props_onSelectionChange3 = props.onSelectionChange) === null || _props_onSelectionChange3 === void 0 ? void 0 : _props_onSelectionChange3.call(props, null, '', []);
                        }
                    }
                } catch (error) {
                    console.error('Selection change error:', error);
                }
                return [
                    2
                ];
            });
        })();
    }, 16);
    // 添加选区变化的监听
    useEffect(function() {
        var container = markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : markdownContainerRef.current;
        if (!container) return;
        var handleMouseUp = function handleMouseUp(e) {
            e.preventDefault();
            handleSelectionChange.run();
        };
        container.addEventListener('mouseup', handleMouseUp);
        return function() {
            container.removeEventListener('mouseup', handleMouseUp);
            handleSelectionChange.cancel();
        };
    }, [
        readonly,
        markdownContainerRef === null || markdownContainerRef === void 0 ? void 0 : markdownContainerRef.current
    ]);
    useEffect(function() {
        if (nodeRef.current !== props.instance) {
            initialNote();
        }
    }, [
        props.instance,
        markdownEditorRef.current
    ]);
    useEffect(function() {
        var _props_fncProps_onFootnoteDefinitionChange, _props_fncProps;
        var footnoteDefinitionList = markdownEditorRef.current.children.filter(function(item) {
            return item.type === 'footnoteDefinition';
        }).map(function(item, index) {
            return {
                id: item.id || index,
                placeholder: item.identifier,
                origin_text: item.value,
                url: item.url,
                origin_url: item.url
            };
        });
        props === null || props === void 0 ? void 0 : (_props_fncProps = props.fncProps) === null || _props_fncProps === void 0 ? void 0 : (_props_fncProps_onFootnoteDefinitionChange = _props_fncProps.onFootnoteDefinitionChange) === null || _props_fncProps_onFootnoteDefinitionChange === void 0 ? void 0 : _props_fncProps_onFootnoteDefinitionChange.call(_props_fncProps, footnoteDefinitionList);
    }, [
        (_markdownEditorRef_current1 = markdownEditorRef.current) === null || _markdownEditorRef_current1 === void 0 ? void 0 : _markdownEditorRef_current1.children
    ]);
    // 非hook变量声明
    var _ref = props.tagInputProps || {}, _ref_prefixCls = _ref.prefixCls, prefixCls = _ref_prefixCls === void 0 ? '$' : _ref_prefixCls;
    var baseClassName = "".concat(props.prefixCls, "-content");
    var onSlateChange = useRefFunction(function(v) {
        var _markdownEditorRef_current_operations;
        // 忽略初始化时的第一次变化
        if (first.current) {
            setTimeout(function() {
                first.current = false;
            }, 100);
            return;
        }
        // 更新当前值引用
        value.current = v;
        // 触发onChange回调
        onChange(v, markdownEditorRef.current.operations);
        // 检查是否存在非选区变化操作，如有则标记内容已变更
        var hasContentChanges = (_markdownEditorRef_current_operations = markdownEditorRef.current.operations) === null || _markdownEditorRef_current_operations === void 0 ? void 0 : _markdownEditorRef_current_operations.some(function(op) {
            return op.type !== 'set_selection';
        });
        if (hasContentChanges && !changedMark.current) {
            changedMark.current = true;
        }
    });
    var checkEnd = useRefFunction(function(e) {
        var _props_textAreaProps;
        // 如果启用打字机模式或为只读模式，不处理定位逻辑
        if (props === null || props === void 0 ? void 0 : props.typewriter) return;
        if (readonly) {
            // 点击时清除工具栏
            setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
            return;
        }
        // 获取目标元素
        var target = e.target;
        // 如果启用文本区域模式，不处理定位逻辑
        if ((_props_textAreaProps = props.textAreaProps) === null || _props_textAreaProps === void 0 ? void 0 : _props_textAreaProps.enable) {
            return false;
        }
        // 检查是否点击在编辑器内容区域
        if (target.dataset.slateEditor) {
            var _target_lastElementChild;
            // 获取最后一个元素的顶部位置
            var top = (_target_lastElementChild = target.lastElementChild) === null || _target_lastElementChild === void 0 ? void 0 : _target_lastElementChild.offsetTop;
            // 判断点击位置是否在编辑器内容底部区域
            // 当点击位置距离顶部的距离大于最后一个元素的顶部位置时，认为点击在底部区域
            if (markdownContainerRef.current && markdownContainerRef.current.scrollTop + e.clientY - 60 > top) {
                // 尝试将光标设置到编辑器内容末尾
                if (EditorUtils.checkEnd(markdownEditorRef.current)) {
                    e.preventDefault();
                }
            }
        }
    });
    var handleClipboardCopy = useRefFunction(function(event, operationType) {
        try {
            var _markdownEditorRef_current;
            // 1. 如果事件已被处理，则直接返回
            if (isEventHandled(event)) {
                return false;
            }
            // 2. 检查目标元素是否可编辑，如果不可编辑，则从DOM选区中获取编辑器选区
            if (operationType === 'copy' && !hasEditableTarget(markdownEditorRef.current, event.target)) {
                var domSelection = window.getSelection();
                markdownEditorRef.current.selection = getSelectionFromDomSelection(markdownEditorRef.current, domSelection);
            } else if (operationType === 'cut') {
                var domSelection1 = window.getSelection();
                markdownEditorRef.current.selection = getSelectionFromDomSelection(markdownEditorRef.current, domSelection1);
            }
            // 如果无法获取选区，则直接返回
            if (!markdownEditorRef.current.selection) {
                return false;
            }
            // 3. 处理复制/剪切选中内容
            if ((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.selection) {
                var _event_clipboardData;
                (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.clearData();
                var editor = markdownEditorRef.current;
                try {
                    // 复制HTML内容
                    var tempDiv = document.createElement('div');
                    var domRange = ReactEditor.toDOMRange(editor, editor.selection);
                    var selectedHtml = domRange.cloneContents();
                    tempDiv.appendChild(selectedHtml);
                    event.clipboardData.setData('text/html', tempDiv.innerHTML);
                    tempDiv === null || tempDiv === void 0 ? void 0 : tempDiv.remove();
                    // 设置Slate编辑器特定的片段数据，用于保留格式信息
                    event.clipboardData.setData('application/x-slate-md-fragment', JSON.stringify((editor === null || editor === void 0 ? void 0 : editor.getFragment()) || []));
                    event.clipboardData.setData('text/plain', parserSlateNodeToMarkdown(editor === null || editor === void 0 ? void 0 : editor.getFragment()));
                    event.clipboardData.setData('text/markdown', parserSlateNodeToMarkdown(editor === null || editor === void 0 ? void 0 : editor.getFragment()));
                    // 4. 设置剪贴板的片段数据
                    ReactEditor.setFragmentData(markdownEditorRef.current, event.clipboardData, operationType);
                    // 5. 如果是剪切操作，删除选中内容
                    if (operationType === 'cut') {
                        Transforms.delete(markdownEditorRef.current, {
                            at: markdownEditorRef.current.selection
                        });
                    }
                    // 阻止默认行为和事件冒泡
                    event.preventDefault();
                    return true;
                } catch (innerError) {
                    console.error('Error during clipboard operation:', innerError);
                    return false;
                }
            }
            return false;
        } catch (error) {
            console.error('Clipboard copy/cut operation failed:', error);
            return false;
        }
    });
    var handleKeyDown = useRefFunction(function(event) {
        var _props_tagInputProps, _flat;
        if (((_props_tagInputProps = props.tagInputProps) === null || _props_tagInputProps === void 0 ? void 0 : _props_tagInputProps.enable) && ((_flat = [
            prefixCls
        ].flat(2)) === null || _flat === void 0 ? void 0 : _flat.includes(event === null || event === void 0 ? void 0 : event.key))) {
            event.preventDefault();
            event.stopPropagation();
            Transforms.insertNodes(markdownEditorRef.current, [
                {
                    code: true,
                    tag: true,
                    autoOpen: true,
                    text: (event === null || event === void 0 ? void 0 : event.key) + ' ',
                    triggerText: event === null || event === void 0 ? void 0 : event.key
                }
            ]);
            return;
        }
        onKeyDown(event);
    });
    /**
   * 初始化编辑器
   */ var initialNote = function initialNote() {
        return _async_to_generator(function() {
            var tableConfig, _props_initSchemaValue;
            return _ts_generator(this, function(_state) {
                if (props.instance) {
                    nodeRef.current = props.instance;
                    first.current = true;
                    tableConfig = props.tableConfig;
                    genTableMinSize(props.initSchemaValue || [], {
                        minColumn: tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.minColumn,
                        minRows: tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.minRows
                    });
                    try {
                        ;
                        EditorUtils.reset(markdownEditorRef.current, ((_props_initSchemaValue = props.initSchemaValue) === null || _props_initSchemaValue === void 0 ? void 0 : _props_initSchemaValue.length) ? props.initSchemaValue : undefined);
                    } catch (e) {
                        EditorUtils.deleteAll(markdownEditorRef.current);
                    }
                } else {
                    nodeRef.current = undefined;
                }
                return [
                    2
                ];
            });
        })();
    };
    useEffect(function() {
        if (nodeRef.current !== props.instance) {
            initialNote();
        }
    }, [
        props.instance,
        markdownEditorRef.current
    ]);
    /**
   * 处理粘贴事件，会把粘贴的内容转换为对应的节点
   * @description paste event
   * @param {React.ClipboardEvent<HTMLDivElement>} e
   */ var onPaste = useRefFunction(function(event) {
        return _async_to_generator(function() {
            return _ts_generator(this, function(_state) {
                switch(_state.label){
                    case 0:
                        return [
                            4,
                            handlePasteEvent(event)
                        ];
                    case 1:
                        _state.sent();
                        return [
                            2
                        ];
                }
            });
        })();
    });
    /**
   * 实际的粘贴处理逻辑
   */ var handlePasteEvent = function handlePasteEvent(event) {
        return _async_to_generator(function() {
            var _props_onPaste, _event_clipboardData, pasteConfig, currentTextSelection, nodeList, curNode, result, types, allowedTypes, result1, _event_clipboardData_getData, _event_clipboardData_getData1, _event_clipboardData1, text, _event_clipboardData_getData2, _event_clipboardData_getData3, _event_clipboardData2, text1, selection, e;
            return _ts_generator(this, function(_state) {
                switch(_state.label){
                    case 0:
                        event.stopPropagation();
                        event.preventDefault();
                        // 检查粘贴配置
                        pasteConfig = props.pasteConfig;
                        if ((pasteConfig === null || pasteConfig === void 0 ? void 0 : pasteConfig.enabled) === false) {
                            return [
                                2
                            ]; // 如果禁用粘贴功能，直接返回
                        }
                        currentTextSelection = markdownEditorRef.current.selection;
                        if (currentTextSelection && currentTextSelection.anchor && Editor.hasPath(markdownEditorRef.current, currentTextSelection.anchor.path)) {
                            if (!Range.isCollapsed(currentTextSelection)) {
                                Transforms.delete(markdownEditorRef.current, {
                                    at: currentTextSelection,
                                    reverse: true
                                });
                            }
                        }
                        if (currentTextSelection) {
                            nodeList = Editor === null || Editor === void 0 ? void 0 : Editor.node(markdownEditorRef.current, currentTextSelection.focus.path);
                            curNode = nodeList === null || nodeList === void 0 ? void 0 : nodeList.at(0);
                            if (handleTagNodePaste(markdownEditorRef.current, currentTextSelection, event.clipboardData, curNode)) {
                                return [
                                    2
                                ];
                            }
                        }
                        result = (_props_onPaste = props.onPaste) === null || _props_onPaste === void 0 ? void 0 : _props_onPaste.call(props, event);
                        if (result === false) {
                            return [
                                2
                            ];
                        }
                        types = ((_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.types) || [
                            'text/plain'
                        ];
                        // 获取允许的类型
                        allowedTypes = (pasteConfig === null || pasteConfig === void 0 ? void 0 : pasteConfig.allowedTypes) || defaultAllowedTypes;
                        // 1. 首先尝试处理 slate-md-fragment
                        if (types.includes('application/x-slate-md-fragment') && allowedTypes.includes('application/x-slate-md-fragment')) {
                            if (handleSlateMarkdownFragment(markdownEditorRef.current, event.clipboardData, currentTextSelection)) {
                                return [
                                    2
                                ];
                            }
                        }
                        if (!(types.includes('text/html') && allowedTypes.includes('text/html'))) return [
                            3,
                            2
                        ];
                        event.stopPropagation();
                        event.preventDefault();
                        return [
                            4,
                            handleHtmlPaste(markdownEditorRef.current, event.clipboardData, props)
                        ];
                    case 1:
                        result1 = _state.sent();
                        if (result1) {
                            return [
                                2
                            ];
                        }
                        _state.label = 2;
                    case 2:
                        if (!(types.includes('Files') && allowedTypes.includes('Files'))) return [
                            3,
                            4
                        ];
                        event.stopPropagation();
                        event.preventDefault();
                        return [
                            4,
                            handleFilesPaste(markdownEditorRef.current, event.clipboardData, props)
                        ];
                    case 3:
                        if (_state.sent()) {
                            return [
                                2
                            ];
                        }
                        _state.label = 4;
                    case 4:
                        if (types.includes('text/markdown') && allowedTypes.includes('text/markdown')) {
                            ;
                            event.stopPropagation();
                            event.preventDefault();
                            text = ((_event_clipboardData1 = event.clipboardData) === null || _event_clipboardData1 === void 0 ? void 0 : (_event_clipboardData_getData1 = _event_clipboardData1.getData) === null || _event_clipboardData_getData1 === void 0 ? void 0 : (_event_clipboardData_getData = _event_clipboardData_getData1.call(_event_clipboardData1, 'text/markdown')) === null || _event_clipboardData_getData === void 0 ? void 0 : _event_clipboardData_getData.trim()) || '';
                            if (text) {
                                Transforms.insertFragment(markdownEditorRef.current, parserMdToSchema(text, plugins).schema);
                            }
                            return [
                                2
                            ];
                        }
                        if (!(types.includes('text/plain') && allowedTypes.includes('text/plain'))) return [
                            3,
                            8
                        ];
                        event.stopPropagation();
                        event.preventDefault();
                        text1 = ((_event_clipboardData2 = event.clipboardData) === null || _event_clipboardData2 === void 0 ? void 0 : (_event_clipboardData_getData3 = _event_clipboardData2.getData) === null || _event_clipboardData_getData3 === void 0 ? void 0 : (_event_clipboardData_getData2 = _event_clipboardData_getData3.call(_event_clipboardData2, 'text/plain')) === null || _event_clipboardData_getData2 === void 0 ? void 0 : _event_clipboardData_getData2.trim()) || '';
                        if (!text1) return [
                            2
                        ];
                        selection = markdownEditorRef.current.selection;
                        // 如果是表格或者代码块，直接插入文本
                        if (shouldInsertTextDirectly(markdownEditorRef.current, selection)) {
                            Transforms.insertText(markdownEditorRef.current, text1);
                            return [
                                2
                            ];
                        }
                        _state.label = 5;
                    case 5:
                        _state.trys.push([
                            5,
                            7,
                            ,
                            8
                        ]);
                        // 处理特殊文本格式（media:// 和 attach:// 链接）
                        if (handleSpecialTextPaste(markdownEditorRef.current, text1, selection)) {
                            return [
                                2
                            ];
                        }
                        // 处理 HTTP 链接
                        if (handleHttpLinkPaste(markdownEditorRef.current, text1, selection, store)) {
                            return [
                                2
                            ];
                        }
                        return [
                            4,
                            handlePlainTextPaste(markdownEditorRef.current, text1, selection, plugins)
                        ];
                    case 6:
                        // 处理普通文本
                        if (_state.sent()) {
                            return [
                                2
                            ];
                        }
                        return [
                            3,
                            8
                        ];
                    case 7:
                        e = _state.sent();
                        console.log('insert error', e);
                        return [
                            3,
                            8
                        ];
                    case 8:
                        // 5. 如果前面的处理都失败了，才使用默认的插入行为
                        if (hasEditableTarget(markdownEditorRef.current, event.target)) {
                            ReactEditor.insertData(markdownEditorRef.current, event.clipboardData);
                        }
                        return [
                            2
                        ];
                }
            });
        })();
    };
    /**
   * 处理输入法开始事件
   */ var onCompositionStart = function onCompositionStart(e) {
        var _markdownEditorRef_current_selection;
        if (markdownContainerRef.current) {
            markdownContainerRef.current.setAttribute('data-composition', '');
        }
        store.inputComposition = true;
        var focusPath = ((_markdownEditorRef_current_selection = markdownEditorRef.current.selection) === null || _markdownEditorRef_current_selection === void 0 ? void 0 : _markdownEditorRef_current_selection.focus.path) || [];
        if (focusPath.length > 0) {
            var _markdownEditorRef_current_selection1;
            var node = Node.get(markdownEditorRef.current, ((_markdownEditorRef_current_selection1 = markdownEditorRef.current.selection) === null || _markdownEditorRef_current_selection1 === void 0 ? void 0 : _markdownEditorRef_current_selection1.focus.path) || []);
            if (node) {
                var dom = ReactEditor.toDOMNode(markdownEditorRef.current, node);
                if (dom) {
                    var tagInput = dom.querySelector('[data-tag-popup-input]');
                    if (tagInput) {
                        tagInput.setAttribute('data-composition', '');
                    }
                }
            }
        }
        if (markdownEditorRef.current.selection && Range.isCollapsed(markdownEditorRef.current.selection)) {
            e.preventDefault();
        }
    };
    /**
   * 处理输入法结束事件
   */ var onCompositionEnd = function onCompositionEnd() {
        var _markdownEditorRef_current_selection;
        store.inputComposition = false;
        if (markdownContainerRef.current) {
            markdownContainerRef.current.removeAttribute('data-composition');
        }
        var focusPath = ((_markdownEditorRef_current_selection = markdownEditorRef.current.selection) === null || _markdownEditorRef_current_selection === void 0 ? void 0 : _markdownEditorRef_current_selection.focus.path) || [];
        if (focusPath.length > 0) {
            var _markdownEditorRef_current_selection1;
            var node = Node.get(markdownEditorRef.current, ((_markdownEditorRef_current_selection1 = markdownEditorRef.current.selection) === null || _markdownEditorRef_current_selection1 === void 0 ? void 0 : _markdownEditorRef_current_selection1.focus.path) || []);
            if (node) {
                var dom = ReactEditor.toDOMNode(markdownEditorRef.current, node);
                if (dom) {
                    var tagInput = dom.querySelector('[data-tag-popup-input]');
                    if (tagInput) {
                        tagInput.removeAttribute('data-composition');
                    }
                }
            }
        }
    };
    var elementRenderElement = useRefFunction(function(eleProps) {
        var _props_lazy;
        // 在每个渲染周期的第一次调用时重置索引
        if (!hasResetIndexRef.current) {
            lazyElementIndexRef.current = 0;
            hasResetIndexRef.current = true;
            // 使用 Promise 在下一个事件循环重置标记
            Promise.resolve().then(function() {
                hasResetIndexRef.current = false;
            });
        }
        var defaultDom = /*#__PURE__*/ React.createElement(ErrorBoundary, {
            fallbackRender: function fallbackRender() {
                return null;
            }
        }, /*#__PURE__*/ React.createElement(MElement, _object_spread_props(_object_spread({}, eleProps), {
            children: eleProps.children,
            readonly: readonly,
            deps: props.deps
        })));
        var renderedDom = defaultDom;
        var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
        try {
            // First check for plugin components
            for(var _iterator = plugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
                var plugin = _step.value;
                var _plugin_elements;
                var Component = (_plugin_elements = plugin.elements) === null || _plugin_elements === void 0 ? void 0 : _plugin_elements[eleProps.element.type];
                if (Component) {
                    renderedDom = /*#__PURE__*/ React.createElement(Component, eleProps);
                    break;
                }
            }
        } catch (err) {
            _didIteratorError = true;
            _iteratorError = err;
        } finally{
            try {
                if (!_iteratorNormalCompletion && _iterator.return != null) {
                    _iterator.return();
                }
            } finally{
                if (_didIteratorError) {
                    throw _iteratorError;
                }
            }
        }
        // Then allow eleItemRender to process the result
        if (props.eleItemRender) {
            if (eleProps.element.type !== 'table-cell' && eleProps.element.type !== 'table-row') {
                renderedDom = props.eleItemRender(eleProps, renderedDom);
            }
        }
        // Finally, wrap with LazyElement if lazy mode is enabled
        if ((_props_lazy = props.lazy) === null || _props_lazy === void 0 ? void 0 : _props_lazy.enable) {
            var _props_lazy1, _props_lazy2, _props_lazy3;
            // 不对表格单元格和表格行进行懒加载，避免破坏表格结构
            if (eleProps.element.type === 'table-cell' || eleProps.element.type === 'table-row') {
                return renderedDom;
            }
            // 获取当前索引并递增
            var currentIndex = lazyElementIndexRef.current;
            lazyElementIndexRef.current += 1;
            // 计算总元素数
            var totalElements = countLazyElements(value.current);
            return /*#__PURE__*/ React.createElement(LazyElement, {
                placeholderHeight: (_props_lazy1 = props.lazy) === null || _props_lazy1 === void 0 ? void 0 : _props_lazy1.placeholderHeight,
                rootMargin: (_props_lazy2 = props.lazy) === null || _props_lazy2 === void 0 ? void 0 : _props_lazy2.rootMargin,
                renderPlaceholder: (_props_lazy3 = props.lazy) === null || _props_lazy3 === void 0 ? void 0 : _props_lazy3.renderPlaceholder,
                elementInfo: {
                    type: eleProps.element.type,
                    index: currentIndex,
                    total: totalElements
                }
            }, renderedDom);
        }
        return renderedDom;
    });
    var renderMarkdownLeaf = useRefFunction(function(leafComponentProps) {
        var defaultDom = /*#__PURE__*/ React.createElement(MLeaf, _object_spread_props(_object_spread({}, leafComponentProps), {
            fncProps: props.fncProps,
            comment: props === null || props === void 0 ? void 0 : props.comment,
            children: leafComponentProps.children,
            tagInputProps: props.tagInputProps,
            linkConfig: props.linkConfig,
            readonly: readonly
        }));
        if (!props.leafRender) return defaultDom;
        return props.leafRender(_object_spread_props(_object_spread({}, leafComponentProps), {
            fncProps: props.fncProps,
            comment: props === null || props === void 0 ? void 0 : props.comment,
            hashId: hashId,
            tagInputProps: props.tagInputProps
        }), defaultDom);
    });
    var decorateFn = function decorateFn(e) {
        var _props_comment;
        // 始终运行 useHighlight，以支持 fnc（脚注）、链接等基础展示
        var decorateList = high(e) || [];
        if (!(props === null || props === void 0 ? void 0 : props.comment)) return decorateList;
        if ((props === null || props === void 0 ? void 0 : (_props_comment = props.comment) === null || _props_comment === void 0 ? void 0 : _props_comment.enable) === false) return decorateList;
        if (commentMap.size === 0) return decorateList;
        try {
            var ranges = [];
            var _e = _sliced_to_array(e, 2), path = _e[1];
            var itemMap = commentMap.get(path.join(','));
            if (!itemMap) return decorateList;
            itemMap.forEach(function(itemList) {
                itemList === null || itemList === void 0 ? void 0 : itemList.forEach(function(item) {
                    var _ref = item.selection || {}, anchor = _ref.anchor, focus = _ref.focus;
                    var newSelection = undefined;
                    var fragment = undefined;
                    if (anchor && focus && isPath(anchor.path) && focus.path && isPath(focus.path) && Editor.hasPath(markdownEditorRef.current, anchor.path) && Editor.hasPath(markdownEditorRef.current, focus.path)) {
                        newSelection = {
                            anchor: {
                                path: findLeafPath(markdownEditorRef.current, anchor.path),
                                offset: anchor.offset
                            },
                            focus: {
                                path: findLeafPath(markdownEditorRef.current, focus.path),
                                offset: focus.offset
                            }
                        };
                        fragment = Editor.fragment(markdownEditorRef.current, newSelection);
                    } else if (item.refContent) {
                        var findDom = findByPathAndText(markdownEditorRef.current, item.path, item.refContent).at(0);
                        if (findDom) {
                            newSelection = {
                                anchor: _object_spread_props(_object_spread({}, anchor), {
                                    path: findLeafPath(markdownEditorRef.current, findDom.path),
                                    offset: findDom.offset.start
                                }),
                                focus: _object_spread_props(_object_spread({}, focus), {
                                    path: findLeafPath(markdownEditorRef.current, findDom.path),
                                    offset: findDom.offset.end
                                })
                            };
                            fragment = Editor.fragment(markdownEditorRef.current, newSelection);
                        } else {
                            // 检查 focus.path 是否存在且有效
                            if (focus && focus.path && isPath(focus.path) && Editor.hasPath(markdownEditorRef.current, focus.path)) {
                                try {
                                    // 获取 focus.path 对应的节点
                                    var _Editor_node = _sliced_to_array(Editor.node(markdownEditorRef.current, item.path), 1), node = _Editor_node[0];
                                    // 检查该节点是否是 table 类型
                                    if ((node === null || node === void 0 ? void 0 : node.type) === 'table' || (node === null || node === void 0 ? void 0 : node.type) === 'card') {
                                        // 获取 table 节点的开始和结尾位置
                                        var startPoint = Editor.start(markdownEditorRef.current, item.path);
                                        var endPoint = Editor.end(markdownEditorRef.current, item.path);
                                        newSelection = {
                                            anchor: startPoint,
                                            focus: endPoint
                                        };
                                        fragment = Editor.fragment(markdownEditorRef.current, newSelection);
                                    }
                                } catch (error) {
                                    console.error('Error selecting table node:', error);
                                }
                            }
                        }
                    }
                    // 尝试调整路径，处理可能的节点变化
                    if (fragment && newSelection) {
                        var newAnchorPath = newSelection.anchor.path;
                        var newFocusPath = newSelection.focus.path;
                        if (isPath(newFocusPath) && isPath(newAnchorPath) && Editor.hasPath(markdownEditorRef.current, newAnchorPath) && Editor.hasPath(markdownEditorRef.current, newFocusPath)) {
                            ranges.push({
                                anchor: {
                                    path: newAnchorPath,
                                    offset: newSelection.anchor.offset
                                },
                                focus: {
                                    path: newFocusPath,
                                    offset: newSelection.focus.offset
                                },
                                data: itemList,
                                comment: true,
                                id: item.id,
                                selection: newSelection,
                                updateTime: itemList.map(function(i) {
                                    return i.updateTime;
                                }).sort().join(',')
                            });
                        }
                    }
                });
            });
            return decorateList.concat(ranges);
        } catch (error) {
            console.log('error', error);
            return decorateList;
        }
    };
    // 在 SSR 环境下，如果有 initSchemaValue，直接使用它作为初始值
    // 因为 useEffect 在 SSR 环境下不会执行，initialNote 不会被调用
    var initialValue = useMemo(function() {
        var _props_initSchemaValue;
        if ((_props_initSchemaValue = props.initSchemaValue) === null || _props_initSchemaValue === void 0 ? void 0 : _props_initSchemaValue.length) {
            return props.initSchemaValue;
        }
        return [
            EditorUtils.p
        ];
    }, [
        props.initSchemaValue
    ]);
    var _obj;
    return wrapSSR(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Slate, {
        editor: markdownEditorRef.current,
        initialValue: initialValue,
        onChange: onSlateChange
    }, /*#__PURE__*/ React.createElement(Editable, {
        decorate: decorateFn,
        onDragOver: function onDragOver(e) {
            return e.preventDefault();
        },
        readOnly: readonly,
        spellCheck: false,
        autoCorrect: "off",
        autoCapitalize: "none",
        onCompositionStart: onCompositionStart,
        onCompositionEnd: onCompositionEnd,
        className: classNames(props.className, baseClassName, (_obj = {}, _define_property(_obj, "".concat(baseClassName, "-").concat(readonlyCls), readonlyCls), _define_property(_obj, "".concat(baseClassName, "-report"), props.reportMode), _define_property(_obj, "".concat(baseClassName, "-edit"), !readonly), _define_property(_obj, "".concat(baseClassName, "-compact"), props.compact), _obj), hashId),
        style: props.style,
        onSelect: handleSelectionChange.run,
        onCut: function onCut(event) {
            var handled = handleClipboardCopy(event, 'cut');
            if (!handled) {
                event.preventDefault();
            }
        },
        onFocus: function onFocus(e) {
            var _props_onFocus;
            (_props_onFocus = props.onFocus) === null || _props_onFocus === void 0 ? void 0 : _props_onFocus.call(props, parserSlateNodeToMarkdown(markdownEditorRef.current.children), markdownEditorRef.current.children, e);
        },
        onBlur: function onBlur() {
            // 失去焦点时清除工具栏
            setDomRect === null || setDomRect === void 0 ? void 0 : setDomRect(null);
        },
        onMouseDown: checkEnd,
        onPaste: function onPaste1(event) {
            event.preventDefault();
            event.stopPropagation();
            onPaste(event);
        },
        onCopy: function onCopy(event) {
            var handled = handleClipboardCopy(event, 'copy');
            if (!handled) {
                event.preventDefault();
            }
        },
        renderElement: elementRenderElement,
        renderLeaf: renderMarkdownLeaf,
        onKeyDown: handleKeyDown
    }))));
});
