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 _class_call_check(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
    }
}
function _defineProperties(target, props) {
    for(var i = 0; i < props.length; i++){
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) descriptor.writable = true;
        Object.defineProperty(target, descriptor.key, descriptor);
    }
}
function _create_class(Constructor, protoProps, staticProps) {
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
    if (staticProps) _defineProperties(Constructor, staticProps);
    return Constructor;
}
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 _instanceof(left, right) {
    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
        return !!right[Symbol.hasInstance](left);
    } else {
        return left instanceof right;
    }
}
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);
}
/* eslint-disable @typescript-eslint/no-this-alias */ /* eslint-disable no-param-reassign */ import isEqual from "lodash-es/isEqual";
import { parse } from "querystring";
import * as React from "react";
import { Editor, Element, Node, Path, Range, Text, Transforms } from "slate";
import { ReactEditor } from "slate-react";
import { parserMdToSchema } from "./parser/parserMdToSchema";
import { parserSlateNodeToMarkdown } from "./parser/parserSlateNodeToMarkdown";
import { getOffsetLeft, getOffsetTop } from "./utils/dom";
import { EditorUtils, findByPathAndText } from "./utils/editorUtils";
import { markdownToHtmlSync } from "./utils/markdownToHtml";
var createContext = React.createContext, useContext = React.useContext;
export var EditorStoreContext = createContext(null);
/**
 * 获取编辑器存储上下文的Hook
 *
 * 提供安全的上下文访问，包含默认值处理
 *
 * @returns 编辑器存储上下文对象
 *
 * @example
 * ```tsx
 * const { store, readonly, typewriter } = useEditorStore();
 * ```
 */ export var useEditorStore = function useEditorStore() {
    return useContext(EditorStoreContext) || {
        store: {},
        readonly: true,
        typewriter: false,
        editorProps: {},
        markdownEditorRef: {},
        openJinjaTemplate: false,
        setOpenJinjaTemplate: undefined,
        jinjaAnchorPath: null,
        setJinjaAnchorPath: undefined,
        jinjaEnabled: false,
        jinjaTemplatePanelEnabled: false
    };
};
/** 支持键入操作的标签类型列表 */ var SUPPORT_TYPING_TAG = [
    'table-cell',
    'paragraph',
    'head'
];
/**
 * 编辑器核心状态管理类
 *
 * 负责管理编辑器的所有状态、操作和事件处理
 * 包括文档结构、选择状态、高亮、拖拽、历史记录等
 *
 * @class
 */ export var EditorStore = /*#__PURE__*/ function() {
    "use strict";
    function EditorStore(_editor, plugins, markdownToHtmlOptions) {
        var _this = this;
        _class_call_check(this, EditorStore);
        /** 高亮缓存映射表 */ _define_property(this, "highlightCache", new Map());
        /** 允许进入的元素类型集合 */ _define_property(this, "ableToEnter", new Set([
            'paragraph',
            'head',
            'blockquote',
            'code',
            'table',
            'list',
            'media',
            'attach'
        ]));
        /** 当前拖拽的元素 */ _define_property(this, "draggedElement", null);
        _define_property(this, "footnoteDefinitionMap", new Map());
        _define_property(this, "inputComposition", false);
        _define_property(this, "plugins", void 0);
        _define_property(this, "domRect", null);
        _define_property(this, "_editor", void 0);
        /** 当前 setMDContent 操作的 AbortController */ _define_property(this, "_currentAbortController", null);
        _define_property(this, "markdownToHtmlOptions", void 0);
        /**
   * 移除节点
   * @param options
   */ _define_property(this, "removeNodes", function(options) {
            Transforms.removeNodes(_this._editor.current, options);
        });
        this.dragStart = this.dragStart.bind(this);
        this._editor = _editor;
        this.plugins = plugins;
        this.markdownToHtmlOptions = markdownToHtmlOptions;
    }
    _create_class(EditorStore, [
        {
            key: "editor",
            get: /**
   * 获取当前编辑器实例。
   *
   * @returns 当前的 Slate 编辑器实例。
   */ function get() {
                return this._editor.current;
            }
        },
        {
            /**
   * 聚焦到编辑器
   */ key: "focus",
            value: function focus() {
                var editor = this._editor.current;
                try {
                    // 1. 确保编辑器获得焦点（异步，需要单独 try-catch 防止白屏）
                    setTimeout(function() {
                        try {
                            ReactEditor.focus(editor);
                        } catch (e) {
                            console.error('ReactEditor.focus 失败:', e);
                        }
                    }, 0);
                    // 2. 处理空文档情况
                    if (editor.children.length === 0) {
                        var defaultNode = {
                            type: 'paragraph',
                            children: [
                                {
                                    text: ''
                                }
                            ]
                        };
                        Transforms.insertNodes(editor, defaultNode, {
                            at: [
                                0
                            ]
                        });
                    }
                    // 3. 获取文档末尾位置
                    var end = Editor.end(editor, []);
                    // 4. 设置光标位置
                    Transforms.select(editor, {
                        anchor: end,
                        focus: end
                    });
                } catch (error) {
                    console.error('移动光标失败:', error);
                }
            }
        },
        {
            key: "findLatest",
            value: /**
   * 查找最新的节点索引。
   *
   * @param node - 当前节点。
   * @param index - 当前索引路径。
   * @returns 最新节点的索引路径。
   */ function findLatest(node, index) {
                if (Array.isArray(node.children)) {
                    if (node.children.length === 1 && (SUPPORT_TYPING_TAG.includes(node.type) || !node.children[0].type)) {
                        return index;
                    }
                    return this.findLatest(node.children[node.children.length - 1], _to_consumable_array(index).concat([
                        node.children.length - 1
                    ]));
                }
                return index;
            }
        },
        {
            /**
   * 检查给定节点是否是最新节点。用于展示 闪动光标
   *
   * @param node - 要检查的节点。
   * @returns 如果节点是最新节点，则返回 true；否则返回 false。
   */ key: "isLatestNode",
            value: function isLatestNode(node) {
                try {
                    return this.findLatest(this._editor.current.children.at(-1), [
                        this._editor.current.children.length - 1
                    ]).join('-').startsWith(ReactEditor.findPath(this._editor.current, node).join('-'));
                } catch (error) {
                    return false;
                }
            }
        },
        {
            /**
   * 插入一个链接到编辑器中。
   *
   * @param filePath - 要插入的文件路径。如果路径以 'http' 开头，则链接文本为路径本身，否则为文件名。
   *
   * 该方法首先解析文件路径，并创建一个包含文本和 URL 的节点对象。
   * 然后，它检查当前编辑器的选区是否存在且未折叠。如果选区不存在或已折叠，则方法返回。
   *
   * 接下来，它查找当前选区所在的最低层级的元素节点。如果节点类型是 'table-cell' 或 'paragraph'，
   * 则在当前选区插入链接节点并选中它。
   *
   * 如果当前选区所在的元素节点类型不是 'table-cell' 或 'paragraph'，则查找包含当前选区的父级元素节点，
   * 并在其后插入一个包含链接节点的新段落。
   */ key: "insertLink",
            value: function insertLink(filePath) {
                var p = parse(filePath);
                var insertPath = filePath;
                var node = {
                    text: filePath.startsWith('http') ? filePath : p.name,
                    url: insertPath
                };
                var sel = this._editor.current.selection;
                if (!sel || !Range.isCollapsed(sel)) return;
                // @ts-ignore
                var _Editor_nodes = _sliced_to_array(Editor.nodes(this._editor.current, {
                    match: function match(n) {
                        return Element.isElement(n);
                    },
                    mode: 'lowest'
                }), 1), cur = _Editor_nodes[0];
                if (node.text && [
                    'table-cell',
                    'paragraph'
                ].includes(cur[0].type)) {
                    Transforms.insertNodes(this._editor.current, node, {
                        select: true
                    });
                } else {
                    // @ts-ignore
                    var _Editor_nodes1 = _sliced_to_array(Editor.nodes(this._editor.current, {
                        match: function match(n) {
                            return Element.isElement(n) && [
                                'table',
                                'code',
                                'head'
                            ].includes(n.type);
                        }
                    }), 1), par = _Editor_nodes1[0];
                    Transforms.insertNodes(this._editor.current, {
                        type: 'paragraph',
                        children: [
                            node
                        ]
                    }, {
                        select: true,
                        at: Path.next(par[1])
                    });
                }
            }
        },
        {
            /**
   * 插入节点到编辑器中。
   *
   * @param nodes - 要插入的节点，可以是单个节点或节点数组。
   * @param options - 可选参数，用于指定插入节点的选项。
   */ key: "insertNodes",
            value: function insertNodes(nodes, options) {
                Transforms.insertNodes(this._editor.current, nodes, options);
            }
        },
        {
            key: "toPath",
            value: /**
   * Converts an HTML element to a Slate path and node.
   *
   * @param el - The HTML element to convert.
   * @returns A tuple containing the path and the corresponding Slate node.
   * @private
   */ function toPath(el) {
                var node = ReactEditor.toSlateNode(this._editor.current, el);
                var path = ReactEditor.findPath(this._editor.current, node);
                return [
                    path,
                    node
                ];
            }
        },
        {
            /**
   * Clears all content from the editor, replacing it with an empty paragraph.
   */ key: "clearContent",
            value: function clearContent() {
                EditorUtils.replaceEditorContent(this._editor.current, [
                    {
                        type: 'paragraph',
                        children: [
                            {
                                text: ''
                            }
                        ]
                    }
                ]);
            }
        },
        {
            /**
   * 从 markdown 文本设置编辑器内容
   *
   * @param md - 要设置为编辑器内容的 Markdown 字符串
   *             如果为 undefined，方法将直接返回不做任何更改
   *             如果 markdown 与当前内容相同，则不做任何更改
   * @param plugins - 可选的自定义 markdown 解析插件
   * @param options - 可选的配置参数
   *   - chunkSize: 分块大小阈值，默认 5000 字符。超过此大小会启用分批处理
   *   - separator: 分隔符，默认为双换行符 '\n\n'，用于拆分长文本
   *   - useRAF: 是否使用 requestAnimationFrame 优化，默认 true，避免长文本处理时卡顿
   *   - batchSize: 每帧处理的节点数量，默认 50，仅在 useRAF=true 时生效
   *   - onProgress: 进度回调函数，接收当前进度 (0-1) 作为参数
   * @returns 如果使用 RAF，返回 Promise；否则同步执行
   */ key: "setMDContent",
            value: function setMDContent(md, plugins, options) {
                var _ref, _ref1, _ref2, _ref3;
                if (md === undefined) return;
                if (!md) {
                    if (this._shouldSkipSetContent('')) return;
                    this.clearContent();
                    return;
                }
                if (this._shouldSkipSetContent(md)) return;
                this.cancelSetMDContent();
                var chunkSize = (_ref = options === null || options === void 0 ? void 0 : options.chunkSize) !== null && _ref !== void 0 ? _ref : 5000;
                var separator = (_ref1 = options === null || options === void 0 ? void 0 : options.separator) !== null && _ref1 !== void 0 ? _ref1 : /\n\n/;
                var useRAF = (_ref2 = options === null || options === void 0 ? void 0 : options.useRAF) !== null && _ref2 !== void 0 ? _ref2 : false;
                var batchSize = (_ref3 = options === null || options === void 0 ? void 0 : options.batchSize) !== null && _ref3 !== void 0 ? _ref3 : 50;
                var targetPlugins = plugins || this.plugins;
                if (md.length <= chunkSize) {
                    return this._setShortContent(md, targetPlugins, options === null || options === void 0 ? void 0 : options.onProgress);
                }
                var chunks = this._splitMarkdown(md, separator);
                if (!useRAF) {
                    return this._setLongContentSync(chunks, targetPlugins, options === null || options === void 0 ? void 0 : options.onProgress);
                }
                if (chunks.length > 10) {
                    this._currentAbortController = new AbortController();
                    return this._parseAndSetContentWithRAF(chunks, targetPlugins || [], batchSize, options === null || options === void 0 ? void 0 : options.onProgress, this._currentAbortController.signal);
                }
                return this._setLongContentSync(chunks, targetPlugins, options === null || options === void 0 ? void 0 : options.onProgress);
            }
        },
        {
            key: "_shouldSkipSetContent",
            value: /**
   * 检查是否应该跳过设置内容
   */ function _shouldSkipSetContent(md) {
                try {
                    var currentMD = parserSlateNodeToMarkdown(this._editor.current.children);
                    return md.trim() === currentMD.trim();
                } catch (error) {
                    console.warn('Failed to compare current content, proceeding with setMDContent:', error);
                    return false;
                }
            }
        },
        {
            key: "_setShortContent",
            value: /**
   * 设置短内容（直接处理）
   */ function _setShortContent(md, plugins, onProgress) {
                try {
                    var nodeList = parserMdToSchema(md, plugins).schema;
                    this._editor.current.selection = null;
                    this.setContent(nodeList);
                    this._safeDeselect();
                    onProgress === null || onProgress === void 0 ? void 0 : onProgress(1);
                } catch (error) {
                    console.error('Failed to set MD content:', error);
                    throw error;
                }
            }
        },
        {
            key: "_setLongContentSync",
            value: /**
   * 同步设置长内容
   */ function _setLongContentSync(chunks, plugins, onProgress) {
                try {
                    var allNodes = this._parseChunksToNodes(chunks, plugins);
                    if (allNodes.length > 0) {
                        this._editor.current.selection = null;
                        this.setContent(allNodes);
                        this._safeDeselect();
                    }
                    onProgress === null || onProgress === void 0 ? void 0 : onProgress(1);
                } catch (error) {
                    console.error('Failed to set MD content synchronously:', error);
                    throw error;
                }
            }
        },
        {
            key: "_parseChunksToNodes",
            value: /**
   * 解析分块为节点列表
   */ function _parseChunksToNodes(chunks, plugins) {
                var allNodes = [];
                var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
                try {
                    for(var _iterator = chunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
                        var chunk = _step.value;
                        if (chunk.trim()) {
                            var _allNodes;
                            var schema = parserMdToSchema(chunk, plugins).schema;
                            (_allNodes = allNodes).push.apply(_allNodes, _to_consumable_array(schema));
                        }
                    }
                } catch (err) {
                    _didIteratorError = true;
                    _iteratorError = err;
                } finally{
                    try {
                        if (!_iteratorNormalCompletion && _iterator.return != null) {
                            _iterator.return();
                        }
                    } finally{
                        if (_didIteratorError) {
                            throw _iteratorError;
                        }
                    }
                }
                return allNodes;
            }
        },
        {
            /**
   * 取消当前正在进行的 setMDContent 操作
   */ key: "cancelSetMDContent",
            value: function cancelSetMDContent() {
                if (this._currentAbortController) {
                    this._currentAbortController.abort();
                    this._currentAbortController = null;
                }
            }
        },
        {
            key: "_safeDeselect",
            value: /**
   * 安全地取消编辑器选区。
   *
   * ReactEditor.deselect() 内部调用 window.getSelection().removeAllRanges()，
   * 当编辑器处于聚焦状态时，浏览器要求必须存在活跃选区才能操作，
   * 否则抛出 InvalidStateError("Failed to execute 'collapseToEnd' on 'Selection'")。
   *
   * 双重防御策略：
   * 1. isFocused 检查 —— 大多数情况下直接跳过（性能优先）
   * 2. try-catch —— 覆盖 isFocused 与 deselect 之间的竞态窗口
   */ function _safeDeselect() {
                if (ReactEditor.isFocused(this._editor.current)) return;
                try {
                    ReactEditor.deselect(this._editor.current);
                } catch (unused) {
                // InvalidStateError：编辑器在 isFocused 检查与 deselect 调用之间获得了焦点，忽略即可
                }
            }
        },
        {
            key: "_parseAndSetContentWithRAF",
            value: /**
   * 使用 requestAnimationFrame 分批解析和设置内容
   * 边解析边插入，实时显示内容
   *
   * @param chunks - markdown 分块数组
   * @param plugins - 解析插件
   * @param batchSize - 每帧处理的数量
   * @param onProgress - 进度回调函数
   * @returns Promise，在所有内容处理完成后 resolve
   * @private
   */ function _parseAndSetContentWithRAF(chunks, plugins, batchSize, onProgress, signal) {
                var _this = this;
                return new Promise(function(resolve, reject) {
                    var currentChunkIndex = 0;
                    var totalChunks = chunks.length;
                    var parseChunksPerFrame = Math.max(1, Math.floor(batchSize / 10)); // 每帧解析的 chunk 数
                    var isFirstBatch = true;
                    var rafId = null;
                    // 边解析边插入
                    var parseAndInsertNextBatch = function parseAndInsertNextBatch1() {
                        try {
                            // 检查是否被取消
                            if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
                                if (rafId) {
                                    cancelAnimationFrame(rafId);
                                    rafId = null;
                                }
                                _this._currentAbortController = null;
                                reject(new Error('Operation was cancelled'));
                                return;
                            }
                            // 检查编辑器是否仍然有效
                            if (!_this._editor.current) {
                                if (rafId) {
                                    cancelAnimationFrame(rafId);
                                    rafId = null;
                                }
                                _this._currentAbortController = null;
                                reject(new Error('Editor instance is no longer available'));
                                return;
                            }
                            var endIndex = Math.min(currentChunkIndex + parseChunksPerFrame, totalChunks);
                            // 解析当前批次的 chunks 并立即插入
                            for(var i = currentChunkIndex; i < endIndex; i++){
                                var chunk = chunks[i];
                                if (chunk.trim()) {
                                    try {
                                        var schema = parserMdToSchema(chunk, plugins).schema;
                                        if (schema.length > 0) {
                                            if (isFirstBatch) {
                                                EditorUtils.replaceEditorContent(_this._editor.current, schema);
                                                isFirstBatch = false;
                                            } else {
                                                // 后续批次：追加节点
                                                Transforms.insertNodes(_this._editor.current, schema, {
                                                    at: [
                                                        _this._editor.current.children.length
                                                    ]
                                                });
                                            }
                                        }
                                    } catch (chunkError) {
                                        // 单个 chunk 解析失败，记录但继续处理其他 chunks
                                        console.warn("Failed to parse chunk ".concat(i, ":"), chunkError);
                                    }
                                }
                            }
                            currentChunkIndex = endIndex;
                            // 更新进度
                            var progress = currentChunkIndex / totalChunks;
                            if (onProgress) {
                                try {
                                    onProgress(progress);
                                } catch (progressError) {
                                    // 进度回调失败不应该中断整个流程
                                    console.warn('Progress callback failed:', progressError);
                                }
                            }
                            if (currentChunkIndex < totalChunks) {
                                // 还有 chunks 未处理，继续下一帧
                                rafId = requestAnimationFrame(parseAndInsertNextBatch);
                            } else {
                                // 所有内容处理完成
                                _this._safeDeselect();
                                rafId = null;
                                _this._currentAbortController = null;
                                resolve();
                            }
                        } catch (error) {
                            // 清理资源并拒绝 Promise
                            if (rafId) {
                                cancelAnimationFrame(rafId);
                                rafId = null;
                            }
                            _this._currentAbortController = null;
                            reject(error);
                        }
                    };
                    // 开始处理
                    rafId = requestAnimationFrame(parseAndInsertNextBatch);
                });
            }
        },
        {
            key: "_splitMarkdown",
            value: /**
   * 按指定分隔符拆分 markdown 内容
   * 保持内容结构的完整性
   *
   * @param md - 要拆分的 markdown 字符串
   * @param separator - 分隔符，可以是字符串或正则表达式
   * @returns 拆分后的字符串数组
   * @private
   */ function _splitMarkdown(md, separator) {
                if (!md) {
                    return [];
                }
                var separatorMatches = this._collectSeparatorMatches(md, separator);
                if (separatorMatches.length === 0) {
                    return [
                        md
                    ];
                }
                var chunks = [];
                var start = 0;
                var currentMatchIndex = 0;
                var insideFence = false;
                var activeFence = null;
                var index = 0;
                while(index < md.length){
                    if (this._isLineStart(md, index)) {
                        var fence = this._matchFence(md, index);
                        if (fence) {
                            if (!insideFence) {
                                insideFence = true;
                                activeFence = fence.marker;
                            } else if (activeFence === fence.marker) {
                                insideFence = false;
                                activeFence = null;
                            }
                            index = fence.end;
                            continue;
                        }
                    }
                    var match = separatorMatches[currentMatchIndex];
                    if (!insideFence && match && index === match.index) {
                        var chunk = md.slice(start, index);
                        if (chunk.length > 0) {
                            chunks.push(chunk);
                        }
                        start = index + match.length;
                        currentMatchIndex += 1;
                        index = start;
                        continue;
                    }
                    index += 1;
                }
                var tail = md.slice(start);
                if (tail.length > 0) {
                    chunks.push(tail);
                }
                return chunks.length > 0 ? chunks : [
                    md
                ];
            }
        },
        {
            key: "_collectSeparatorMatches",
            value: function _collectSeparatorMatches(md, separator) {
                if (typeof separator === 'string') {
                    var matches = [];
                    var searchIndex = md.indexOf(separator);
                    while(searchIndex !== -1){
                        matches.push({
                            index: searchIndex,
                            length: separator.length
                        });
                        searchIndex = md.indexOf(separator, searchIndex + separator.length);
                    }
                    return matches;
                }
                var flags = separator.flags.includes('g') ? separator.flags : "".concat(separator.flags, "g");
                var globalRegex = new RegExp(separator.source, flags);
                var matches1 = [];
                var match;
                while((match = globalRegex.exec(md)) !== null){
                    var matchedText = match[0];
                    matches1.push({
                        index: match.index,
                        length: matchedText.length
                    });
                    if (matchedText.length === 0) {
                        globalRegex.lastIndex += 1;
                    }
                }
                return matches1;
            }
        },
        {
            key: "_isLineStart",
            value: function _isLineStart(content, position) {
                if (position === 0) {
                    return true;
                }
                return content[position - 1] === '\n';
            }
        },
        {
            key: "_matchFence",
            value: function _matchFence(content, position) {
                var cursor = position;
                var spaces = 0;
                while(cursor < content.length && content[cursor] === ' ' && spaces < 3){
                    cursor += 1;
                    spaces += 1;
                }
                if (cursor >= content.length) {
                    return null;
                }
                var char = content[cursor];
                if (char !== '`' && char !== '~') {
                    return null;
                }
                var fenceLength = 0;
                while(cursor < content.length && content[cursor] === char){
                    cursor += 1;
                    fenceLength += 1;
                }
                if (fenceLength < 3) {
                    return null;
                }
                var lineEnd = this._findLineEnd(content, cursor);
                return {
                    marker: char,
                    end: lineEnd
                };
            }
        },
        {
            key: "_findLineEnd",
            value: function _findLineEnd(content, position) {
                var cursor = position;
                while(cursor < content.length && content[cursor] !== '\n'){
                    cursor += 1;
                }
                if (cursor < content.length && content[cursor] === '\n') {
                    return cursor + 1;
                }
                return cursor;
            }
        },
        {
            /**
   * 获取当前编辑器内容作为节点列表
   *
   * @returns 当前编辑器内容的节点列表
   */ key: "getContent",
            value: function getContent() {
                var nodeList = this._editor.current.children;
                return nodeList;
            }
        },
        {
            /**
   * 获取当前编辑器内容作为 markdown 字符串
   *
   * @param plugins - 可选的自定义 markdown 转换插件
   * @returns 转换为 markdown 的当前编辑器内容
   */ key: "getMDContent",
            value: function getMDContent(plugins) {
                var nodeList = this._editor.current.children;
                var md = parserSlateNodeToMarkdown(nodeList, '', [
                    {
                        root: true
                    }
                ], plugins || this.plugins);
                return md;
            }
        },
        {
            /**
   * 获取当前编辑器内容作为 HTML 字符串
   *
   * @returns 转换为 HTML 的当前编辑器内容
   */ key: "getHtmlContent",
            value: function getHtmlContent(options) {
                var markdown = this.getMDContent();
                var appliedOptions = options !== null && options !== void 0 ? options : this.markdownToHtmlOptions;
                if (options) {
                    this.markdownToHtmlOptions = options;
                }
                return markdownToHtmlSync(markdown, appliedOptions);
            }
        },
        {
            key: "_getNodeFinished",
            value: /**
   * 获取节点的 finished 属性
   *
   * @param node - 节点对象
   * @returns finished 属性值
   * @private
   */ function _getNodeFinished(node) {
                var _ref;
                var _node_otherProps;
                return (_ref = node === null || node === void 0 ? void 0 : node.finished) !== null && _ref !== void 0 ? _ref : node === null || node === void 0 ? void 0 : (_node_otherProps = node.otherProps) === null || _node_otherProps === void 0 ? void 0 : _node_otherProps.finished;
            }
        },
        {
            key: "_isNodeEqual",
            value: /**
   * 比较两个节点的 hash 和 finished 是否相同
   *
   * @param newNode - 新节点
   * @param oldNode - 旧节点
   * @returns 如果 hash 和 finished 都相同返回 true，否则返回 false
   * @private
   */ function _isNodeEqual(newNode, oldNode) {
                var newHash = newNode === null || newNode === void 0 ? void 0 : newNode.hash;
                var oldHash = oldNode === null || oldNode === void 0 ? void 0 : oldNode.hash;
                var newFinished = this._getNodeFinished(newNode);
                var oldFinished = this._getNodeFinished(oldNode);
                return newHash !== undefined && oldHash !== undefined && newHash === oldHash && newFinished !== undefined && oldFinished !== undefined && newFinished === oldFinished;
            }
        },
        {
            key: "_replaceNodeAt",
            value: /**
   * 替换指定位置的节点
   *
   * @param path - 节点路径
   * @param newNode - 新节点
   * @private
   */ function _replaceNodeAt(path, newNode) {
                var _this = this;
                Editor.withoutNormalizing(this._editor.current, function() {
                    Transforms.removeNodes(_this._editor.current, {
                        at: path
                    });
                    Transforms.insertNodes(_this._editor.current, newNode, {
                        at: path
                    });
                });
            }
        },
        {
            /**
   * 使用节点列表设置编辑器内容
   *
   * @param nodeList - 要设置为编辑器内容的节点列表
   */ key: "setContent",
            value: function setContent(nodeList) {
                EditorUtils.replaceEditorContent(this._editor.current, nodeList);
            }
        },
        {
            /**
   * 使用差异检测和操作队列优化更新节点列表。
   *
   * @param nodeList - 新的节点列表
   *
   * 优化步骤：
   * 1. 过滤无效节点
   * 2. 计算 hash 并检查是否需要更新
   * 3. 生成差异操作
   * 4. 执行优化后的操作
   * 5. 处理可能的错误情况
   *
   * 过滤规则：
   * - 移除空的段落节点
   * - 移除空的列表节点
   * - 移除空的列表项节点
   * - 移除无效的代码块节点
   * - 移除无源的图片节点
   *
   * 错误处理：
   * - 如果优化更新失败，会回退到直接替换整个节点列表
   * - 错误信息会被记录到控制台
   */ key: "updateNodeList",
            value: function updateNodeList(nodeList) {
                var _this = this;
                if (!nodeList || !Array.isArray(nodeList)) return;
                var filteredNodes = nodeList.filter(function(item) {
                    return _this._isValidNode(item);
                });
                try {
                    var operations = this.generateDiffOperations(filteredNodes, this._editor.current.children);
                    if (operations.length > 0) {
                        this.executeOperations(operations);
                    }
                } catch (error) {
                    console.error('Failed to update nodes with optimized method:', error);
                    EditorUtils.replaceEditorContent(this._editor.current, nodeList);
                }
            }
        },
        {
            key: "_isValidNode",
            value: /**
   * 检查节点是否有效
   */ function _isValidNode(item) {
                if (!item) return false;
                if (item.type === 'p' && (!item.children || item.children.length === 0)) return false;
                if ((item.type === 'list' || item.type === 'bulleted-list' || item.type === 'numbered-list') && (!item.children || item.children.length === 0)) return false;
                if (item.type === 'listItem' && (!item.children || item.children.length === 0)) return false;
                if (item.type === 'code' && item.language === 'code' && (!item.otherProps || item.otherProps.length === 0)) return false;
                if (item.type === 'image' && !item.src) return false;
                return true;
            }
        },
        {
            key: "generateDiffOperations",
            value: /**
   * 生成两个节点列表之间的差异操作队列。
   *
   * @param newNodes - 新的节点列表
   * @param oldNodes - 旧的节点列表
   * @returns 包含所有需要执行的操作的队列
   *
   * 该方法通过以下步骤生成差异：
   * 1. 处理节点数量不同的情况
   * 2. 对共有节点进行深度比较
   * 3. 生成最小化的操作序列
   * 4. 根据优先级排序操作
   */ function generateDiffOperations(newNodes, oldNodes) {
                var operations = [];
                this.generateDiffOperationsInternal(newNodes, oldNodes, operations);
                // 只在最外层排序一次
                return operations.sort(function(a, b) {
                    return a.priority - b.priority;
                });
            }
        },
        {
            key: "generateDiffOperationsInternal",
            value: /**
   * 内部方法：生成差异操作，不进行排序。
   * 递归调用时使用此方法，避免重复排序。
   */ function generateDiffOperationsInternal(newNodes, oldNodes, operations) {
                if (!newNodes || !oldNodes) return;
                // 第一阶段：处理节点数量不同的情况
                var lengthDiff = newNodes.length - oldNodes.length;
                if (lengthDiff > 0) {
                    // 新列表比旧列表长，添加新节点
                    for(var i = oldNodes.length; i < newNodes.length; i++){
                        operations.push({
                            type: 'insert',
                            path: [
                                i
                            ],
                            node: newNodes[i],
                            priority: 10
                        });
                    }
                } else if (lengthDiff < 0) {
                    // 旧列表比新列表长，需要删除节点
                    // 从后往前删除，以避免索引问题
                    for(var i1 = oldNodes.length - 1; i1 >= newNodes.length; i1--){
                        operations.push({
                            type: 'remove',
                            path: [
                                i1
                            ],
                            priority: 0
                        });
                    }
                }
                // 第二阶段：深度比较共有的节点
                var minLength = Math.min(newNodes.length, oldNodes.length);
                for(var i2 = 0; i2 < minLength; i2++){
                    var newNode = newNodes[i2];
                    var oldNode = oldNodes[i2];
                    // 提前检查 hash，相同则跳过
                    if (newNode.hash && oldNode.hash && newNode.hash === oldNode.hash) {
                        continue;
                    }
                    this.compareNodes(newNode, oldNode, [
                        i2
                    ], operations);
                }
            }
        },
        {
            key: "compareNodes",
            value: /**
   * 递归比较两个节点及其子节点的差异。
   *
   * @param newNode - 新节点
   * @param oldNode - 旧节点
   * @param path - 当前节点的路径
   * @param operations - 操作队列，用于存储发现的差异操作
   *
   * 比较过程包括：
   * 1. 检查节点 hash 是否相同（相同则跳过比较）
   * 2. 检查节点类型是否相同
   * 3. 特殊处理表格节点
   * 4. 比较文本节点内容
   * 5. 比较节点属性
   * 6. 递归比较子节点
   * @private
   */ function compareNodes(newNode, oldNode, path, operations) {
                // 如果两个节点的 hash 相同，跳过比较
                if (newNode.hash && oldNode.hash && newNode.hash === oldNode.hash) {
                    return;
                }
                // 如果节点类型不同，直接替换整个节点
                if (newNode.type !== oldNode.type || newNode.finished !== oldNode.finished) {
                    operations.push({
                        type: 'replace',
                        path: path,
                        node: newNode,
                        priority: 5
                    });
                    return;
                }
                // 特殊处理表格节点
                if (newNode.type === 'table') {
                    this.compareTableNodes(newNode, oldNode, path, operations);
                    return;
                }
                // 如果两个节点是文本节点
                if (typeof newNode.text === 'string' && typeof oldNode.text === 'string') {
                    if (newNode.text !== oldNode.text) {
                        operations.push({
                            type: 'text',
                            path: path,
                            text: newNode.text,
                            priority: 8
                        });
                    }
                    // 比较文本节点的其他属性（如加粗、斜体等）
                    var newProps = _object_spread({}, newNode);
                    var oldProps = _object_spread({}, oldNode);
                    delete newProps.text;
                    delete oldProps.text;
                    if (!isEqual(newProps, oldProps)) {
                        operations.push({
                            type: 'update',
                            path: path,
                            properties: newProps,
                            priority: 7
                        });
                    }
                    return;
                }
                // 处理其他类型的节点属性更新
                var newProps1 = _object_spread_props(_object_spread({}, newNode), {
                    children: undefined
                });
                var oldProps1 = _object_spread_props(_object_spread({}, oldNode), {
                    children: undefined
                });
                if (!isEqual(newProps1, oldProps1)) {
                    operations.push({
                        type: 'update',
                        path: path,
                        properties: newProps1,
                        priority: 7
                    });
                }
                // 递归比较子节点
                if (newNode.children && oldNode.children) {
                    // 特殊处理列表、引用等可能有嵌套结构的节点
                    var childrenOps = [];
                    this.generateDiffOperationsInternal(newNode.children, oldNode.children, childrenOps);
                    // 将子节点的操作添加到队列中，调整路径
                    childrenOps.forEach(function(op) {
                        operations.push(_object_spread_props(_object_spread({}, op), {
                            path: _to_consumable_array(path).concat(_to_consumable_array(op.path))
                        }));
                    });
                }
            }
        },
        {
            key: "compareTableNodes",
            value: /**
   * 特殊处理表格节点的比较。
   *
   * @param newTable - 新的表格节点
   * @param oldTable - 旧的表格节点
   * @param path - 表格节点的路径
   * @param operations - 操作队列
   *
   * 处理步骤：
   * 1. 检查表格结构是否相同
   * 2. 比较表格属性
   * 3. 逐行比较和更新
   * 4. 处理行数变化
   * 5. 必要时进行整表替换
   * @private
   */ function compareTableNodes(newTable, oldTable, path, operations) {
                var newRows = newTable.children || [];
                var oldRows = oldTable.children || [];
                if (this._isSameTableStructure(newTable, oldTable, newRows, oldRows)) {
                    this._updateSameStructureTable(newTable, oldTable, newRows, oldRows, path, operations);
                } else {
                    this._updateDifferentStructureTable(newTable, oldTable, newRows, oldRows, path, operations);
                }
            }
        },
        {
            key: "_isSameTableStructure",
            value: /**
   * 检查表格结构是否相同
   */ function _isSameTableStructure(newTable, oldTable, newRows, oldRows) {
                if (newTable.id && oldTable.id) {
                    return newTable.id === oldTable.id;
                }
                if (newRows.length !== oldRows.length) {
                    return false;
                }
                for(var i = 0; i < newRows.length; i++){
                    var newRow = newRows[i];
                    var oldRow = oldRows[i];
                    if (!newRow.children || !oldRow.children || newRow.children.length !== oldRow.children.length) {
                        return false;
                    }
                }
                return true;
            }
        },
        {
            key: "_updateSameStructureTable",
            value: /**
   * 更新结构相同的表格
   */ function _updateSameStructureTable(newTable, oldTable, newRows, oldRows, path, operations) {
                if (this._tablePropsChanged(newTable, oldTable)) {
                    operations.push({
                        type: 'update',
                        path: path,
                        properties: _object_spread_props(_object_spread({}, newTable), {
                            children: undefined
                        }),
                        priority: 7
                    });
                }
                for(var rowIdx = 0; rowIdx < newRows.length; rowIdx++){
                    this._updateTableRow(newRows[rowIdx], oldRows[rowIdx], _to_consumable_array(path).concat([
                        rowIdx
                    ]), operations);
                }
            }
        },
        {
            key: "_updateDifferentStructureTable",
            value: /**
   * 更新结构不同的表格
   */ function _updateDifferentStructureTable(newTable, oldTable, newRows, oldRows, path, operations) {
                if (Math.abs(newRows.length - oldRows.length) <= 2) {
                    this._updateTableWithRowChanges(newTable, oldTable, newRows, oldRows, path, operations);
                } else {
                    operations.push({
                        type: 'replace',
                        path: path,
                        node: newTable,
                        priority: 5
                    });
                }
            }
        },
        {
            key: "_tablePropsChanged",
            value: /**
   * 检查表格属性是否变化
   */ function _tablePropsChanged(newTable, oldTable) {
                var newProps = _object_spread({}, newTable);
                var oldProps = _object_spread({}, oldTable);
                delete newProps.children;
                delete oldProps.children;
                return !isEqual(newProps, oldProps);
            }
        },
        {
            key: "_updateTableRow",
            value: /**
   * 更新表格行
   */ function _updateTableRow(newRow, oldRow, rowPath, operations) {
                var newRowProps = _object_spread_props(_object_spread({}, newRow), {
                    children: undefined
                });
                var oldRowProps = _object_spread_props(_object_spread({}, oldRow), {
                    children: undefined
                });
                if (!isEqual(newRowProps, oldRowProps)) {
                    operations.push({
                        type: 'update',
                        path: rowPath,
                        properties: newRowProps,
                        priority: 7
                    });
                }
                var newCells = newRow.children || [];
                var oldCells = oldRow.children || [];
                var minCellCount = Math.min(newCells.length, oldCells.length);
                for(var cellIdx = 0; cellIdx < minCellCount; cellIdx++){
                    this.compareCells(newCells[cellIdx], oldCells[cellIdx], _to_consumable_array(rowPath).concat([
                        cellIdx
                    ]), operations);
                }
                this._handleCellCountChanges(newCells, oldCells, rowPath, operations);
            }
        },
        {
            key: "_handleCellCountChanges",
            value: /**
   * 处理单元格数量变化
   */ function _handleCellCountChanges(newCells, oldCells, rowPath, operations) {
                if (newCells.length > oldCells.length) {
                    for(var cellIdx = oldCells.length; cellIdx < newCells.length; cellIdx++){
                        operations.push({
                            type: 'insert',
                            path: _to_consumable_array(rowPath).concat([
                                cellIdx
                            ]),
                            node: newCells[cellIdx],
                            priority: 6
                        });
                    }
                } else if (newCells.length < oldCells.length) {
                    for(var cellIdx1 = oldCells.length - 1; cellIdx1 >= newCells.length; cellIdx1--){
                        operations.push({
                            type: 'remove',
                            path: _to_consumable_array(rowPath).concat([
                                cellIdx1
                            ]),
                            priority: 1
                        });
                    }
                }
            }
        },
        {
            key: "_updateTableWithRowChanges",
            value: /**
   * 更新有行数变化的表格
   */ function _updateTableWithRowChanges(newTable, oldTable, newRows, oldRows, path, operations) {
                if (this._tablePropsChanged(newTable, oldTable)) {
                    operations.push({
                        type: 'update',
                        path: path,
                        properties: _object_spread_props(_object_spread({}, newTable), {
                            children: undefined
                        }),
                        priority: 7
                    });
                }
                var minRowCount = Math.min(newRows.length, oldRows.length);
                for(var rowIdx = 0; rowIdx < minRowCount; rowIdx++){
                    this.compareNodes(newRows[rowIdx], oldRows[rowIdx], _to_consumable_array(path).concat([
                        rowIdx
                    ]), operations);
                }
                this._handleRowCountChanges(newRows, oldRows, path, operations);
            }
        },
        {
            key: "_handleRowCountChanges",
            value: /**
   * 处理行数变化
   */ function _handleRowCountChanges(newRows, oldRows, path, operations) {
                if (newRows.length > oldRows.length) {
                    for(var rowIdx = oldRows.length; rowIdx < newRows.length; rowIdx++){
                        operations.push({
                            type: 'insert',
                            path: _to_consumable_array(path).concat([
                                rowIdx
                            ]),
                            node: newRows[rowIdx],
                            priority: 5
                        });
                    }
                } else if (newRows.length < oldRows.length) {
                    for(var rowIdx1 = oldRows.length - 1; rowIdx1 >= newRows.length; rowIdx1--){
                        operations.push({
                            type: 'remove',
                            path: _to_consumable_array(path).concat([
                                rowIdx1
                            ]),
                            priority: 1
                        });
                    }
                }
            }
        },
        {
            key: "compareCells",
            value: /**
   * 比较和更新表格单元格。
   *
   * @param newCell - 新的单元格节点
   * @param oldCell - 旧的单元格节点
   * @param path - 单元格的路径
   * @param operations - 操作队列
   *
   * 处理步骤：
   * 1. 检查单元格属性变化
   * 2. 处理简单文本单元格
   * 3. 处理复杂单元格内容
   * 4. 生成适当的更新操作
   * @private
   */ function compareCells(newCell, oldCell, path, operations) {
                // 检查单元格属性是否变化
                this.compareCellProperties(newCell, oldCell, path, operations);
                // 处理单元格内容
                var newChildren = newCell.children || [];
                var oldChildren = oldCell.children || [];
                this.compareCellChildren(newChildren, oldChildren, path, operations);
            }
        },
        {
            key: "compareCellProperties",
            value: /**
   * 比较单元格属性
   */ function compareCellProperties(newCell, oldCell, path, operations) {
                var newCellProps = _object_spread_props(_object_spread({}, newCell), {
                    children: undefined
                });
                var oldCellProps = _object_spread_props(_object_spread({}, oldCell), {
                    children: undefined
                });
                if (!isEqual(newCellProps, oldCellProps)) {
                    operations.push({
                        type: 'update',
                        path: path,
                        properties: newCellProps,
                        priority: 7
                    });
                }
            }
        },
        {
            key: "compareCellChildren",
            value: /**
   * 比较单元格子节点
   */ function compareCellChildren(newChildren, oldChildren, path, operations) {
                // 简单文本单元格的优化处理
                if (this.isSimpleTextCell(newChildren, oldChildren)) {
                    this.compareSimpleTextCell(newChildren, oldChildren, path, operations);
                    return;
                }
                // 复杂单元格内容
                this.compareComplexCellChildren(newChildren, oldChildren, path, operations);
            }
        },
        {
            key: "isSimpleTextCell",
            value: /**
   * 判断是否是简单文本单元格
   */ function isSimpleTextCell(newChildren, oldChildren) {
                var _newChildren_, _oldChildren_;
                return newChildren.length === 1 && oldChildren.length === 1 && typeof (newChildren === null || newChildren === void 0 ? void 0 : (_newChildren_ = newChildren[0]) === null || _newChildren_ === void 0 ? void 0 : _newChildren_.text) === 'string' && typeof (oldChildren === null || oldChildren === void 0 ? void 0 : (_oldChildren_ = oldChildren[0]) === null || _oldChildren_ === void 0 ? void 0 : _oldChildren_.text) === 'string';
            }
        },
        {
            key: "compareSimpleTextCell",
            value: /**
   * 比较简单文本单元格
   */ function compareSimpleTextCell(newChildren, oldChildren, path, operations) {
                var _newChildren_, _oldChildren_;
                // 只有文本内容变化
                if ((newChildren === null || newChildren === void 0 ? void 0 : (_newChildren_ = newChildren[0]) === null || _newChildren_ === void 0 ? void 0 : _newChildren_.text) !== (oldChildren === null || oldChildren === void 0 ? void 0 : (_oldChildren_ = oldChildren[0]) === null || _oldChildren_ === void 0 ? void 0 : _oldChildren_.text)) {
                    var _newChildren_1;
                    operations.push({
                        type: 'text',
                        path: _to_consumable_array(path).concat([
                            0
                        ]),
                        text: (newChildren === null || newChildren === void 0 ? void 0 : (_newChildren_1 = newChildren[0]) === null || _newChildren_1 === void 0 ? void 0 : _newChildren_1.text) || '',
                        priority: 8
                    });
                }
                // 检查文本节点的属性变化（加粗、斜体等）
                this.compareTextNodeProperties(newChildren[0], oldChildren[0], path, operations);
            }
        },
        {
            key: "compareTextNodeProperties",
            value: /**
   * 比较文本节点属性
   */ function compareTextNodeProperties(newChild, oldChild, path, operations) {
                var newTextProps = _object_spread({}, newChild);
                var oldTextProps = _object_spread({}, oldChild);
                delete newTextProps.text;
                delete oldTextProps.text;
                if (!isEqual(newTextProps, oldTextProps)) {
                    operations.push({
                        type: 'update',
                        path: _to_consumable_array(path).concat([
                            0
                        ]),
                        properties: newTextProps,
                        priority: 7
                    });
                }
            }
        },
        {
            key: "compareComplexCellChildren",
            value: /**
   * 比较复杂单元格子节点
   */ function compareComplexCellChildren(newChildren, oldChildren, path, operations) {
                // 检查是否结构完全不同
                var structurallyDifferent = this.isStructurallyDifferent(newChildren, oldChildren);
                if (structurallyDifferent) {
                    this.replaceComplexCellChildren(newChildren, oldChildren, path, operations);
                    return;
                }
                // 逐个比较并更新子节点
                this.compareChildrenSequentially(newChildren, oldChildren, path, operations);
            }
        },
        {
            key: "isStructurallyDifferent",
            value: /**
   * 判断结构是否不同
   */ function isStructurallyDifferent(newChildren, oldChildren) {
                if (newChildren.length !== oldChildren.length) return true;
                return newChildren.some(function(n, i) {
                    return oldChildren[i] && n.type !== oldChildren[i].type;
                });
            }
        },
        {
            key: "replaceComplexCellChildren",
            value: /**
   * 替换复杂单元格子节点
   */ function replaceComplexCellChildren(newChildren, oldChildren, path, operations) {
                var childOps = [];
                this.generateDiffOperationsInternal(newChildren, oldChildren, childOps);
                // 调整子操作的路径
                childOps.forEach(function(op) {
                    operations.push(_object_spread_props(_object_spread({}, op), {
                        path: _to_consumable_array(path).concat(_to_consumable_array(op.path))
                    }));
                });
            }
        },
        {
            key: "compareChildrenSequentially",
            value: /**
   * 逐个比较子节点
   */ function compareChildrenSequentially(newChildren, oldChildren, path, operations) {
                var length = Math.min(newChildren.length, oldChildren.length);
                for(var i = 0; i < length; i++){
                    this.compareNodes(newChildren[i], oldChildren[i], _to_consumable_array(path).concat([
                        i
                    ]), operations);
                }
            }
        },
        {
            key: "executeOperations",
            value: /**
   * 执行操作队列中的所有操作。
   *
   * @param operations - 要执行的操作队列
   *
   * 执行过程：
   * 1. 使用批处理模式执行所有操作
   * 2. 按照操作类型分别处理
   * 3. 处理可能的错误情况
   * 4. 保证操作的原子性
   */ function executeOperations(operations) {
                var editor = this._editor.current;
                if (!editor) return;
                // 使用批处理模式执行所有操作，避免中间状态导致路径变化
                Editor.withoutNormalizing(editor, function() {
                    var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
                    try {
                        for(var _iterator = operations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
                            var op = _step.value;
                            try {
                                switch(op.type){
                                    case 'insert':
                                        if (op.node && editor.hasPath(Path.parent(op.path))) {
                                            // 检查路径是否仍然有效，避免重复插入
                                            if (!editor.hasPath(op.path)) {
                                                Transforms.insertNodes(editor, op.node, {
                                                    at: op.path
                                                });
                                            }
                                        }
                                        break;
                                    case 'remove':
                                        if (editor.hasPath(op.path)) {
                                            Transforms.removeNodes(editor, {
                                                at: op.path
                                            });
                                        }
                                        break;
                                    case 'update':
                                        if (op.properties && editor.hasPath(op.path)) {
                                            Transforms.setNodes(editor, op.properties, {
                                                at: op.path
                                            });
                                        }
                                        break;
                                    case 'replace':
                                        if (op.node && editor.hasPath(op.path)) {
                                            Transforms.removeNodes(editor, {
                                                at: op.path
                                            });
                                            Transforms.insertNodes(editor, op.node, {
                                                at: op.path
                                            });
                                        }
                                        break;
                                    case 'text':
                                        if (op.text !== undefined && editor.hasPath(op.path)) {
                                            Transforms.insertText(editor, op.text, {
                                                at: op.path,
                                                voids: true
                                            });
                                        }
                                        break;
                                }
                            } catch (err) {
                                console.error("Error executing operation ".concat(op.type, " at path ").concat(op.path, ":"), err);
                            }
                        }
                    } catch (err) {
                        _didIteratorError = true;
                        _iteratorError = err;
                    } finally{
                        try {
                            if (!_iteratorNormalCompletion && _iterator.return != null) {
                                _iterator.return();
                            }
                        } finally{
                            if (_didIteratorError) {
                                throw _iteratorError;
                            }
                        }
                    }
                });
            }
        },
        {
            /**
   * 处理拖拽开始事件。
   *
   * @param e - React 拖拽事件对象
   * @param container - 容器 div 元素
   *
   * 此方法会在拖拽开始时调用，主要功能包括：
   * 1. 阻止事件传播
   * 2. 设置拖拽图像
   * 3. 初始化拖拽相关的元素和位置数据
   * 4. 添加拖拽过程中和拖拽结束时的事件监听器
   * 5. 计算可拖拽目标的位置
   * 6. 处理拖拽过程中的视觉反馈
   * 7. 在拖拽结束时更新编辑器内容
   */ key: "dragStart",
            value: function dragStart(e, container) {
                var _this = this;
                e.stopPropagation();
                this._setupDragImage(e);
                var ableToEnter = this._getAbleToEnterSet();
                var points = this._collectMovePoints(container, ableToEnter);
                var mark = null;
                var last = null;
                var dragover = this._createDragOverHandler(container, points, function(cur) {
                    last = cur;
                    mark = _this._updateDragMark(mark, cur, container);
                });
                window.addEventListener('dragover', dragover);
                window.addEventListener('dragend', function() {
                    try {
                        window.removeEventListener('dragover', dragover);
                        if (mark) container === null || container === void 0 ? void 0 : container.parentElement.removeChild(mark);
                        if (last && _this.draggedElement) {
                            _this._handleDragEnd(last);
                        }
                        _this.draggedElement = null;
                    } catch (error) {
                        console.error(error);
                    }
                }, {
                    once: true
                });
            }
        },
        {
            key: "_setupDragImage",
            value: /**
   * 设置拖拽图像
   */ function _setupDragImage(e) {
                var img = document.createElement('img');
                img.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
                e.dataTransfer.setDragImage(img, 1, 1);
            }
        },
        {
            key: "_getAbleToEnterSet",
            value: /**
   * 获取允许进入的元素类型集合
   */ function _getAbleToEnterSet() {
                var _this_draggedElement_dataset, _this_draggedElement;
                if (((_this_draggedElement = this.draggedElement) === null || _this_draggedElement === void 0 ? void 0 : (_this_draggedElement_dataset = _this_draggedElement.dataset) === null || _this_draggedElement_dataset === void 0 ? void 0 : _this_draggedElement_dataset.be) === 'list-item') {
                    return new Set([
                        'paragraph',
                        'head',
                        'blockquote',
                        'code',
                        'table',
                        'list',
                        'list-item',
                        'media',
                        'attach'
                    ]);
                }
                return this.ableToEnter;
            }
        },
        {
            key: "_collectMovePoints",
            value: /**
   * 收集移动点
   */ function _collectMovePoints(container, ableToEnter) {
                var points = [];
                var els = document.querySelectorAll('[data-be]');
                var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
                try {
                    for(var _iterator = els[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
                        var el = _step.value;
                        if (!this._shouldIncludeElement(el, ableToEnter)) continue;
                        var top = getOffsetTop(el, container);
                        var left = getOffsetLeft(el, container);
                        points.push({
                            el: el,
                            direction: 'top',
                            left: left,
                            top: top
                        }, {
                            el: el,
                            direction: 'bottom',
                            left: left,
                            top: top + el.clientHeight + 2
                        });
                    }
                } catch (err) {
                    _didIteratorError = true;
                    _iteratorError = err;
                } finally{
                    try {
                        if (!_iteratorNormalCompletion && _iterator.return != null) {
                            _iterator.return();
                        }
                    } finally{
                        if (_didIteratorError) {
                            throw _iteratorError;
                        }
                    }
                }
                return points;
            }
        },
        {
            key: "_shouldIncludeElement",
            value: /**
   * 判断是否应该包含元素
   */ function _shouldIncludeElement(el, ableToEnter) {
                var _this_draggedElement;
                if (!ableToEnter.has(el.dataset.be)) return false;
                if (el.hasAttribute('data-frontmatter')) return false;
                if (el === this.draggedElement) return false;
                var pre = el.previousSibling;
                if (el.dataset.be === 'paragraph' && ((_this_draggedElement = this.draggedElement) === null || _this_draggedElement === void 0 ? void 0 : _this_draggedElement.dataset.be) === 'list-item' && (!pre || pre.hasAttribute('data-check-item'))) {
                    return false;
                }
                return true;
            }
        },
        {
            key: "_createDragOverHandler",
            value: /**
   * 创建拖拽悬停处理器
   */ function _createDragOverHandler(container, points, onPointFound) {
                var _this = this;
                return function(e) {
                    e.preventDefault();
                    var top = e.clientY - 40 + container.scrollTop;
                    var cur = _this._findClosestPoint(points, top);
                    if (cur) {
                        onPointFound(cur);
                    }
                };
            }
        },
        {
            key: "_findClosestPoint",
            value: /**
   * 查找最近的移动点
   */ function _findClosestPoint(points, targetTop) {
                var distance = 1000000;
                var closest = null;
                var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
                try {
                    for(var _iterator = points[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
                        var p = _step.value;
                        var curDistance = Math.abs(p.top - targetTop);
                        if (curDistance < distance) {
                            closest = p;
                            distance = curDistance;
                        }
                    }
                } catch (err) {
                    _didIteratorError = true;
                    _iteratorError = err;
                } finally{
                    try {
                        if (!_iteratorNormalCompletion && _iterator.return != null) {
                            _iterator.return();
                        }
                    } finally{
                        if (_didIteratorError) {
                            throw _iteratorError;
                        }
                    }
                }
                return closest;
            }
        },
        {
            key: "_updateDragMark",
            value: /**
   * 更新拖拽标记
   */ function _updateDragMark(mark, point, container) {
                var rect = container.getBoundingClientRect();
                var scrollTop = container.scrollTop;
                var scrollLeft = container.scrollLeft;
                var width = point.el.dataset.be === 'list-item' ? point.el.clientWidth + 20 + 'px' : point.el.clientWidth + 'px';
                if (!mark) {
                    mark = document.createElement('div');
                    mark.setAttribute('data-move-mark', '');
                    mark.style.width = width;
                    mark.style.height = '2px';
                    container === null || container === void 0 ? void 0 : container.parentElement.append(mark);
                } else {
                    mark.style.width = width;
                }
                mark.style.transform = "translate(".concat(point.left - rect.left - scrollLeft, "px, ").concat(point.top - rect.top - scrollTop, "px)");
                return mark;
            }
        },
        {
            key: "_handleDragEnd",
            value: /**
   * 处理拖拽结束
   */ function _handleDragEnd(last) {
                if (!this.draggedElement) return;
                var _this_toPath = _sliced_to_array(this.toPath(this.draggedElement), 2), dragPath = _this_toPath[0], dragNode = _this_toPath[1];
                var _this_toPath1 = _sliced_to_array(this.toPath(last.el), 1), targetPath = _this_toPath1[0];
                var toPath = last.direction === 'top' ? targetPath : Path.next(targetPath);
                if (Path.equals(targetPath, dragPath)) return;
                var parent = Node.parent(this._editor.current, dragPath);
                if (Path.equals(Path.parent(targetPath), Path.parent(dragPath)) && Path.compare(dragPath, targetPath) === -1) {
                    toPath = Path.previous(toPath);
                }
                var targetNode = Node.get(this._editor.current, targetPath);
                this._moveNode(dragNode, dragPath, toPath, targetNode, parent, targetPath);
                if ((dragNode === null || dragNode === void 0 ? void 0 : dragNode.type) !== 'media') {
                    this.draggedElement.draggable = false;
                }
            }
        },
        {
            key: "_moveNode",
            value: /**
   * 移动节点
   */ function _moveNode(dragNode, dragPath, toPath, targetNode, parent, targetPath) {
                if (dragNode.type === 'list-item' && targetNode.type !== 'list-item') {
                    var delPath = this._moveListItemToNonListItem(dragNode, dragPath, toPath, parent, targetPath);
                    if (delPath) {
                        Transforms.delete(this._editor.current, {
                            at: delPath
                        });
                    }
                } else {
                    Transforms.moveNodes(this._editor.current, {
                        at: dragPath,
                        to: toPath
                    });
                    this._cleanupEmptyParent(parent, dragPath, toPath);
                }
            }
        },
        {
            key: "_moveListItemToNonListItem",
            value: /**
   * 移动列表项到非列表项位置
   * @returns 需要删除的路径，如果不需要删除则返回 null
   */ function _moveListItemToNonListItem(dragNode, dragPath, toPath, parent, targetPath) {
                var _parent_children;
                Transforms.delete(this._editor.current, {
                    at: dragPath
                });
                Transforms.insertNodes(this._editor.current, _object_spread_props(_object_spread({}, parent), {
                    children: [
                        EditorUtils.copy(dragNode)
                    ]
                }), {
                    at: toPath,
                    select: true
                });
                if (((_parent_children = parent.children) === null || _parent_children === void 0 ? void 0 : _parent_children.length) !== 1) return null;
                if (EditorUtils.isNextPath(Path.parent(dragPath), targetPath)) {
                    return Path.next(Path.parent(dragPath));
                }
                return Path.parent(dragPath);
            }
        },
        {
            key: "_cleanupEmptyParent",
            value: /**
   * 清理空的父节点
   */ function _cleanupEmptyParent(parent, dragPath, toPath) {
                var _parent_children;
                if (((_parent_children = parent.children) === null || _parent_children === void 0 ? void 0 : _parent_children.length) !== 1) return;
                var delPath = Path.parent(dragPath);
                if (Path.equals(Path.parent(toPath), Path.parent(delPath)) && Path.compare(toPath, delPath) !== 1) {
                    delPath = Path.next(delPath);
                }
                Transforms.delete(this._editor.current, {
                    at: delPath
                });
            }
        },
        {
            /**
   * 替换编辑器中的文本内容
   *
   * @param searchText - 要查找和替换的原始文本
   * @param replaceText - 替换后的新文本
   * @param options - 可选参数
   * @param options.caseSensitive - 是否区分大小写，默认为 false
   * @param options.wholeWord - 是否只匹配完整单词，默认为 false
   * @param options.replaceAll - 是否替换所有匹配项，默认为 true
   *
   * @returns 替换操作的数量
   *
   * @example
   * ```ts
   * // 替换所有 "old" 为 "new"
   * const count = store.replaceText("old", "new");
   *
   * // 只替换第一个匹配项，区分大小写
   * const count = store.replaceText("Old", "New", {
   *   caseSensitive: true,
   *   replaceAll: false
   * });
   * ```
   */ key: "replaceText",
            value: function replaceText(searchText, replaceText) {
                var _this = this;
                var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
                var _options_caseSensitive = options.caseSensitive, caseSensitive = _options_caseSensitive === void 0 ? false : _options_caseSensitive, _options_wholeWord = options.wholeWord, wholeWord = _options_wholeWord === void 0 ? false : _options_wholeWord, _options_replaceAll = options.replaceAll, replaceAll = _options_replaceAll === void 0 ? true : _options_replaceAll;
                if (!searchText) return 0;
                var editor = this._editor.current;
                var textNodes = Array.from(Editor.nodes(editor, {
                    at: [],
                    match: function match(n) {
                        return Text.isText(n) && typeof n.text === 'string';
                    }
                }));
                var replaceCount = 0;
                Editor.withoutNormalizing(editor, function() {
                    if (replaceAll) {
                        replaceCount = _this._replaceAllInNodes(textNodes, searchText, replaceText, caseSensitive, wholeWord);
                    } else {
                        replaceCount = _this._replaceFirstInNodes(textNodes, searchText, replaceText, caseSensitive, wholeWord);
                    }
                });
                return replaceCount;
            }
        },
        {
            key: "_replaceAllInNodes",
            value: /**
   * 在所有文本节点中替换所有匹配项
   */ function _replaceAllInNodes(textNodes, searchText, replaceText, caseSensitive, wholeWord) {
                var editor = this._editor.current;
                var replaceCount = 0;
                for(var i = textNodes.length - 1; i >= 0; i--){
                    var _textNodes_i = _sliced_to_array(textNodes[i], 2), node = _textNodes_i[0], path = _textNodes_i[1];
                    var result = this._replaceInText(node.text, searchText, replaceText, caseSensitive, wholeWord, true);
                    if (result.newText !== result.originalText) {
                        Transforms.insertText(editor, result.newText, {
                            at: path,
                            voids: true
                        });
                        replaceCount += result.count;
                    }
                }
                return replaceCount;
            }
        },
        {
            key: "_replaceFirstInNodes",
            value: /**
   * 在所有文本节点中替换第一个匹配项
   */ function _replaceFirstInNodes(textNodes, searchText, replaceText, caseSensitive, wholeWord) {
                var editor = this._editor.current;
                for(var i = 0; i < textNodes.length; i++){
                    var _textNodes_i = _sliced_to_array(textNodes[i], 2), node = _textNodes_i[0], path = _textNodes_i[1];
                    var result = this._replaceInText(node.text, searchText, replaceText, caseSensitive, wholeWord, false);
                    if (result.newText !== result.originalText) {
                        Transforms.insertText(editor, result.newText, {
                            at: path,
                            voids: true
                        });
                        return result.count;
                    }
                }
                return 0;
            }
        },
        {
            key: "_replaceInText",
            value: /**
   * 在单个文本中执行替换
   */ function _replaceInText(originalText, searchText, replaceText, caseSensitive, wholeWord, replaceAll) {
                var flags = this._buildRegexFlags(caseSensitive, replaceAll);
                var pattern = wholeWord ? "\\b".concat(this.escapeRegExp(searchText), "\\b") : this.escapeRegExp(searchText);
                var regex = new RegExp(pattern, flags);
                var count = 0;
                var newText = originalText.replace(regex, function() {
                    count++;
                    return replaceText;
                });
                return {
                    originalText: originalText,
                    newText: newText,
                    count: count
                };
            }
        },
        {
            key: "_buildRegexFlags",
            value: /**
   * 构建正则表达式标志
   */ function _buildRegexFlags(caseSensitive, global) {
                var flags = '';
                if (!caseSensitive) flags += 'i';
                if (global) flags += 'g';
                return flags;
            }
        },
        {
            /**
   * 在选中的区域内替换文本
   *
   * @param searchText - 要查找和替换的原始文本
   * @param replaceText - 替换后的新文本
   * @param options - 可选参数
   * @param options.caseSensitive - 是否区分大小写，默认为 false
   * @param options.wholeWord - 是否只匹配完整单词，默认为 false
   * @param options.replaceAll - 是否替换所有匹配项，默认为 true
   *
   * @returns 替换操作的数量，如果没有选中区域则返回 0
   *
   * @example
   * ```ts
   * // 在选中区域内替换文本
   * const count = store.replaceTextInSelection("old", "new");
   * ```
   */ key: "replaceTextInSelection",
            value: function replaceTextInSelection(searchText, replaceText) {
                var _this = this;
                var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
                var editor = this._editor.current;
                var selection = editor.selection;
                if (!selection || Range.isCollapsed(selection)) {
                    return 0;
                }
                var _options_caseSensitive = options.caseSensitive, caseSensitive = _options_caseSensitive === void 0 ? false : _options_caseSensitive, _options_wholeWord = options.wholeWord, wholeWord = _options_wholeWord === void 0 ? false : _options_wholeWord, _options_replaceAll = options.replaceAll, replaceAll = _options_replaceAll === void 0 ? true : _options_replaceAll;
                if (!searchText) return 0;
                var textNodes = Array.from(Editor.nodes(editor, {
                    at: selection,
                    match: function match(n) {
                        return Text.isText(n) && typeof n.text === 'string';
                    }
                }));
                var replaceCount = 0;
                Editor.withoutNormalizing(editor, function() {
                    replaceCount = _this._replaceInSelectionNodes(textNodes, searchText, replaceText, caseSensitive, wholeWord, replaceAll);
                });
                return replaceCount;
            }
        },
        {
            key: "_replaceInSelectionNodes",
            value: /**
   * 在选中区域的文本节点中执行替换
   */ function _replaceInSelectionNodes(textNodes, searchText, replaceText, caseSensitive, wholeWord, replaceAll) {
                var editor = this._editor.current;
                var replaceCount = 0;
                for(var i = textNodes.length - 1; i >= 0; i--){
                    var _textNodes_i = _sliced_to_array(textNodes[i], 2), node = _textNodes_i[0], path = _textNodes_i[1];
                    var result = this._replaceInText(node.text, searchText, replaceText, caseSensitive, wholeWord, replaceAll);
                    if (result.newText !== result.originalText) {
                        Transforms.insertText(editor, result.newText, {
                            at: path,
                            voids: true
                        });
                        replaceCount += result.count;
                        if (!replaceAll && result.count > 0) {
                            break;
                        }
                    }
                }
                return replaceCount;
            }
        },
        {
            /**
   * 替换所有匹配的文本（replaceText 的简化版本）
   *
   * @param searchText - 要查找和替换的原始文本
   * @param replaceText - 替换后的新文本
   * @param caseSensitive - 是否区分大小写，默认为 false
   *
   * @returns 替换操作的数量
   *
   * @example
   * ```ts
   * // 替换所有 "old" 为 "new"
   * const count = store.replaceAll("old", "new");
   *
   * // 区分大小写替换
   * const count = store.replaceAll("Old", "New", true);
   * ```
   */ key: "replaceAll",
            value: function replaceAll(searchText, replaceText) {
                var caseSensitive = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
                return this.replaceText(searchText, replaceText, {
                    caseSensitive: caseSensitive,
                    replaceAll: true
                });
            }
        },
        {
            key: "escapeRegExp",
            value: /**
   * 转义正则表达式特殊字符
   *
   * @param string - 需要转义的字符串
   * @returns 转义后的字符串
   * @private
   */ function escapeRegExp(string) {
                return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
            }
        },
        {
            /**
   * 在编辑器中根据路径描述和文本内容查找并选择匹配位置
   *
   * @param pathDescription - 路径描述，用于限制搜索范围。可以是：
   *                         - 节点类型（如 "paragraph", "table", "list"）
   *                         - 包含特定文本的节点区域
   *                         - 空字符串表示在整个编辑器中搜索
   * @param searchText - 要查找的文本内容
   * @param options - 查找选项
   * @returns 匹配结果数组
   *
   * @example
   * ```ts
   * // 查找所有包含 "focus" 的位置
   * const results = store.findByPathAndText("", "focus");
   */ key: "findByPathAndText",
            value: function findByPathAndText1(pathDescription, searchText) {
                var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
                var _options_caseSensitive = options.caseSensitive, caseSensitive = _options_caseSensitive === void 0 ? false : _options_caseSensitive, _options_wholeWord = options.wholeWord, wholeWord = _options_wholeWord === void 0 ? false : _options_wholeWord, _options_maxResults = options.maxResults, maxResults = _options_maxResults === void 0 ? 50 : _options_maxResults;
                if (!searchText.trim()) return [];
                var editor = this._editor.current;
                return findByPathAndText(editor, pathDescription, searchText, {
                    caseSensitive: caseSensitive,
                    wholeWord: wholeWord,
                    maxResults: maxResults
                });
            }
        },
        {
            /**
   * 更新编辑器的状态数据
   *
   * @param value - 状态更新器，可以是函数或对象
   *
   * 该方法提供两种更新状态的方式：
   * 1. 函数式更新：传入一个函数，可以直接修改状态
   * 2. 对象式更新：传入一个对象，直接覆盖对应的状态值
   *
   * @example
   * ```ts
   * // 函数式更新 - 可以访问当前状态
   * setState((state) => {
   *   state.focus = true;
   *   state.manual = false;
   * });
   *
   * // 对象式更新 - 直接设置新值
   * setState({
   *   focus: true,
   *   manual: false
   * });
   * ```
   */ key: "setState",
            value: function setState(value) {
                if (_instanceof(value, Function)) {
                    value(this);
                } else {
                    var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
                    try {
                        for(var _iterator = Object.keys(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
                            var key = _step.value;
                            // @ts-ignore
                            this[key] = value[key];
                        }
                    } catch (err) {
                        _didIteratorError = true;
                        _iteratorError = err;
                    } finally{
                        try {
                            if (!_iteratorNormalCompletion && _iterator.return != null) {
                                _iterator.return();
                            }
                        } finally{
                            if (_didIteratorError) {
                                throw _iteratorError;
                            }
                        }
                    }
                }
            }
        }
    ]);
    return EditorStore;
}();
