{"version":3,"file":"taiga-ui-editor-extensions-background-color.mjs","sources":["../../../projects/editor/extensions/background-color/index.ts","../../../projects/editor/extensions/background-color/taiga-ui-editor-extensions-background-color.ts"],"sourcesContent":["import {type Command, Extension, type GlobalAttributes} from '@tiptap/core';\n\nexport interface TuiBackgroundColorOptions {\n    types: string[];\n}\n\ndeclare module '@tiptap/core' {\n    interface Commands<ReturnType> {\n        backgroundColor: {\n            /**\n             * Set the background color\n             */\n            setBackgroundColor(backgroundColor: string): ReturnType;\n            /**\n             * Unset the background color\n             */\n            unsetBackgroundColor(): ReturnType;\n        };\n    }\n}\n\nexport const TuiBackgroundColor = Extension.create<TuiBackgroundColorOptions>({\n    name: 'backgroundColor',\n\n    addOptions(): TuiBackgroundColorOptions {\n        return {types: ['textStyle']};\n    },\n\n    addGlobalAttributes(): GlobalAttributes {\n        return [\n            {\n                types: this.options.types,\n                attributes: {\n                    backgroundColor: {\n                        default: null,\n                        renderHTML: ({backgroundColor}) =>\n                            backgroundColor\n                                ? {\n                                      style: `background-color: ${backgroundColor}`,\n                                  }\n                                : {},\n                        parseHTML: ({style}) =>\n                            style.backgroundColor.replaceAll(/['\"]+/g, ''),\n                        keepOnSplit: false,\n                    },\n                },\n            },\n        ];\n    },\n\n    addCommands(): {\n        setBackgroundColor?(backgroundColor: string): Command;\n        unsetBackgroundColor?(): Command;\n    } {\n        return {\n            setBackgroundColor:\n                (backgroundColor) =>\n                ({chain}) =>\n                    chain().setMark('textStyle', {backgroundColor}).run(),\n            unsetBackgroundColor:\n                () =>\n                ({chain}) =>\n                    chain().setMark('textStyle', {backgroundColor: null}).run(),\n        };\n    },\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;AAqBa,MAAA,kBAAkB,GAAG,SAAS,CAAC,MAAM,CAA4B;AAC1E,IAAA,IAAI,EAAE,iBAAiB;IAEvB,UAAU,GAAA;AACN,QAAA,OAAO,EAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAC,CAAC;KACjC;IAED,mBAAmB,GAAA;QACf,OAAO;AACH,YAAA;AACI,gBAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;AACzB,gBAAA,UAAU,EAAE;AACR,oBAAA,eAAe,EAAE;AACb,wBAAA,OAAO,EAAE,IAAI;wBACb,UAAU,EAAE,CAAC,EAAC,eAAe,EAAC,KAC1B,eAAe;AACX,8BAAE;gCACI,KAAK,EAAE,CAAqB,kBAAA,EAAA,eAAe,CAAE,CAAA;AAChD,6BAAA;AACH,8BAAE,EAAE;AACZ,wBAAA,SAAS,EAAE,CAAC,EAAC,KAAK,EAAC,KACf,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC;AAClD,wBAAA,WAAW,EAAE,KAAK;AACrB,qBAAA;AACJ,iBAAA;AACJ,aAAA;SACJ,CAAC;KACL;IAED,WAAW,GAAA;QAIP,OAAO;YACH,kBAAkB,EACd,CAAC,eAAe,KAChB,CAAC,EAAC,KAAK,EAAC,KACJ,KAAK,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAC,eAAe,EAAC,CAAC,CAAC,GAAG,EAAE;YAC7D,oBAAoB,EAChB,MACA,CAAC,EAAC,KAAK,EAAC,KACJ,KAAK,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAC,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC,GAAG,EAAE;SACtE,CAAC;KACL;AACJ,CAAA;;ACjED;;AAEG;;;;"}