"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var toggle_node_text_wrap_exports = {};
__export(toggle_node_text_wrap_exports, {
  toggleNodeTextWrap: () => toggleNodeTextWrap
});
module.exports = __toCommonJS(toggle_node_text_wrap_exports);
var import_v1 = require("./../../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_tiptap = require("./../../tiptap/index.js");
const toggleNodeTextWrap = () => ({ commands, tr, dispatch }) => {
  if (!dispatch) {
    return !(0, import_tiptap.findParentNodeClosestToPos)(
      tr.selection.$from,
      (node) => node?.type?.name === import_v1.Node_Type.LAYOUT_CELL || node?.type?.name === import_v1.Node_Type.LIST_ITEM
    );
  }
  const $from = tr.selection.$from;
  const selectedNode = $from.nodeAfter;
  const nodeType = selectedNode?.type.name || "";
  const nodeContainerData = selectedNode?.attrs.containerData;
  const currentTextWrap = nodeContainerData?.textWrap ?? true;
  return commands.updateAttributes(nodeType, {
    containerData: { ...nodeContainerData, textWrap: !currentTextWrap }
  });
};
//# sourceMappingURL=toggle-node-text-wrap.js.map
