import { definePmNodeConverter } from "./../../pm-converters/types.js";
import { removeNullValues } from "./../../pm-converters/utils.js";
import { Node_Type } from "./../../ricos-schema/next-schema/index.js";
const paragraphConverter = definePmNodeConverter({
  toPm: {
    types: [Node_Type.PARAGRAPH],
    convert: (node, visit) => {
      const { id = "", style, paragraphData } = node || {};
      const result = {
        type: Node_Type.PARAGRAPH,
        attrs: {
          id,
          style: style ?? null,
          indentation: paragraphData?.indentation ?? null,
          level: paragraphData?.level ?? null,
          textStyle: paragraphData?.textStyle ?? null
        },
        content: visit?.(node) ?? []
      };
      return result;
    }
  },
  fromPm: {
    types: [Node_Type.PARAGRAPH],
    convert: (node, visit) => {
      const attributes = node.attrs;
      const { id, style, ...data } = attributes || {};
      const nodes = visit?.(node) ?? [];
      const result = {
        type: Node_Type.PARAGRAPH,
        id,
        ...nodes && nodes.length ? { nodes } : {},
        ...style ? { style } : {},
        paragraphData: {
          ...removeNullValues(data)
        }
      };
      return result;
    }
  }
});
export {
  paragraphConverter
};
//# sourceMappingURL=paragraph-converter.js.map
