// (C) 2021-2026 GoodData Corporation
import { put, select } from "redux-saga/effects";
import { richTextWidgetContentChanged, } from "../../events/richText.js";
import { tabsActions } from "../../store/tabs/index.js";
import { selectWidgetsMap } from "../../store/tabs/layout/layoutSelectors.js";
import { validateExistingRichTextWidget } from "./validation/widgetValidations.js";
export function* changeRichTextWidgetContentHandler(ctx, cmd) {
    const { payload: { content }, correlationId, } = cmd;
    const widgets = yield select(selectWidgetsMap);
    const richTextWidget = validateExistingRichTextWidget(widgets, cmd, ctx);
    yield put(tabsActions.replaceRichTextWidgetContent({
        ref: richTextWidget.ref,
        content,
        undo: {
            cmd,
        },
    }));
    return richTextWidgetContentChanged(ctx, richTextWidget.ref, content, correlationId);
}
//# sourceMappingURL=changeRichTextWidgetContentHandler.js.map