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 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_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 _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 _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = 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 _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
        };
    }
}
import { BlockOutlined, DeleteFilled, LoadingOutlined } from "@ant-design/icons";
import { Image, Modal, Popover, Skeleton, Space } from "antd";
import React, { useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { useRefFunction } from "../../../../Hooks/useRefFunction";
import { debugInfo } from "../../../../Utils/debugUtils";
import { useDebounceFn } from "@ant-design/pro-components";
import { Rnd } from "react-rnd";
import { Path, Transforms } from "slate";
import { ActionIconBox } from "../../../../Components/ActionIconBox";
import { I18nContext } from "../../../../I18n";
import { useSelStatus } from "../../../hooks/editor";
import { MediaErrorLink } from "../../components/MediaErrorLink";
import { useEditorStore } from "../../store";
import { useGetSetState } from "../../utils";
import { getMediaType } from "../../utils/dom";
export var ReadonlyImage = function(param) {
    var src = param.src, alt = param.alt, width = param.width, height = param.height, crossOrigin = param.crossOrigin;
    var _editorProps_image;
    var editorProps = useEditorStore().editorProps;
    var _React_useState = _sliced_to_array(React.useState(false), 2), error = _React_useState[0], setError = _React_useState[1];
    // 图片加载失败时显示为链接
    if (error) {
        return /*#__PURE__*/ React.createElement(MediaErrorLink, {
            url: src,
            displayText: alt || src || '图片链接'
        });
    }
    var imageProps = {
        src: src,
        alt: alt || 'image',
        width: width ? Number(width) || width : 400,
        height: height,
        preview: {
            getContainer: function() {
                return document.body;
            }
        },
        referrerPolicy: 'no-referrer',
        crossOrigin: crossOrigin,
        draggable: false,
        style: {
            maxWidth: '100%',
            height: 'auto',
            display: 'block'
        },
        onError: function() {
            setError(true);
        }
    };
    if (editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_image = editorProps.image) === null || _editorProps_image === void 0 ? void 0 : _editorProps_image.render) {
        var _editorProps_image_render, _editorProps_image1;
        return (_editorProps_image_render = (_editorProps_image1 = editorProps.image).render) === null || _editorProps_image_render === void 0 ? void 0 : _editorProps_image_render.call(_editorProps_image1, imageProps, /*#__PURE__*/ React.createElement(Image, imageProps));
    }
    return /*#__PURE__*/ React.createElement("div", {
        "data-testid": "image-container",
        "data-be": "image-container"
    }, /*#__PURE__*/ React.createElement(Image, imageProps));
};
/**
 * 修复图片大小的问题
 * @param props
 * @returns
 */ export var ResizeImage = function(_0) {
    var onResizeStart = _0.onResizeStart, onResizeStop = _0.onResizeStop, selected = _0.selected, defaultSize = _0.defaultSize, props = _object_without_properties(_0, [
        "onResizeStart",
        "onResizeStop",
        "selected",
        "defaultSize"
    ]);
    var _React_useState = _sliced_to_array(React.useState(true), 2), loading = _React_useState[0], setLoading = _React_useState[1];
    var _React_useState1 = _sliced_to_array(React.useState(false), 2), error = _React_useState1[0], setError = _React_useState1[1];
    var radio = useRef(1);
    var _React_useState2 = _sliced_to_array(React.useState({
        width: (defaultSize === null || defaultSize === void 0 ? void 0 : defaultSize.width) || 400,
        height: (defaultSize === null || defaultSize === void 0 ? void 0 : defaultSize.height) || 0
    }), 2), size = _React_useState2[0], setSize = _React_useState2[1];
    var imgRef = useRef(null);
    //@ts-expect-error
    var resize = useDebounceFn(function(size) {
        var _imgRef_current, _imgRef_current1;
        setSize({
            width: size.width,
            height: size.width / radio.current
        });
        (_imgRef_current = imgRef.current) === null || _imgRef_current === void 0 ? void 0 : _imgRef_current.style.setProperty('width', "".concat(size.width, "px"));
        (_imgRef_current1 = imgRef.current) === null || _imgRef_current1 === void 0 ? void 0 : _imgRef_current1.style.setProperty('height', "".concat((size.width || 0) / radio.current, "px"));
    }, 160);
    // 如果图片加载失败，显示为链接
    if (error) {
        return /*#__PURE__*/ React.createElement(MediaErrorLink, {
            url: props.src,
            displayText: props.alt || props.src || '图片链接',
            style: {
                fontSize: '13px',
                lineHeight: '1.5'
            }
        });
    }
    return /*#__PURE__*/ React.createElement("div", {
        "data-testid": "resize-image-container",
        style: {
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'center',
            borderRadius: 4,
            overflow: 'hidden',
            width: size.width,
            height: size.height,
            maxWidth: '100%',
            boxSizing: 'border-box'
        }
    }, loading ? /*#__PURE__*/ React.createElement("div", {
        style: {
            width: '24px',
            height: '24px',
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'center',
            background: 'rgba(0,0,0,0.05)',
            borderRadius: 12
        }
    }, /*#__PURE__*/ React.createElement(LoadingOutlined, {
        style: {
            fontSize: 16,
            color: '#1890ff'
        }
    })) : null, /*#__PURE__*/ React.createElement(Rnd, {
        onResizeStart: onResizeStart,
        onResizeStop: function() {
            onResizeStop === null || onResizeStop === void 0 ? void 0 : onResizeStop(size);
        },
        default: {
            x: 0,
            y: 0,
            width: (defaultSize === null || defaultSize === void 0 ? void 0 : defaultSize.width) || '100%',
            height: (defaultSize === null || defaultSize === void 0 ? void 0 : defaultSize.height) || '100%'
        },
        size: size,
        disableDragging: true,
        style: {
            userSelect: 'none',
            WebkitUserSelect: 'none',
            MozUserSelect: 'none',
            msUserSelect: 'none'
        },
        onResize: function(_, dir, ele) {
            var _imgRef_current, _imgRef_current1;
            (_imgRef_current = imgRef.current) === null || _imgRef_current === void 0 ? void 0 : _imgRef_current.style.setProperty('width', "".concat(ele.clientWidth, "px"));
            (_imgRef_current1 = imgRef.current) === null || _imgRef_current1 === void 0 ? void 0 : _imgRef_current1.style.setProperty('height', "".concat((ele.clientWidth || 0) / radio.current, "px"));
            resize.cancel();
            resize.run({
                width: ele.clientWidth,
                height: (ele.clientWidth || 0) / radio.current
            });
        }
    }, /*#__PURE__*/ React.createElement("img", _object_spread({
        draggable: false,
        onLoad: function(e) {
            setLoading(false);
            var width = e.target.naturalWidth;
            var height = e.target.naturalHeight;
            radio.current = width / height;
            var containerWidth = document.documentElement.clientWidth || window.innerWidth || 600;
            var maxAllowedWidth = Math.min(containerWidth * 0.9, 600);
            width = Math.min((defaultSize === null || defaultSize === void 0 ? void 0 : defaultSize.width) || 400, maxAllowedWidth);
            setSize({
                width: width,
                height: width / radio.current
            });
        },
        onError: function() {
            setError(true);
        },
        alt: 'image',
        referrerPolicy: 'no-referrer',
        width: "min(".concat(size.width, "px, 100%)"),
        ref: imgRef,
        style: {
            width: '100%',
            height: 'auto',
            position: 'relative',
            zIndex: 99,
            outline: selected ? '2px solid #1890ff' : 'none',
            boxShadow: selected ? '0 0 0 2px #1890ff' : 'none',
            minHeight: 20,
            display: loading ? 'none' : 'block',
            userSelect: 'none',
            WebkitUserSelect: 'none',
            MozUserSelect: 'none',
            msUserSelect: 'none',
            pointerEvents: 'none'
        }
    }, props))));
};
export function EditorImage(param) {
    var element = param.element, attributes = param.attributes, children = param.children;
    var _element_url, _state;
    debugInfo('EditorImage - 渲染图片', {
        url: element === null || element === void 0 ? void 0 : (_element_url = element.url) === null || _element_url === void 0 ? void 0 : _element_url.substring(0, 100),
        alt: element === null || element === void 0 ? void 0 : element.alt,
        width: element === null || element === void 0 ? void 0 : element.width,
        height: element === null || element === void 0 ? void 0 : element.height,
        finished: element === null || element === void 0 ? void 0 : element.finished
    });
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    var _useSelStatus = _sliced_to_array(useSelStatus(element), 2), _ = _useSelStatus[0], path = _useSelStatus[1];
    var markdownEditorRef = useEditorStore().markdownEditorRef;
    var htmlRef = React.useRef(null);
    var _useState = _sliced_to_array(useState(false), 2), showAsText = _useState[0], setShowAsText = _useState[1];
    var _useGetSetState = _sliced_to_array(useGetSetState({
        height: element.height,
        dragging: false,
        loadSuccess: true,
        url: '',
        selected: false,
        type: getMediaType(element === null || element === void 0 ? void 0 : element.url, element.alt)
    }), 2), state = _useGetSetState[0], setState = _useGetSetState[1];
    var updateElement = useRefFunction(function(attr) {
        if (!(markdownEditorRef === null || markdownEditorRef === void 0 ? void 0 : markdownEditorRef.current)) return;
        Transforms.setNodes(markdownEditorRef.current, attr, {
            at: path
        });
    });
    var locale = useContext(I18nContext).locale;
    var initial = useRefFunction(function() {
        return _async_to_generator(function() {
            var _element_url, type, realUrl, img;
            return _ts_generator(this, function(_state) {
                debugInfo('EditorImage - 初始化图片', {
                    url: element === null || element === void 0 ? void 0 : (_element_url = element.url) === null || _element_url === void 0 ? void 0 : _element_url.substring(0, 100),
                    alt: element === null || element === void 0 ? void 0 : element.alt
                });
                type = getMediaType(element === null || element === void 0 ? void 0 : element.url, element.alt);
                type = !type ? 'image' : type;
                setState({
                    type: [
                        'image',
                        'video',
                        'autio',
                        'attachment'
                    ].includes(type) ? type : 'other'
                });
                realUrl = element === null || element === void 0 ? void 0 : element.url;
                setState({
                    url: realUrl
                });
                debugInfo('EditorImage - 设置图片类型和URL', {
                    type: state().type,
                    url: realUrl === null || realUrl === void 0 ? void 0 : realUrl.substring(0, 100)
                });
                if (state().type === 'image' || state().type === 'other') {
                    img = document.createElement('img');
                    img.referrerPolicy = 'no-referrer';
                    img.crossOrigin = 'anonymous';
                    img.src = realUrl;
                    img.onerror = function() {
                        debugInfo('EditorImage - 图片加载失败');
                        setState({
                            loadSuccess: false
                        });
                    };
                    img.onload = function() {
                        debugInfo('EditorImage - 图片加载成功');
                        setState({
                            loadSuccess: true
                        });
                    };
                }
                if (!element.mediaType) {
                    updateElement({
                        mediaType: state().type
                    });
                }
                return [
                    2
                ];
            });
        })();
    });
    useLayoutEffect(function() {
        initial();
    }, [
        element === null || element === void 0 ? void 0 : element.url
    ]);
    // 如果 finished 为 false，设置 5 秒超时，超时后显示为文本
    useEffect(function() {
        if (element.finished === false) {
            setShowAsText(false);
            var timer = setTimeout(function() {
                setShowAsText(true);
            }, 5000);
            return function() {
                clearTimeout(timer);
            };
        } else {
            setShowAsText(false);
        }
    }, [
        element.finished
    ]);
    var imageDom = useMemo(function() {
        var _state;
        debugInfo('EditorImage - 生成图片 DOM', {
            finished: element.finished,
            showAsText: showAsText,
            loadSuccess: state().loadSuccess
        });
        // 检查是否为不完整的图片（finished 状态）
        if (element.finished === false) {
            // 如果 5 秒后仍未完成，显示为文本
            if (showAsText) {
                debugInfo('EditorImage - 显示为文本（超时）');
                return /*#__PURE__*/ React.createElement("div", {
                    style: {
                        padding: '8px 12px',
                        border: '1px solid #d9d9d9',
                        borderRadius: '4px',
                        color: 'rgba(0, 0, 0, 0.65)',
                        wordBreak: 'break-all'
                    }
                }, element.alt || element.url || '图片链接');
            }
            // 5 秒内显示 loading 状态的占位符
            debugInfo('EditorImage - 显示加载占位符');
            return /*#__PURE__*/ React.createElement(Skeleton.Image, {
                active: true
            });
        }
        // 如果图片加载失败，显示为链接
        if (!state().loadSuccess) {
            var _state1, _state2;
            debugInfo('EditorImage - 显示错误链接');
            return /*#__PURE__*/ React.createElement(MediaErrorLink, {
                url: (_state1 = state()) === null || _state1 === void 0 ? void 0 : _state1.url,
                fallbackUrl: element === null || element === void 0 ? void 0 : element.url,
                displayText: (element === null || element === void 0 ? void 0 : element.alt) || ((_state2 = state()) === null || _state2 === void 0 ? void 0 : _state2.url) || (element === null || element === void 0 ? void 0 : element.url) || '图片链接',
                style: {
                    fontSize: '13px',
                    lineHeight: '1.5'
                }
            });
        }
        // 编辑模式：使用可调整大小的图片
        debugInfo('EditorImage - 使用可调整大小的图片', {
            width: element.width,
            height: element.height
        });
        return /*#__PURE__*/ React.createElement(ResizeImage, {
            defaultSize: {
                width: Number(element.width) || element.width || 400,
                height: Number(element.height) || 400
            },
            selected: state().selected,
            src: (_state = state()) === null || _state === void 0 ? void 0 : _state.url,
            onResizeStart: function() {
                debugInfo('EditorImage - 开始调整大小');
                setState({
                    selected: true
                });
            },
            onResizeStop: function(size) {
                debugInfo('EditorImage - 调整大小完成', {
                    size: size
                });
                if (!(markdownEditorRef === null || markdownEditorRef === void 0 ? void 0 : markdownEditorRef.current)) return;
                Transforms.setNodes(markdownEditorRef.current, size, {
                    at: path
                });
                setState({
                    selected: false
                });
            }
        });
    }, [
        state().type,
        (_state = state()) === null || _state === void 0 ? void 0 : _state.url,
        state().selected,
        state().loadSuccess,
        element.finished,
        showAsText,
        element === null || element === void 0 ? void 0 : element.rawMarkdown
    ]);
    return /*#__PURE__*/ React.createElement("div", _object_spread_props(_object_spread({}, attributes), {
        "data-be": "image",
        "data-drag-el": true,
        "data-testid": "image-container",
        style: {
            cursor: 'pointer',
            position: 'relative',
            userSelect: 'none',
            WebkitUserSelect: 'none',
            MozUserSelect: 'none',
            msUserSelect: 'none',
            width: '100%',
            maxWidth: '100%',
            boxSizing: 'border-box'
        },
        draggable: false,
        onContextMenu: function(e) {
            e.stopPropagation();
        },
        onMouseDown: function(e) {
            e.stopPropagation();
        },
        onDragStart: function(e) {
            e.preventDefault();
            e.stopPropagation();
        }
    }), /*#__PURE__*/ React.createElement(Popover, {
        arrow: false,
        styles: {
            body: {
                padding: 8
            }
        },
        trigger: "hover",
        open: state().selected ? undefined : false,
        content: /*#__PURE__*/ React.createElement(Space, null, /*#__PURE__*/ React.createElement(ActionIconBox, {
            title: (locale === null || locale === void 0 ? void 0 : locale.delete) || '删除',
            type: "danger",
            onClick: function(e) {
                e.stopPropagation();
                Modal.confirm({
                    title: (locale === null || locale === void 0 ? void 0 : locale.deleteMedia) || '删除媒体',
                    content: (locale === null || locale === void 0 ? void 0 : locale.confirmDelete) || '确定删除该媒体吗？',
                    onOk: function() {
                        if (!(markdownEditorRef === null || markdownEditorRef === void 0 ? void 0 : markdownEditorRef.current)) return;
                        Transforms.removeNodes(markdownEditorRef.current, {
                            at: path
                        });
                    }
                });
            }
        }, /*#__PURE__*/ React.createElement(DeleteFilled, null)), /*#__PURE__*/ React.createElement(ActionIconBox, {
            title: (element === null || element === void 0 ? void 0 : element.block) ? locale === null || locale === void 0 ? void 0 : locale.blockImage : locale === null || locale === void 0 ? void 0 : locale.inlineImage,
            onClick: function(e) {
                e.stopPropagation();
                if (!(markdownEditorRef === null || markdownEditorRef === void 0 ? void 0 : markdownEditorRef.current)) return;
                Transforms.setNodes(markdownEditorRef.current, {
                    block: !element.block
                }, {
                    at: path
                });
                Transforms.setNodes(markdownEditorRef.current, {
                    block: !element.block
                }, {
                    at: Path.parent(path)
                });
            }
        }, /*#__PURE__*/ React.createElement(BlockOutlined, null)))
    }, /*#__PURE__*/ React.createElement("div", {
        onClick: function() {
            setTimeout(function() {
                setState({
                    selected: true
                });
            }, 16);
        },
        tabIndex: -1,
        style: {
            padding: 4,
            display: 'flex',
            width: '100%',
            maxWidth: '100%',
            boxSizing: 'border-box'
        },
        ref: htmlRef,
        draggable: false,
        contentEditable: false,
        "data-be": "media-container"
    }, imageDom, /*#__PURE__*/ React.createElement("div", {
        style: {
            display: 'none'
        }
    }, children))));
}
