{"version":3,"file":"withStrapiSchema.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.ts"],"sourcesContent":["import { type Text, Node, Editor, Element, Transforms } from 'slate';\n\nconst isText = (node: unknown): node is Text => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'text';\n};\n\n/**\n * This plugin is used to normalize the Slate document to match the Strapi schema.\n */\nconst withStrapiSchema = (editor: Editor) => {\n const { normalizeNode } = editor;\n\n /**\n * On the strapi schema, we want text nodes to have type: text\n * By default, Slate add text nodes without type: text\n * So we add this normalization for the cases when Slate add text nodes automatically\n */\n editor.normalizeNode = (entry) => {\n const [node, path] = entry;\n\n if (!Element.isElement(node) && !isText(node)) {\n Transforms.setNodes(editor, { type: 'text' }, { at: path });\n\n return;\n }\n\n normalizeNode(entry);\n };\n\n return editor;\n};\n\nexport { withStrapiSchema };\n"],"names":["isText","node","Node","isNode","Editor","isEditor","type","withStrapiSchema","editor","normalizeNode","entry","path","Element","isElement","Transforms","setNodes","at"],"mappings":";;AAEA,MAAMA,SAAS,CAACC,IAAAA,GAAAA;IACd,OAAOC,IAAAA,CAAKC,MAAM,CAACF,IAAAA,CAAAA,IAAS,CAACG,MAAAA,CAAOC,QAAQ,CAACJ,IAAAA,CAAAA,IAASA,IAAAA,CAAKK,IAAI,KAAK,MAAA;AACtE,CAAA;AAEA;;IAGA,MAAMC,mBAAmB,CAACC,MAAAA,GAAAA;IACxB,MAAM,EAAEC,aAAa,EAAE,GAAGD,MAAAA;AAE1B;;;;MAKAA,MAAAA,CAAOC,aAAa,GAAG,CAACC,KAAAA,GAAAA;QACtB,MAAM,CAACT,IAAAA,EAAMU,IAAAA,CAAK,GAAGD,KAAAA;AAErB,QAAA,IAAI,CAACE,OAAAA,CAAQC,SAAS,CAACZ,IAAAA,CAAAA,IAAS,CAACD,OAAOC,IAAAA,CAAAA,EAAO;YAC7Ca,UAAAA,CAAWC,QAAQ,CAACP,MAAAA,EAAQ;gBAAEF,IAAAA,EAAM;aAAO,EAAG;gBAAEU,EAAAA,EAAIL;AAAK,aAAA,CAAA;AAEzD,YAAA;AACF,QAAA;QAEAF,aAAAA,CAAcC,KAAAA,CAAAA;AAChB,IAAA,CAAA;IAEA,OAAOF,MAAAA;AACT;;;;"}